From 3d2ae433ee305644bd6b4f4e13a8492cbe49a804 Mon Sep 17 00:00:00 2001 From: vyzo Date: Sun, 25 Jul 2021 11:14:48 +0300 Subject: [PATCH] add ChainCheckBlockstore API --- api/api_full.go | 4 ++++ node/impl/full/chain.go | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/api/api_full.go b/api/api_full.go index 5c72c3613..a4a5dd253 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -164,6 +164,10 @@ type FullNode interface { // If oldmsgskip is set, messages from before the requested roots are also not included. ChainExport(ctx context.Context, nroots abi.ChainEpoch, oldmsgskip bool, tsk types.TipSetKey) (<-chan []byte, error) //perm:read + // ChainCheckBlockstore performs an (asynchronous) health check on the chain/state blockstore + // if supported by the underlying implementation. + ChainCheckBlockstore(context.Context) error + // MethodGroup: Beacon // The Beacon method group contains methods for interacting with the random beacon (DRAND) diff --git a/node/impl/full/chain.go b/node/impl/full/chain.go index 33d14d3ba..579a82227 100644 --- a/node/impl/full/chain.go +++ b/node/impl/full/chain.go @@ -83,6 +83,9 @@ type ChainAPI struct { // expose externally. In the future, this will be segregated into two // blockstores. ExposedBlockstore dtypes.ExposedBlockstore + + // BaseBlockstore is the underyling blockstore + BaseBlockstore dtypes.BaseBlockstore } func (m *ChainModule) ChainNotify(ctx context.Context) (<-chan []*api.HeadChange, error) { @@ -644,3 +647,12 @@ func (a *ChainAPI) ChainExport(ctx context.Context, nroots abi.ChainEpoch, skipo return out, nil } + +func (a *ChainAPI) ChainCheckBlockstore(ctx context.Context) error { + checker, ok := a.BaseBlockstore.(interface{ Check() error }) + if !ok { + return xerrors.Errorf("underlying blockstore does not support health checks") + } + + return checker.Check() +}