feat: add header and comet info service (#15850)
Co-authored-by: Aaron Craelius <aaron@regen.network>
This commit is contained in:
+26
-4
@@ -11,6 +11,9 @@ import (
|
||||
|
||||
"cosmossdk.io/store/gaskv"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
"cosmossdk.io/core/comet"
|
||||
"cosmossdk.io/core/header"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -22,10 +25,13 @@ but please do not over-use it. We try to keep all data structured
|
||||
and standard additions here would be better just to add to the Context struct
|
||||
*/
|
||||
type Context struct {
|
||||
baseCtx context.Context
|
||||
ms storetypes.MultiStore
|
||||
header cmtproto.Header
|
||||
headerHash []byte
|
||||
baseCtx context.Context
|
||||
ms storetypes.MultiStore
|
||||
// Deprecated: Use HeaderService for height, time, and chainID and CometService for the rest
|
||||
header cmtproto.Header
|
||||
// Deprecated: Use HeaderService for hash
|
||||
headerHash []byte
|
||||
// Deprecated: Use HeaderService for chainID and CometService for the rest
|
||||
chainID string
|
||||
txBytes []byte
|
||||
logger log.Logger
|
||||
@@ -41,6 +47,8 @@ type Context struct {
|
||||
kvGasConfig storetypes.GasConfig
|
||||
transientKVGasConfig storetypes.GasConfig
|
||||
streamingManager storetypes.StreamingManager
|
||||
cometInfo comet.BlockInfo
|
||||
headerInfo header.Info
|
||||
}
|
||||
|
||||
// Proposed rename, not done to avoid API breakage
|
||||
@@ -65,6 +73,8 @@ func (c Context) Priority() int64 { return c.prior
|
||||
func (c Context) KVGasConfig() storetypes.GasConfig { return c.kvGasConfig }
|
||||
func (c Context) TransientKVGasConfig() storetypes.GasConfig { return c.transientKVGasConfig }
|
||||
func (c Context) StreamingManager() storetypes.StreamingManager { return c.streamingManager }
|
||||
func (c Context) CometInfo() comet.BlockInfo { return c.cometInfo }
|
||||
func (c Context) HeaderInfo() header.Info { return c.headerInfo }
|
||||
|
||||
// clone the header before returning
|
||||
func (c Context) BlockHeader() cmtproto.Header {
|
||||
@@ -262,6 +272,18 @@ func (c Context) WithStreamingManager(sm storetypes.StreamingManager) Context {
|
||||
return c
|
||||
}
|
||||
|
||||
// WithCometInfo returns a Context with an updated comet info
|
||||
func (c Context) WithCometInfo(cometInfo comet.BlockInfo) Context {
|
||||
c.cometInfo = cometInfo
|
||||
return c
|
||||
}
|
||||
|
||||
// WithHeaderInfo returns a Context with an updated header info
|
||||
func (c Context) WithHeaderInfo(headerInfo header.Info) Context {
|
||||
c.headerInfo = headerInfo
|
||||
return c
|
||||
}
|
||||
|
||||
// TODO: remove???
|
||||
func (c Context) IsZero() bool {
|
||||
return c.ms == nil
|
||||
|
||||
Reference in New Issue
Block a user