add flag for subtrie workers

This commit is contained in:
Roy Crihfield 2023-09-20 18:07:47 +08:00
parent d1be30346e
commit 44c60ac9e3
3 changed files with 10 additions and 2 deletions

View File

@ -44,6 +44,8 @@ type Config struct {
BackfillCheckPastBlocks uint64
// Size of the worker pool
NumWorkers uint
// Number of subtries to iterate in parallel
SubtrieWorkers uint
// Should the statediff service wait until geth has synced to the head of the blockchain?
WaitForSync bool
// Context used during DB initialization

View File

@ -46,7 +46,11 @@ func init() {
)
Flags.UintVar(&config.NumWorkers,
"statediff.workers", 1,
"Number of concurrent workers to use during statediff processing (default 1)",
"Number of concurrent workers to dispatch to during statediff processing",
)
Flags.UintVar(&config.SubtrieWorkers,
"statediff.subtries", 1,
"Number of subtries to iterate in parallel",
)
Flags.BoolVar(&config.WaitForSync,
"statediff.waitforsync", false,

View File

@ -166,10 +166,12 @@ func NewService(cfg Config, blockChain BlockChain, backend plugeth.Backend, inde
workers = 1
}
builder := NewBuilder(blockChain.StateCache())
builder.SetSubtrieWorkers(cfg.SubtrieWorkers)
quitCh := make(chan bool)
sds := &Service{
BlockChain: blockChain,
Builder: NewBuilder(blockChain.StateCache()),
Builder: builder,
QuitChan: quitCh,
Subscriptions: make(map[common.Hash]map[SubID]Subscription),
SubscriptionTypes: make(map[common.Hash]Params),