Backports to beta (#2068)

* Fix several RPCs (#1926)

* Fix up pending receipts details.

* Add support for additional params and registry over RPC.

* Fix tests.

* Add test, additional fix.

Fixes #1932.

* Fix up tests.

* Fix test.

* Fix test.

* DB WAL size limit (#1935)

* Limit WAL size

* Check pruning by db modification date (#1924)

* Cache address hash (#1943)

* ECIES without MAC (#1948)

* Use random IV for ECIES AES

* ECIES encrypt/decrypt for a single message

* Derive IV from shared secret

* Apply settings to column families

* fixed #1933 (#1979)

* Fixed neighbours collection (#1996)

* dapps-hosts configuration

* Disabled counter check

* always process trie death row on commit, add more tracing

* fixed transaction addresses mapping, fixes #1971

* simplified iterator

* v1.3.1

* v1.3.1
This commit is contained in:
Arkadiy Paronyan
2016-09-11 14:04:17 +02:00
committed by GitHub
parent 1ccc90108c
commit 2a82fa0a47
43 changed files with 732 additions and 181 deletions

View File

@@ -56,11 +56,11 @@ impl From<H256> for NodeHandle {
}
}
fn empty_children() -> [Option<NodeHandle>; 16] {
[
fn empty_children() -> Box<[Option<NodeHandle>; 16]> {
Box::new([
None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None,
]
])
}
/// Node types in the Trie.
@@ -78,7 +78,7 @@ enum Node {
/// The child node is always a branch.
Extension(Bytes, NodeHandle),
/// A branch has up to 16 children and an optional value.
Branch([Option<NodeHandle>; 16], Option<Bytes>)
Branch(Box<[Option<NodeHandle>; 16]>, Option<Bytes>)
}
impl Node {
@@ -820,19 +820,19 @@ impl<'a> TrieDBMut<'a> {
/// Commit the in-memory changes to disk, freeing their storage and
/// updating the state root.
pub fn commit(&mut self) {
let handle = match self.root_handle() {
NodeHandle::Hash(_) => return, // no changes necessary.
NodeHandle::InMemory(h) => h,
};
trace!(target: "trie", "Committing trie changes to db.");
// kill all the nodes on death row.
// always kill all the nodes on death row.
trace!(target: "trie", "{:?} nodes to remove from db", self.death_row.len());
for hash in self.death_row.drain() {
self.db.remove(&hash);
}
let handle = match self.root_handle() {
NodeHandle::Hash(_) => return, // no changes necessary.
NodeHandle::InMemory(h) => h,
};
match self.storage.destroy(handle) {
Stored::New(node) => {
let root_rlp = node.into_rlp(|child, stream| self.commit_node(child, stream));
@@ -906,21 +906,29 @@ impl<'a> TrieMut for TrieDBMut<'a> {
return self.remove(key);
}
trace!(target: "trie", "insert: key={:?}, value={:?}", key.pretty(), value.pretty());
let root_handle = self.root_handle();
let (new_handle, _) = try!(self.insert_at(root_handle, NibbleSlice::new(key), value.to_owned()));
let (new_handle, changed) = try!(self.insert_at(root_handle, NibbleSlice::new(key), value.to_owned()));
trace!(target: "trie", "insert: altered trie={}", changed);
self.root_handle = NodeHandle::InMemory(new_handle);
Ok(())
}
fn remove(&mut self, key: &[u8]) -> super::Result<()> {
trace!(target: "trie", "remove: key={:?}", key.pretty());
let root_handle = self.root_handle();
let key = NibbleSlice::new(key);
match try!(self.remove_at(root_handle, key)) {
Some((handle, _)) => {
Some((handle, changed)) => {
trace!(target: "trie", "remove: altered trie={}", changed);
self.root_handle = NodeHandle::InMemory(handle);
}
None => {
trace!(target: "trie", "remove: obliterated trie");
self.root_handle = NodeHandle::Hash(SHA3_NULL_RLP);
*self.root = SHA3_NULL_RLP;
}