Beispiel #1
0
 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
Beispiel #2
0
    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))
Beispiel #3
0
 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)
Beispiel #4
0
 def __repr__(self):
     return "<%s %r B:%r>" % (self.__class__.__name__, self.signature, phx(self.blockhash))
Beispiel #5
0
 def __repr__(self):
     # add id so they are not filtered
     return "<%s %r %d>" % (self.__class__.__name__, phx(self.blockhash), id(self))
Beispiel #6
0
 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)
Beispiel #7
0
 def __repr__(self):
     return "<%s %r B:%r>" % (self.__class__.__name__, self.signature,
                              phx(self.blockhash))
Beispiel #8
0
 def __repr__(self):
     # add id so they are not filtered
     return "<%s %r %d>" % (self.__class__.__name__, phx(
         self.blockhash), id(self))