func name

This commit is contained in:
Roy Crihfield 2020-11-24 21:51:30 +08:00
parent dd6f9ccabe
commit ae2f32f9d8

View File

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