AddBlock add a new block to this validator
(block *types.Block)
| 67 | |
| 68 | // AddBlock add a new block to this validator |
| 69 | func (self *IncrementValidator) AddBlock(block *types.Block) { |
| 70 | self.mutex.Lock() |
| 71 | defer self.mutex.Unlock() |
| 72 | if len(self.blocks) == 0 { |
| 73 | self.baseHeight = block.Header.Height |
| 74 | } |
| 75 | |
| 76 | if self.baseHeight+uint32(len(self.blocks)) != block.Header.Height { |
| 77 | start, end := self.blockRange() |
| 78 | log.Errorf("discontinue block is not allowed: [start, end)=[%d, %d), block height= %d", |
| 79 | start, end, block.Header.Height) |
| 80 | return |
| 81 | } |
| 82 | |
| 83 | if len(self.blocks) >= self.maxBlocks { |
| 84 | self.blocks = self.blocks[1:] |
| 85 | self.baseHeight += 1 |
| 86 | } |
| 87 | txHashes := make(map[common.Uint256]bool) |
| 88 | for _, tx := range block.Transactions { |
| 89 | txHashes[tx.Hash()] = true |
| 90 | } |
| 91 | self.blocks = append(self.blocks, txHashes) |
| 92 | } |
| 93 | |
| 94 | // Verfiy does increment check start at startHeight |
| 95 | func (self *IncrementValidator) Verify(tx *types.Transaction, startHeight uint32) error { |
nothing calls this directly
no test coverage detected