From a5320da5c88b783bbcdab11056124fd4f0aee8f5 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Mon, 14 Mar 2022 17:00:51 -0400 Subject: [PATCH] node: cleanup evidence db (#8119) --- node/node.go | 3 ++- node/setup.go | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/node/node.go b/node/node.go index 3329d9f9a..c2acfa7a8 100644 --- a/node/node.go +++ b/node/node.go @@ -274,9 +274,10 @@ func makeNode( return nil, combineCloseError(err, makeCloser(closers)) } - evReactor, evPool, err := createEvidenceReactor(ctx, + evReactor, evPool, edbCloser, err := createEvidenceReactor(ctx, cfg, dbProvider, stateStore, blockStore, peerManager, router, logger, nodeMetrics.evidence, eventBus, ) + closers = append(closers, edbCloser) if err != nil { return nil, combineCloseError(err, makeCloser(closers)) } diff --git a/node/setup.go b/node/setup.go index c3e229fbf..48ffcb073 100644 --- a/node/setup.go +++ b/node/setup.go @@ -220,11 +220,12 @@ func createEvidenceReactor( logger log.Logger, metrics *evidence.Metrics, eventBus *eventbus.EventBus, -) (*evidence.Reactor, *evidence.Pool, error) { +) (*evidence.Reactor, *evidence.Pool, closer, error) { evidenceDB, err := dbProvider(&config.DBContext{ID: "evidence", Config: cfg}) if err != nil { - return nil, nil, fmt.Errorf("unable to initialize evidence db: %w", err) + return nil, nil, func() error { return nil }, fmt.Errorf("unable to initialize evidence db: %w", err) } + dbCloser := evidenceDB.Close logger = logger.With("module", "evidence") @@ -238,10 +239,10 @@ func createEvidenceReactor( evidencePool, ) if err != nil { - return nil, nil, fmt.Errorf("creating evidence reactor: %w", err) + return nil, nil, dbCloser, fmt.Errorf("creating evidence reactor: %w", err) } - return evidenceReactor, evidencePool, nil + return evidenceReactor, evidencePool, dbCloser, nil } func createConsensusReactor(