MCPcopy Create free account
hub / github.com/DNAProject/DNA / fastForwardBlock

Method fastForwardBlock

consensus/vbft/service.go:2037–2057  ·  view source on GitHub ↗
(block *Block)

Source from the content-addressed store, hash-verified

2035}
2036
2037func (self *Server) fastForwardBlock(block *Block) error {
2038
2039 // TODO: update chainconfig when forwarding
2040
2041 if isActive(self.getState()) {
2042 return fmt.Errorf("server %d: invalid fastforward, current state: %d", self.Index, self.getState())
2043 }
2044 if self.GetCurrentBlockNo() > block.getBlockNum() {
2045 return nil
2046 }
2047 if self.GetCurrentBlockNo() == block.getBlockNum() {
2048 // block from peer syncer, there should only one candidate block
2049 flag := false
2050 if len(block.Block.Header.SigData) <= 1 {
2051 flag = true
2052 }
2053 return self.sealBlock(block, false, flag)
2054 }
2055 return fmt.Errorf("server %d: fastforward blk %d failed, current blkNum: %d",
2056 self.Index, block.getBlockNum(), self.GetCurrentBlockNo())
2057}
2058
2059func (self *Server) sealBlock(block *Block, empty bool, sigdata bool) error {
2060 sealedBlkNum := block.getBlockNum()

Callers 1

runMethod · 0.80

Calls 6

getStateMethod · 0.95
GetCurrentBlockNoMethod · 0.95
sealBlockMethod · 0.95
isActiveFunction · 0.85
ErrorfMethod · 0.80
getBlockNumMethod · 0.80

Tested by

no test coverage detected