()
| 97 | } |
| 98 | |
| 99 | func (self *ChainStore) ReloadFromLedger() { |
| 100 | height := self.db.GetCurrentBlockHeight() |
| 101 | if height > self.chainedBlockNum { |
| 102 | // update chainstore height |
| 103 | self.chainedBlockNum = height |
| 104 | // remove persisted pending blocks |
| 105 | newPending := make(map[uint32]*PendingBlock) |
| 106 | for blkNum, blk := range self.pendingBlocks { |
| 107 | if blkNum > height { |
| 108 | newPending[blkNum] = blk |
| 109 | } |
| 110 | } |
| 111 | log.Debug("chainstore ReloadFromLedger pendingBlocks") |
| 112 | // update pending blocks |
| 113 | self.pendingBlocks = newPending |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | func (self *ChainStore) AddBlock(block *Block) error { |
| 118 | if block == nil { |
no test coverage detected