Skip to content

Commit ef4387e

Browse files
committed
blockchain WriteBlockAndSetHeadWithTime
1 parent c6ebd8c commit ef4387e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

core/blockchain.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,16 @@ func (bc *BlockChain) WriteBlockAndSetHead(block *types.Block, receipts []*types
13391339
return bc.writeBlockAndSetHead(block, receipts, logs, state, emitHeadEvent)
13401340
}
13411341

1342+
// WriteBlockAndSetHeadWithTime also counts processTime, which will cause intermittent TrieDirty cache writes
1343+
func (bc *BlockChain) WriteBlockAndSetHeadWithTime(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool, processTime time.Duration) (status WriteStatus, err error) {
1344+
if !bc.chainmu.TryLock() {
1345+
return NonStatTy, errChainStopped
1346+
}
1347+
defer bc.chainmu.Unlock()
1348+
bc.gcproc += processTime
1349+
return bc.writeBlockAndSetHead(block, receipts, logs, state, emitHeadEvent)
1350+
}
1351+
13421352
// writeBlockAndSetHead is the internal implementation of WriteBlockAndSetHead.
13431353
// This function expects the chain mutex to be held.
13441354
func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {

0 commit comments

Comments
 (0)