mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
core: stop insert and re-enable
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
e5d6f7d933
commit
bc3314aed9
2 changed files with 7 additions and 0 deletions
|
|
@ -1307,6 +1307,11 @@ func (bc *BlockChain) StopInsert() {
|
||||||
bc.procInterrupt.Store(true)
|
bc.procInterrupt.Store(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResumeInsert re-enables the blockchain insertion, which is used to rewinding the chain to
|
||||||
|
func (bc *BlockChain) ResumeInsert() {
|
||||||
|
bc.procInterrupt.Store(false)
|
||||||
|
}
|
||||||
|
|
||||||
// insertStopped returns true after StopInsert has been called.
|
// insertStopped returns true after StopInsert has been called.
|
||||||
func (bc *BlockChain) insertStopped() bool {
|
func (bc *BlockChain) insertStopped() bool {
|
||||||
return bc.procInterrupt.Load()
|
return bc.procInterrupt.Load()
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,10 @@ func (b *EthAPIBackend) CurrentBlock() *types.Header {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *EthAPIBackend) SetHead(number uint64) {
|
func (b *EthAPIBackend) SetHead(number uint64) {
|
||||||
|
b.eth.blockchain.StopInsert()
|
||||||
b.eth.handler.downloader.Cancel()
|
b.eth.handler.downloader.Cancel()
|
||||||
b.eth.blockchain.SetHead(number)
|
b.eth.blockchain.SetHead(number)
|
||||||
|
b.eth.blockchain.ResumeInsert()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *EthAPIBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) {
|
func (b *EthAPIBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue