mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core, light: fix linter
This commit is contained in:
parent
51390a57ba
commit
61ba56ff73
3 changed files with 20 additions and 9 deletions
|
|
@ -406,6 +406,11 @@ func (bc *BlockChain) SetHead(head uint64) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rawdb.WriteHeadBlockHash(db, newHeadBlock.Hash())
|
rawdb.WriteHeadBlockHash(db, newHeadBlock.Hash())
|
||||||
|
|
||||||
|
// Degrade the chain markers if they are explicitly reverted.
|
||||||
|
// In thoery we should update all in-memory markers in the
|
||||||
|
// last step, however the direction of SetHead is from high
|
||||||
|
// to low, so it's safe the update in-memory markers directly.
|
||||||
bc.currentBlock.Store(newHeadBlock)
|
bc.currentBlock.Store(newHeadBlock)
|
||||||
headBlockGauge.Update(int64(newHeadBlock.NumberU64()))
|
headBlockGauge.Update(int64(newHeadBlock.NumberU64()))
|
||||||
}
|
}
|
||||||
|
|
@ -418,6 +423,11 @@ func (bc *BlockChain) SetHead(head uint64) error {
|
||||||
newHeadFastBlock = bc.genesisBlock
|
newHeadFastBlock = bc.genesisBlock
|
||||||
}
|
}
|
||||||
rawdb.WriteHeadFastBlockHash(db, newHeadFastBlock.Hash())
|
rawdb.WriteHeadFastBlockHash(db, newHeadFastBlock.Hash())
|
||||||
|
|
||||||
|
// Degrade the chain markers if they are explicitly reverted.
|
||||||
|
// In thoery we should update all in-memory markers in the
|
||||||
|
// last step, however the direction of SetHead is from high
|
||||||
|
// to low, so it's safe the update in-memory markers directly.
|
||||||
bc.currentFastBlock.Store(newHeadFastBlock)
|
bc.currentFastBlock.Store(newHeadFastBlock)
|
||||||
headFastBlockGauge.Update(int64(newHeadFastBlock.NumberU64()))
|
headFastBlockGauge.Update(int64(newHeadFastBlock.NumberU64()))
|
||||||
}
|
}
|
||||||
|
|
@ -892,7 +902,7 @@ func (bc *BlockChain) Rollback(chain []common.Hash) {
|
||||||
for i := len(chain) - 1; i >= 0; i-- {
|
for i := len(chain) - 1; i >= 0; i-- {
|
||||||
hash := chain[i]
|
hash := chain[i]
|
||||||
|
|
||||||
// Degrade the chain markers if they are explictly reverted.
|
// Degrade the chain markers if they are explicitly reverted.
|
||||||
// In thoery we should update all in-memory markers in the
|
// In thoery we should update all in-memory markers in the
|
||||||
// last step, however the direction of rollback is from high
|
// last step, however the direction of rollback is from high
|
||||||
// to low, so it's safe the update in-memory markers directly.
|
// to low, so it's safe the update in-memory markers directly.
|
||||||
|
|
@ -904,13 +914,13 @@ func (bc *BlockChain) Rollback(chain []common.Hash) {
|
||||||
}
|
}
|
||||||
if currentFastBlock := bc.CurrentFastBlock(); currentFastBlock.Hash() == hash {
|
if currentFastBlock := bc.CurrentFastBlock(); currentFastBlock.Hash() == hash {
|
||||||
newFastBlock := bc.GetBlock(currentFastBlock.ParentHash(), currentFastBlock.NumberU64()-1)
|
newFastBlock := bc.GetBlock(currentFastBlock.ParentHash(), currentFastBlock.NumberU64()-1)
|
||||||
rawdb.WriteHeadFastBlockHash(batch, newFastBlock.Hash())
|
rawdb.WriteHeadFastBlockHash(batch, currentFastBlock.ParentHash())
|
||||||
bc.currentFastBlock.Store(newFastBlock)
|
bc.currentFastBlock.Store(newFastBlock)
|
||||||
headFastBlockGauge.Update(int64(newFastBlock.NumberU64()))
|
headFastBlockGauge.Update(int64(newFastBlock.NumberU64()))
|
||||||
}
|
}
|
||||||
if currentBlock := bc.CurrentBlock(); currentBlock.Hash() == hash {
|
if currentBlock := bc.CurrentBlock(); currentBlock.Hash() == hash {
|
||||||
newBlock := bc.GetBlock(currentBlock.ParentHash(), currentBlock.NumberU64()-1)
|
newBlock := bc.GetBlock(currentBlock.ParentHash(), currentBlock.NumberU64()-1)
|
||||||
rawdb.WriteHeadBlockHash(batch, newBlock.Hash())
|
rawdb.WriteHeadBlockHash(batch, currentBlock.ParentHash())
|
||||||
bc.currentBlock.Store(newBlock)
|
bc.currentBlock.Store(newBlock)
|
||||||
headBlockGauge.Update(int64(newBlock.NumberU64()))
|
headBlockGauge.Update(int64(newBlock.NumberU64()))
|
||||||
}
|
}
|
||||||
|
|
@ -1246,7 +1256,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
|
||||||
|
|
||||||
var lastWrite uint64
|
var lastWrite uint64
|
||||||
|
|
||||||
// writeBlockWithState writes only the block and its metadata to the database,
|
// writeBlockWithoutState writes only the block and its metadata to the database,
|
||||||
// but does not write any state. This is used to construct competing side forks
|
// but does not write any state. This is used to construct competing side forks
|
||||||
// up to the point where they exceed the canonical total difficulty.
|
// up to the point where they exceed the canonical total difficulty.
|
||||||
func (bc *BlockChain) writeBlockWithoutState(block *types.Block, td *big.Int) (err error) {
|
func (bc *BlockChain) writeBlockWithoutState(block *types.Block, td *big.Int) (err error) {
|
||||||
|
|
|
||||||
|
|
@ -519,6 +519,10 @@ func (hc *HeaderChain) SetHead(head uint64, updateFn UpdateHeadBlocksCallback, d
|
||||||
if err := markerBatch.Write(); err != nil {
|
if err := markerBatch.Write(); err != nil {
|
||||||
log.Crit("Failed to update chain markers", "error", err)
|
log.Crit("Failed to update chain markers", "error", err)
|
||||||
}
|
}
|
||||||
|
hc.currentHeader.Store(parent)
|
||||||
|
hc.currentHeaderHash = parentHash
|
||||||
|
headHeaderGauge.Update(parent.Number.Int64())
|
||||||
|
|
||||||
// Remove the relative data from the database.
|
// Remove the relative data from the database.
|
||||||
if delFn != nil {
|
if delFn != nil {
|
||||||
delFn(batch, hash, num)
|
delFn(batch, hash, num)
|
||||||
|
|
@ -527,10 +531,6 @@ func (hc *HeaderChain) SetHead(head uint64, updateFn UpdateHeadBlocksCallback, d
|
||||||
rawdb.DeleteHeader(batch, hash, num)
|
rawdb.DeleteHeader(batch, hash, num)
|
||||||
rawdb.DeleteTd(batch, hash, num)
|
rawdb.DeleteTd(batch, hash, num)
|
||||||
rawdb.DeleteCanonicalHash(batch, num)
|
rawdb.DeleteCanonicalHash(batch, num)
|
||||||
|
|
||||||
hc.currentHeader.Store(parent)
|
|
||||||
hc.currentHeaderHash = parentHash
|
|
||||||
headHeaderGauge.Update(parent.Number.Int64())
|
|
||||||
}
|
}
|
||||||
// Flush all accumulated deletions.
|
// Flush all accumulated deletions.
|
||||||
if err := batch.Write(); err != nil {
|
if err := batch.Write(); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -206,6 +206,7 @@ func (lc *LightChain) ResetWithGenesisBlock(genesis *types.Block) {
|
||||||
}
|
}
|
||||||
lc.genesisBlock = genesis
|
lc.genesisBlock = genesis
|
||||||
lc.hc.SetGenesis(lc.genesisBlock.Header())
|
lc.hc.SetGenesis(lc.genesisBlock.Header())
|
||||||
|
lc.hc.SetCurrentHeader(lc.genesisBlock.Header())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
|
|
@ -329,7 +330,7 @@ func (lc *LightChain) Rollback(chain []common.Hash) {
|
||||||
for i := len(chain) - 1; i >= 0; i-- {
|
for i := len(chain) - 1; i >= 0; i-- {
|
||||||
hash := chain[i]
|
hash := chain[i]
|
||||||
|
|
||||||
// Degrade the chain markers if they are explictly reverted.
|
// Degrade the chain markers if they are explicitly reverted.
|
||||||
// In thoery we should update all in-memory markers in the
|
// In thoery we should update all in-memory markers in the
|
||||||
// last step, however the direction of rollback is from high
|
// last step, however the direction of rollback is from high
|
||||||
// to low, so it's safe the update in-memory markers directly.
|
// to low, so it's safe the update in-memory markers directly.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue