overlaydb put_payload.
This commit is contained in:
parent
4640d64965
commit
7733faaab5
@ -4,6 +4,7 @@ use error::*;
|
|||||||
use hash::*;
|
use hash::*;
|
||||||
use bytes::*;
|
use bytes::*;
|
||||||
use sha3::*;
|
use sha3::*;
|
||||||
|
use rlp::*;
|
||||||
use hashdb::*;
|
use hashdb::*;
|
||||||
use memorydb::*;
|
use memorydb::*;
|
||||||
use std::ops::*;
|
use std::ops::*;
|
||||||
@ -34,10 +35,10 @@ impl OverlayDB {
|
|||||||
if back_rc + rc < 0 {
|
if back_rc + rc < 0 {
|
||||||
return Err(From::from(BaseDataError::NegativelyReferencedHash));
|
return Err(From::from(BaseDataError::NegativelyReferencedHash));
|
||||||
}
|
}
|
||||||
self.put_payload(&key, (&back_value, rc + back_rc));
|
self.put_payload(&key, (back_value, rc + back_rc));
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
self.put_payload(&key, (&value, rc));
|
self.put_payload(&key, (value, rc));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ret += 1;
|
ret += 1;
|
||||||
@ -48,12 +49,20 @@ impl OverlayDB {
|
|||||||
|
|
||||||
/// Get the refs and value of the given key.
|
/// Get the refs and value of the given key.
|
||||||
fn payload(&self, key: &H256) -> Option<(Bytes, i32)> {
|
fn payload(&self, key: &H256) -> Option<(Bytes, i32)> {
|
||||||
unimplemented!();
|
db.get(&key.bytes())
|
||||||
|
.expect("Low-level database error. Some issue with your hard disk?")
|
||||||
|
.map(|d| {
|
||||||
|
Rlp r(d.deref());
|
||||||
|
r(Bytes, i32)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the refs and value of the given key.
|
/// Get the refs and value of the given key.
|
||||||
fn put_payload(&self, key: &H256, payload: (&Bytes, i32)) {
|
fn put_payload(&self, key: &H256, payload: (Bytes, i32)) {
|
||||||
unimplemented!();
|
let mut s = RlpStream::new_list(2);
|
||||||
|
s.append(payload.1);
|
||||||
|
s.append(payload.0);
|
||||||
|
backing.put(&key.bytes(), &s.out().unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user