Skip to content

Commit

Permalink
making the timestamp available to the rms on commits
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslara committed Aug 31, 2023
1 parent ed4eb88 commit e4d613a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,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.
Expand Down
10 changes: 9 additions & 1 deletion store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package rootmulti

import (
"fmt"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"io"
"math"
"sort"
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit e4d613a

Please sign in to comment.