From f528cfdf714e1256be0d7159bc6e0af3aca78612 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Sun, 27 Aug 2023 11:57:26 +0800 Subject: [PATCH] comments & formatting --- config.go | 6 +++--- indexer/constructor.go | 11 ++++++++++- main/main.go | 8 ++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/config.go b/config.go index ac16f74..960b44a 100644 --- a/config.go +++ b/config.go @@ -48,16 +48,16 @@ type Config struct { SubtrieWorkers uint // Should the statediff service wait until geth has synced to the head of the blockchain? WaitForSync bool - // Context used during DB initialization + // Context passed to all DB method calls Context context.Context } // Params contains config parameters for the state diff builder type Params struct { - IncludeBlock bool + IncludeBlock bool // TODO: not used in write-requests IncludeReceipts bool IncludeTD bool - IncludeCode bool + IncludeCode bool // TODO: not used by anything? WatchedAddresses []common.Address watchedAddressesLeafPaths [][]byte } diff --git a/indexer/constructor.go b/indexer/constructor.go index c44ab64..bb288fd 100644 --- a/indexer/constructor.go +++ b/indexer/constructor.go @@ -33,7 +33,16 @@ import ( ) // NewStateDiffIndexer creates and returns an implementation of the StateDiffIndexer interface. -func NewStateDiffIndexer(ctx context.Context, chainConfig *params.ChainConfig, nodeInfo node.Info, config interfaces.Config) (sql.Database, interfaces.StateDiffIndexer, error) { +func NewStateDiffIndexer( + ctx context.Context, + chainConfig *params.ChainConfig, + nodeInfo node.Info, + config interfaces.Config, +) ( + sql.Database, + interfaces.StateDiffIndexer, + error, +) { switch config.Type() { case shared.FILE: log.Info("Starting statediff service in SQL file writing mode") diff --git a/main/main.go b/main/main.go index 0ab262f..20f9aca 100644 --- a/main/main.go +++ b/main/main.go @@ -47,8 +47,12 @@ func InitializeNode(stack core.Node, b core.Backend) { ClientName: serviceConfig.ClientName, } var err error - _, indexer, err = ind.NewStateDiffIndexer(serviceConfig.Context, - adapt.ChainConfig(backend.ChainConfig()), info, serviceConfig.IndexerConfig) + _, indexer, err = ind.NewStateDiffIndexer( + serviceConfig.Context, + adapt.ChainConfig(backend.ChainConfig()), + info, + serviceConfig.IndexerConfig, + ) if err != nil { log.Error("failed to construct indexer", "error", err) }