core, eth: abort snapshot generation on snap sync and resume later
This commit is contained in:
@ -28,6 +28,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||
"github.com/ethereum/go-ethereum/core/state/snapshot"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/eth/protocols/eth"
|
||||
"github.com/ethereum/go-ethereum/eth/protocols/snap"
|
||||
@ -214,6 +215,9 @@ type BlockChain interface {
|
||||
|
||||
// InsertReceiptChain inserts a batch of receipts into the local chain.
|
||||
InsertReceiptChain(types.Blocks, []types.Receipts, uint64) (int, error)
|
||||
|
||||
// Snapshots returns the blockchain snapshot tree to paused it during sync.
|
||||
Snapshots() *snapshot.Tree
|
||||
}
|
||||
|
||||
// New creates a new downloader to fetch hashes and blocks from remote peers.
|
||||
@ -393,6 +397,12 @@ func (d *Downloader) synchronise(id string, hash common.Hash, td *big.Int, mode
|
||||
// but until snap becomes prevalent, we should support both. TODO(karalabe).
|
||||
if mode == SnapSync {
|
||||
if !d.snapSync {
|
||||
// Snap sync uses the snapshot namespace to store potentially flakey data until
|
||||
// sync completely heals and finishes. Pause snapshot maintenance in the mean
|
||||
// time to prevent access.
|
||||
if snapshots := d.blockchain.Snapshots(); snapshots != nil { // Only nil in tests
|
||||
snapshots.Disable()
|
||||
}
|
||||
log.Warn("Enabling snapshot sync prototype")
|
||||
d.snapSync = true
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||
"github.com/ethereum/go-ethereum/core/state/snapshot"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/eth/protocols/eth"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
@ -409,6 +410,11 @@ func (dl *downloadTester) dropPeer(id string) {
|
||||
dl.downloader.UnregisterPeer(id)
|
||||
}
|
||||
|
||||
// Snapshots implements the BlockChain interface for the downloader, but is a noop.
|
||||
func (dl *downloadTester) Snapshots() *snapshot.Tree {
|
||||
return nil
|
||||
}
|
||||
|
||||
type downloadTesterPeer struct {
|
||||
dl *downloadTester
|
||||
id string
|
||||
|
Reference in New Issue
Block a user