def commit(self): self.log('in commit') for blk in [ c for c in self.block_candidates.values() if c.prevhash == self.head.hash ]: if self.heights[blk.height].has_quorum == blk.hash: success = self.chainmanager.add_block(blk) self.log('commited', blk=blk, hash=phx(blk.hash)) if success: assert self.head == blk self.commit() return
def process(self): "check which blocks are missing, request and keep track of them" self.cm.log('in sync.process', known=len(self.cm.block_candidates), requested=len(self.requested)) missing = set() for blk in self.cm.block_candidates.values(): if not self.cm.get_block(blk.prevhash): missing.add(blk.prevhash) if blk.hash in self.requested: self.requested.remove(blk.hash) # cleanup p = self.cm.active_round.proposal if isinstance( p, VotingInstruction) and not self.cm.get_block(p.blockhash): missing.add(p.blockhash) for blockhash in missing - self.requested: self.requested.add(blockhash) self.cm.broadcast(BlockRequest(blockhash)) if self.requested: self.cm.log('sync', requested=[phx(bh) for bh in self.requested], missing=len(missing))
def __repr__(self): return '<Block CB:%s H:%s R:%s prev=%s %r>' % \ (self.coinbase, self.height, self.round, phx(self.prevhash), self.lockset)
def __repr__(self): return "<%s %r B:%r>" % (self.__class__.__name__, self.signature, phx(self.blockhash))
def __repr__(self): # add id so they are not filtered return "<%s %r %d>" % (self.__class__.__name__, phx(self.blockhash), id(self))
def __repr__(self): # add id so they are not filtered return "<%s %r %d>" % (self.__class__.__name__, phx( self.blockhash), id(self))