Style
This commit is contained in:
@@ -282,7 +282,7 @@ impl ChainSync {
|
||||
}
|
||||
}
|
||||
let hdr = Header {
|
||||
data: r.at(i).raw().to_vec(),
|
||||
data: r.at(i).as_raw().to_vec(),
|
||||
hash: hash.clone(),
|
||||
parent: info.parent_hash(),
|
||||
};
|
||||
@@ -326,8 +326,8 @@ impl ChainSync {
|
||||
for i in 0..item_count {
|
||||
let body: Rlp = r.at(i);
|
||||
let tx = body.at(0);
|
||||
let tx_root = ::util::triehash::ordered_trie_root(tx.iter().map(|r| r.raw().to_vec()).collect()); //TODO: get rid of vectors here
|
||||
let uncles = body.at(1).raw().sha3();
|
||||
let tx_root = ::util::triehash::ordered_trie_root(tx.iter().map(|r| r.as_raw().to_vec()).collect()); //TODO: get rid of vectors here
|
||||
let uncles = body.at(1).as_raw().sha3();
|
||||
let header_id = HeaderId {
|
||||
transactions_root: tx_root,
|
||||
uncles: uncles
|
||||
@@ -335,7 +335,7 @@ impl ChainSync {
|
||||
match self.header_ids.get(&header_id).map(|n| *n) {
|
||||
Some(n) => {
|
||||
self.header_ids.remove(&header_id);
|
||||
self.bodies.insert_item(n, body.raw().to_vec());
|
||||
self.bodies.insert_item(n, body.as_raw().to_vec());
|
||||
trace!(target: "sync", "Got body {}", n);
|
||||
}
|
||||
None => {
|
||||
@@ -351,10 +351,10 @@ impl ChainSync {
|
||||
fn on_peer_new_block(&mut self, io: &mut SyncIo, peer_id: &PeerId, r: &Rlp) {
|
||||
let block_rlp = r.at(0);
|
||||
let header_rlp = block_rlp.at(0);
|
||||
let h = header_rlp.raw().sha3();
|
||||
let h = header_rlp.as_raw().sha3();
|
||||
|
||||
trace!(target: "sync", "{}-> NewBlock ({})", peer_id, h);
|
||||
match io.chain().import_block(block_rlp.raw()) {
|
||||
match io.chain().import_block(block_rlp.as_raw()) {
|
||||
ImportResult::AlreadyInChain => {
|
||||
trace!(target: "sync", "New block already in chain {:?}", h);
|
||||
},
|
||||
@@ -590,8 +590,8 @@ impl ChainSync {
|
||||
let mut block_rlp = RlpStream::new_list(3);
|
||||
block_rlp.append_raw(&headers.1[i].data, 1);
|
||||
let body = Rlp::new(&bodies.1[i]);
|
||||
block_rlp.append_raw(body.at(0).raw(), 1);
|
||||
block_rlp.append_raw(body.at(1).raw(), 1);
|
||||
block_rlp.append_raw(body.at(0).as_raw(), 1);
|
||||
block_rlp.append_raw(body.at(1).as_raw(), 1);
|
||||
let h = &headers.1[i].hash;
|
||||
match io.chain().import_block(&block_rlp.out()) {
|
||||
ImportResult::AlreadyInChain => {
|
||||
|
||||
@@ -42,28 +42,28 @@ impl TestBlockChainClient {
|
||||
let mut uncles = RlpStream::new_list(if empty {0} else {1});
|
||||
if !empty {
|
||||
uncles.append(&H256::from(&U256::from(n)));
|
||||
header.uncles_hash = uncles.raw().sha3();
|
||||
header.uncles_hash = uncles.as_raw().sha3();
|
||||
}
|
||||
let mut rlp = RlpStream::new_list(3);
|
||||
rlp.append(&header);
|
||||
rlp.append_raw(&rlp::NULL_RLP, 1);
|
||||
rlp.append_raw(uncles.raw(), 1);
|
||||
self.import_block(rlp.raw());
|
||||
rlp.append_raw(uncles.as_raw(), 1);
|
||||
self.import_block(rlp.as_raw());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BlockChainClient for TestBlockChainClient {
|
||||
fn block_header(&self, h: &H256) -> Option<Bytes> {
|
||||
self.blocks.get(h).map(|r| Rlp::new(r).at(0).raw().to_vec())
|
||||
self.blocks.get(h).map(|r| Rlp::new(r).at(0).as_raw().to_vec())
|
||||
|
||||
}
|
||||
|
||||
fn block_body(&self, h: &H256) -> Option<Bytes> {
|
||||
self.blocks.get(h).map(|r| {
|
||||
let mut stream = RlpStream::new_list(2);
|
||||
stream.append_raw(Rlp::new(&r).at(1).raw(), 1);
|
||||
stream.append_raw(Rlp::new(&r).at(2).raw(), 1);
|
||||
stream.append_raw(Rlp::new(&r).at(1).as_raw(), 1);
|
||||
stream.append_raw(Rlp::new(&r).at(2).as_raw(), 1);
|
||||
stream.out()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user