XDPoS/engines, core: fix non idiomatic "comma ok" boolean name, close XFN-126 (#1690)

This commit is contained in:
Daniel Liu 2025-11-03 15:15:39 +08:00 committed by GitHub
parent 58c066f053
commit d2706538e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 8 deletions

View file

@ -134,8 +134,8 @@ func (x *XDPoS_v1) VerifyHeaders(chain consensus.ChainReader, headers []*types.H
}
func (x *XDPoS_v1) verifyHeaderWithCache(chain consensus.ChainReader, header *types.Header, parents []*types.Header, fullVerify bool) error {
_, check := x.verifiedHeaders.Get(header.Hash())
if check {
_, ok := x.verifiedHeaders.Get(header.Hash())
if ok {
return nil
}
err := x.verifyHeader(chain, header, parents, fullVerify)

View file

@ -29,8 +29,8 @@ func (x *XDPoS_v2) verifyHeader(chain consensus.ChainReader, header *types.Heade
}
}
_, check := x.verifiedHeaders.Get(header.Hash())
if check {
_, ok := x.verifiedHeaders.Get(header.Hash())
if ok {
return nil
}

View file

@ -2078,11 +2078,11 @@ func (bc *BlockChain) InsertBlock(block *types.Block) error {
func (bc *BlockChain) PrepareBlock(block *types.Block) (err error) {
defer log.Debug("Done prepare block ", "number", block.NumberU64(), "hash", block.Hash(), "validator", block.Header().Validator, "err", err)
if _, check := bc.resultProcess.Get(block.Hash()); check {
if _, ok := bc.resultProcess.Get(block.Hash()); ok {
log.Debug("Stop prepare a block because the result cached", "number", block.NumberU64(), "hash", block.Hash(), "validator", block.Header().Validator)
return nil
}
if _, check := bc.calculatingBlock.Get(block.Hash()); check {
if _, ok := bc.calculatingBlock.Get(block.Hash()); ok {
log.Debug("Stop prepare a block because inserting", "number", block.NumberU64(), "hash", block.Hash(), "validator", block.Header().Validator)
return nil
}
@ -2106,7 +2106,7 @@ func (bc *BlockChain) PrepareBlock(block *types.Block) (err error) {
func (bc *BlockChain) getResultBlock(block *types.Block, verifiedM2 bool) (*ResultProcessBlock, error) {
var calculatedBlock *CalculatedBlock
if verifiedM2 {
if result, check := bc.resultProcess.Get(block.HashNoValidator()); check {
if result, ok := bc.resultProcess.Get(block.HashNoValidator()); ok {
log.Debug("Get result block from cache ", "number", block.NumberU64(), "hash", block.Hash(), "hash no validator", block.HashNoValidator())
return result, nil
}
@ -2236,7 +2236,7 @@ func (bc *BlockChain) insertBlock(block *types.Block) ([]interface{}, []*types.L
events = make([]interface{}, 0, 1)
coalescedLogs []*types.Log
)
if _, check := bc.downloadingBlock.Get(block.Hash()); check {
if _, ok := bc.downloadingBlock.Get(block.Hash()); ok {
log.Debug("Stop fetcher a block because downloading", "number", block.NumberU64(), "hash", block.Hash())
return events, coalescedLogs, nil
}