diff --git a/pkg/trace/schema/consensus.go b/pkg/trace/schema/consensus.go index 726a53d262..28140e2264 100644 --- a/pkg/trace/schema/consensus.go +++ b/pkg/trace/schema/consensus.go @@ -4,6 +4,7 @@ import ( cstypes "github.com/tendermint/tendermint/consensus/types" "github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/pkg/trace" + "time" ) // ConsensusTables returns the list of tables that are used for consensus @@ -12,6 +13,7 @@ func ConsensusTables() []string { return []string{ RoundStateTable, BlockPartsTable, + BlockTable, } } @@ -81,3 +83,22 @@ func WriteBlockPart( TransferTypeFieldKey: transferType, }) } + +const ( + // BlockTable is the name of the table that stores metadata about consensus blocks. + // following schema: + // + // | time | height | + BlockTable = "consensus_block" + + // TimestampFieldKey is the name of the field that stores the time at which + // the block is proposed. + TimestampFieldKey = "timestamp" +) + +func WriteBlock(client *trace.Client, height int64, blockTimestamp time.Time) { + client.WritePoint(BlockTable, map[string]interface{}{ + HeightFieldKey: height, + TimestampFieldKey: blockTimestamp, + }) +}