From fe846845af8f2da3d5b0b81fa5df41889b649c44 Mon Sep 17 00:00:00 2001 From: Nicolas Lara Date: Thu, 31 Aug 2023 16:30:07 +0200 Subject: [PATCH] making the timestamp available to the rms on commits --- baseapp/abci.go | 6 ++++++ store/rootmulti/store.go | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/baseapp/abci.go b/baseapp/abci.go index 702028694980..e99e8bb05a56 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -337,6 +337,12 @@ func (app *BaseApp) Commit() (res abci.ResponseCommit) { // The write to the DeliverTx state writes all state transitions to the root // MultiStore (app.cms) so when Commit() is called is persists those values. app.deliverState.ms.Write() + + rms, ok := app.cms.(*rootmulti.Store) + if ok { + rms.SetCommitHeader(header) + } + commitID := app.cms.Commit() // Reset the Check state to the latest committed. diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 86a80f2346c2..bf5e957edea7 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -2,6 +2,7 @@ package rootmulti import ( "fmt" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "io" "math" "sort" @@ -69,7 +70,8 @@ type Store struct { interBlockCache types.MultiStorePersistentCache - listeners map[types.StoreKey][]types.WriteListener + listeners map[types.StoreKey][]types.WriteListener + commitHeader tmproto.Header } var ( @@ -418,6 +420,7 @@ func (rs *Store) Commit() types.CommitID { } newCommitInfo := rs.commitStores(version, rs.stores) + newCommitInfo.Timestamp = rs.commitHeader.Time rs.updateLatestCommitInfo(newCommitInfo, version) err := rs.handlePruning(version) @@ -436,6 +439,11 @@ func (rs *Store) Commit() types.CommitID { } } +// SetCommitHeader sets the commit block header of the store. +func (rs *Store) SetCommitHeader(h tmproto.Header) { + rs.commitHeader = h +} + // CacheWrap implements CacheWrapper/Store/CommitStore. func (rs *Store) CacheWrap() types.CacheWrap { return rs.CacheMultiStore().(types.CacheWrap)