func name

This commit is contained in:
2020-11-25 00:06:59 +08:00
parent dd6f9ccabe
commit ae2f32f9d8
+5 -4
View File
@@ -200,8 +200,9 @@ func (sds *Service) APIs() []rpc.API {
}
}
// Return the parent block of currentBlock, using the cached block if available
func (lbc *blockCache) replace(currentBlock *types.Block, bc blockChain) *types.Block {
// Return the parent block of currentBlock, using the cached block if available;
// and cache the passed block
func (lbc *blockCache) getParentBlock(currentBlock *types.Block, bc blockChain) *types.Block {
lbc.Lock()
parentHash := currentBlock.ParentHash()
var parentBlock *types.Block
@@ -248,7 +249,7 @@ func (sds *Service) writeLoopWorker(params workerParams) {
log.Debug("WriteLoop(): chain event received", "event", chainEvent)
currentBlock := chainEvent.Block
statediffMetrics.lastEventHeight.Update(int64(currentBlock.Number().Uint64()))
parentBlock := sds.BlockCache.replace(currentBlock, sds.BlockChain)
parentBlock := sds.BlockCache.getParentBlock(currentBlock, sds.BlockChain)
if parentBlock == nil {
log.Error("Parent block is nil, skipping this block", "block height", currentBlock.Number())
continue
@@ -290,7 +291,7 @@ func (sds *Service) Loop(chainEventCh chan core.ChainEvent) {
continue
}
currentBlock := chainEvent.Block
parentBlock := sds.BlockCache.replace(currentBlock, sds.BlockChain)
parentBlock := sds.BlockCache.getParentBlock(currentBlock, sds.BlockChain)
if parentBlock == nil {
log.Error("Parent block is nil, skipping this block", "block height", currentBlock.Number())
continue