mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
core: rename to BlockChainOptions
This commit is contained in:
parent
b84b9211b7
commit
38e88a113c
11 changed files with 20 additions and 20 deletions
|
|
@ -2164,7 +2164,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatalf("%v", err)
|
Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
options := &core.BlockchainOptions{
|
options := &core.BlockChainOptions{
|
||||||
TrieCleanLimit: ethconfig.Defaults.TrieCleanCache,
|
TrieCleanLimit: ethconfig.Defaults.TrieCleanCache,
|
||||||
NoPrefetch: ctx.Bool(CacheNoPrefetchFlag.Name),
|
NoPrefetch: ctx.Bool(CacheNoPrefetchFlag.Name),
|
||||||
TrieDirtyLimit: ethconfig.Defaults.TrieDirtyCache,
|
TrieDirtyLimit: ethconfig.Defaults.TrieDirtyCache,
|
||||||
|
|
|
||||||
|
|
@ -149,8 +149,8 @@ const (
|
||||||
BlockChainVersion uint64 = 9
|
BlockChainVersion uint64 = 9
|
||||||
)
|
)
|
||||||
|
|
||||||
// BlockchainOptions contains the configuration fields for setting up blockchain.
|
// BlockChainOptions contains the configuration fields for setting up blockchain.
|
||||||
type BlockchainOptions struct {
|
type BlockChainOptions struct {
|
||||||
// Trie database related options
|
// Trie database related options
|
||||||
TrieCleanLimit int // Memory allowance (MB) to use for caching trie nodes in memory
|
TrieCleanLimit int // Memory allowance (MB) to use for caching trie nodes in memory
|
||||||
TrieDirtyLimit int // Memory limit (MB) at which to start flushing dirty trie nodes to disk
|
TrieDirtyLimit int // Memory limit (MB) at which to start flushing dirty trie nodes to disk
|
||||||
|
|
@ -187,7 +187,7 @@ type BlockchainOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// triedbConfig derives the configures for trie database.
|
// triedbConfig derives the configures for trie database.
|
||||||
func (o *BlockchainOptions) triedbConfig(isVerkle bool) *triedb.Config {
|
func (o *BlockChainOptions) triedbConfig(isVerkle bool) *triedb.Config {
|
||||||
config := &triedb.Config{
|
config := &triedb.Config{
|
||||||
Preimages: o.Preimages,
|
Preimages: o.Preimages,
|
||||||
IsVerkle: isVerkle,
|
IsVerkle: isVerkle,
|
||||||
|
|
@ -214,7 +214,7 @@ func (o *BlockchainOptions) triedbConfig(isVerkle bool) *triedb.Config {
|
||||||
|
|
||||||
// defaultOptions are the default blockchain options if none are specified by the
|
// defaultOptions are the default blockchain options if none are specified by the
|
||||||
// user (also used during testing).
|
// user (also used during testing).
|
||||||
var defaultOptions = &BlockchainOptions{
|
var defaultOptions = &BlockChainOptions{
|
||||||
TrieCleanLimit: 256,
|
TrieCleanLimit: 256,
|
||||||
TrieDirtyLimit: 256,
|
TrieDirtyLimit: 256,
|
||||||
TrieTimeLimit: 5 * time.Minute,
|
TrieTimeLimit: 5 * time.Minute,
|
||||||
|
|
@ -226,7 +226,7 @@ var defaultOptions = &BlockchainOptions{
|
||||||
|
|
||||||
// BlockchainOptionsWithScheme returns a deep copied default chain config with
|
// BlockchainOptionsWithScheme returns a deep copied default chain config with
|
||||||
// a provided state scheme.
|
// a provided state scheme.
|
||||||
func BlockchainOptionsWithScheme(scheme string) *BlockchainOptions {
|
func BlockchainOptionsWithScheme(scheme string) *BlockChainOptions {
|
||||||
config := *defaultOptions
|
config := *defaultOptions
|
||||||
config.StateScheme = scheme
|
config.StateScheme = scheme
|
||||||
return &config
|
return &config
|
||||||
|
|
@ -255,7 +255,7 @@ type txLookup struct {
|
||||||
// canonical chain.
|
// canonical chain.
|
||||||
type BlockChain struct {
|
type BlockChain struct {
|
||||||
chainConfig *params.ChainConfig // Chain & network configuration
|
chainConfig *params.ChainConfig // Chain & network configuration
|
||||||
options *BlockchainOptions // Blockchain configuration
|
options *BlockChainOptions // Blockchain configuration
|
||||||
|
|
||||||
db ethdb.Database // Low level persistent database to store final content in
|
db ethdb.Database // Low level persistent database to store final content in
|
||||||
snaps *snapshot.Tree // Snapshot tree for fast trie leaf access
|
snaps *snapshot.Tree // Snapshot tree for fast trie leaf access
|
||||||
|
|
@ -311,7 +311,7 @@ type BlockChain struct {
|
||||||
// NewBlockChain returns a fully initialised block chain using information
|
// NewBlockChain returns a fully initialised block chain using information
|
||||||
// available in the database. It initialises the default Ethereum Validator
|
// available in the database. It initialises the default Ethereum Validator
|
||||||
// and Processor.
|
// and Processor.
|
||||||
func NewBlockChain(db ethdb.Database, genesis *Genesis, engine consensus.Engine, options *BlockchainOptions) (*BlockChain, error) {
|
func NewBlockChain(db ethdb.Database, genesis *Genesis, engine consensus.Engine, options *BlockChainOptions) (*BlockChain, error) {
|
||||||
if options == nil {
|
if options == nil {
|
||||||
options = defaultOptions
|
options = defaultOptions
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1781,7 +1781,7 @@ func testRepairWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme s
|
||||||
Config: params.AllEthashProtocolChanges,
|
Config: params.AllEthashProtocolChanges,
|
||||||
}
|
}
|
||||||
engine = ethash.NewFullFaker()
|
engine = ethash.NewFullFaker()
|
||||||
option = &BlockchainOptions{
|
option = &BlockChainOptions{
|
||||||
TrieCleanLimit: 256,
|
TrieCleanLimit: 256,
|
||||||
TrieDirtyLimit: 256,
|
TrieDirtyLimit: 256,
|
||||||
TrieTimeLimit: 5 * time.Minute,
|
TrieTimeLimit: 5 * time.Minute,
|
||||||
|
|
|
||||||
|
|
@ -1985,7 +1985,7 @@ func testSetHeadWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme
|
||||||
Config: params.AllEthashProtocolChanges,
|
Config: params.AllEthashProtocolChanges,
|
||||||
}
|
}
|
||||||
engine = ethash.NewFullFaker()
|
engine = ethash.NewFullFaker()
|
||||||
options = &BlockchainOptions{
|
options = &BlockChainOptions{
|
||||||
TrieCleanLimit: 256,
|
TrieCleanLimit: 256,
|
||||||
TrieDirtyLimit: 256,
|
TrieDirtyLimit: 256,
|
||||||
TrieTimeLimit: 5 * time.Minute,
|
TrieTimeLimit: 5 * time.Minute,
|
||||||
|
|
|
||||||
|
|
@ -310,7 +310,7 @@ func (snaptest *gappedSnapshotTest) test(t *testing.T) {
|
||||||
gappedBlocks, _ := GenerateChain(snaptest.gspec.Config, blocks[len(blocks)-1], snaptest.engine, snaptest.genDb, snaptest.gapped, func(i int, b *BlockGen) {})
|
gappedBlocks, _ := GenerateChain(snaptest.gspec.Config, blocks[len(blocks)-1], snaptest.engine, snaptest.genDb, snaptest.gapped, func(i int, b *BlockGen) {})
|
||||||
|
|
||||||
// Insert a few more blocks without enabling snapshot
|
// Insert a few more blocks without enabling snapshot
|
||||||
var options = &BlockchainOptions{
|
var options = &BlockChainOptions{
|
||||||
TrieCleanLimit: 256,
|
TrieCleanLimit: 256,
|
||||||
TrieDirtyLimit: 256,
|
TrieDirtyLimit: 256,
|
||||||
TrieTimeLimit: 5 * time.Minute,
|
TrieTimeLimit: 5 * time.Minute,
|
||||||
|
|
@ -383,7 +383,7 @@ func (snaptest *wipeCrashSnapshotTest) test(t *testing.T) {
|
||||||
// and state committed.
|
// and state committed.
|
||||||
chain.Stop()
|
chain.Stop()
|
||||||
|
|
||||||
config := &BlockchainOptions{
|
config := &BlockChainOptions{
|
||||||
TrieCleanLimit: 256,
|
TrieCleanLimit: 256,
|
||||||
TrieDirtyLimit: 256,
|
TrieDirtyLimit: 256,
|
||||||
TrieTimeLimit: 5 * time.Minute,
|
TrieTimeLimit: 5 * time.Minute,
|
||||||
|
|
@ -399,7 +399,7 @@ func (snaptest *wipeCrashSnapshotTest) test(t *testing.T) {
|
||||||
newchain.Stop()
|
newchain.Stop()
|
||||||
|
|
||||||
// Restart the chain, the wiper should start working
|
// Restart the chain, the wiper should start working
|
||||||
config = &BlockchainOptions{
|
config = &BlockChainOptions{
|
||||||
TrieCleanLimit: 256,
|
TrieCleanLimit: 256,
|
||||||
TrieDirtyLimit: 256,
|
TrieDirtyLimit: 256,
|
||||||
TrieTimeLimit: 5 * time.Minute,
|
TrieTimeLimit: 5 * time.Minute,
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ func newTestBlockChain(t *testing.T, n int, gspec *core.Genesis, generator func(
|
||||||
_, blocks, _ := core.GenerateChainWithGenesis(gspec, engine, n, generator)
|
_, blocks, _ := core.GenerateChainWithGenesis(gspec, engine, n, generator)
|
||||||
|
|
||||||
// Import the canonical chain
|
// Import the canonical chain
|
||||||
options := &core.BlockchainOptions{
|
options := &core.BlockChainOptions{
|
||||||
TrieCleanLimit: 256,
|
TrieCleanLimit: 256,
|
||||||
TrieDirtyLimit: 256,
|
TrieDirtyLimit: 256,
|
||||||
TrieTimeLimit: 5 * time.Minute,
|
TrieTimeLimit: 5 * time.Minute,
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
vmConfig = vm.Config{
|
vmConfig = vm.Config{
|
||||||
EnablePreimageRecording: config.EnablePreimageRecording,
|
EnablePreimageRecording: config.EnablePreimageRecording,
|
||||||
}
|
}
|
||||||
options = &core.BlockchainOptions{
|
options = &core.BlockChainOptions{
|
||||||
TrieCleanLimit: config.TrieCleanCache,
|
TrieCleanLimit: config.TrieCleanCache,
|
||||||
NoPrefetch: config.NoPrefetch,
|
NoPrefetch: config.NoPrefetch,
|
||||||
TrieDirtyLimit: config.TrieDirtyCache,
|
TrieDirtyLimit: config.TrieDirtyCache,
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ func getChain() *core.BlockChain {
|
||||||
Alloc: ga,
|
Alloc: ga,
|
||||||
}
|
}
|
||||||
_, blocks, _ := core.GenerateChainWithGenesis(gspec, ethash.NewFaker(), 2, func(i int, gen *core.BlockGen) {})
|
_, blocks, _ := core.GenerateChainWithGenesis(gspec, ethash.NewFaker(), 2, func(i int, gen *core.BlockGen) {})
|
||||||
options := &core.BlockchainOptions{
|
options := &core.BlockChainOptions{
|
||||||
TrieCleanLimit: 0,
|
TrieCleanLimit: 0,
|
||||||
TrieDirtyLimit: 0,
|
TrieDirtyLimit: 0,
|
||||||
TrieTimeLimit: 5 * time.Minute,
|
TrieTimeLimit: 5 * time.Minute,
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ func newTestBackend(t *testing.T, n int, gspec *core.Genesis, generator func(i i
|
||||||
_, blocks, _ := core.GenerateChainWithGenesis(gspec, backend.engine, n, generator)
|
_, blocks, _ := core.GenerateChainWithGenesis(gspec, backend.engine, n, generator)
|
||||||
|
|
||||||
// Import the canonical chain
|
// Import the canonical chain
|
||||||
options := &core.BlockchainOptions{
|
options := &core.BlockChainOptions{
|
||||||
TrieCleanLimit: 256,
|
TrieCleanLimit: 256,
|
||||||
TrieDirtyLimit: 256,
|
TrieDirtyLimit: 256,
|
||||||
TrieTimeLimit: 5 * time.Minute,
|
TrieTimeLimit: 5 * time.Minute,
|
||||||
|
|
@ -1144,7 +1144,7 @@ func newTestMergedBackend(t *testing.T, n int, gspec *core.Genesis, generator fu
|
||||||
_, blocks, _ := core.GenerateChainWithGenesis(gspec, backend.engine, n, generator)
|
_, blocks, _ := core.GenerateChainWithGenesis(gspec, backend.engine, n, generator)
|
||||||
|
|
||||||
// Import the canonical chain
|
// Import the canonical chain
|
||||||
options := &core.BlockchainOptions{
|
options := &core.BlockChainOptions{
|
||||||
TrieCleanLimit: 256,
|
TrieCleanLimit: 256,
|
||||||
TrieDirtyLimit: 256,
|
TrieDirtyLimit: 256,
|
||||||
TrieTimeLimit: 5 * time.Minute,
|
TrieTimeLimit: 5 * time.Minute,
|
||||||
|
|
|
||||||
|
|
@ -444,7 +444,7 @@ type testBackend struct {
|
||||||
func newTestBackend(t *testing.T, n int, gspec *core.Genesis, engine consensus.Engine, generator func(i int, b *core.BlockGen)) *testBackend {
|
func newTestBackend(t *testing.T, n int, gspec *core.Genesis, engine consensus.Engine, generator func(i int, b *core.BlockGen)) *testBackend {
|
||||||
var (
|
var (
|
||||||
txLookupLimit = uint64(0)
|
txLookupLimit = uint64(0)
|
||||||
options = &core.BlockchainOptions{
|
options = &core.BlockChainOptions{
|
||||||
TrieCleanLimit: 256,
|
TrieCleanLimit: 256,
|
||||||
TrieDirtyLimit: 256,
|
TrieDirtyLimit: 256,
|
||||||
TrieTimeLimit: 5 * time.Minute,
|
TrieTimeLimit: 5 * time.Minute,
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ func newTestWorkerBackend(t *testing.T, chainConfig *params.ChainConfig, engine
|
||||||
default:
|
default:
|
||||||
t.Fatalf("unexpected consensus engine type: %T", engine)
|
t.Fatalf("unexpected consensus engine type: %T", engine)
|
||||||
}
|
}
|
||||||
chain, err := core.NewBlockChain(db, gspec, engine, &core.BlockchainOptions{ArchiveMode: true})
|
chain, err := core.NewBlockChain(db, gspec, engine, &core.BlockChainOptions{ArchiveMode: true})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("core.NewBlockChain failed: %v", err)
|
t.Fatalf("core.NewBlockChain failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue