def _recv_blocks(self, blocks): new_blocks_H = set() # memorize for block in blocks: h = rlp_hash(block) print self, "_recv_blocks:", rlp_hash_hex(block) if h not in self.dummy_blockchain: new_blocks_H.add(h) self.dummy_blockchain[h] = block # ask for children for h in new_blocks_H: print self, "_recv_blocks: ask for child block", h.encode('hex') self.out_proxy.send_get_chain(1, [h])
def recv_blocks(self, blocks): new_blocks_H = set() # memorize for block in blocks: h = rlp_hash(block) logger.debug("recv_blocks: %r" % rlp_hash_hex(block)) if h not in self.dummy_blockchain: new_blocks_H.add(h) self.dummy_blockchain[h] = block # ask for children for h in new_blocks_H: logger.debug("recv_blocks: ask for child block %r" % h.encode('hex')) signals.remote_chain_data_requested.send( sender=self, parents=[h], count=1)
def recv_blocks(self, block_lst): """ block_lst is rlp decoded data """ block_lst.reverse() # oldest block is sent first in list # FIXME validate received chain, compare with local chain for data in block_lst: logger.debug("processing block: %r" % rlp_hash_hex(data)) block = Block.deserialize(rlp.encode(data)) h = rlp_hash(data) try: self.blockchain.get(h) except KeyError: self.add_block(block) new_blocks_H.add(h)