Skip to content

Commit

Permalink
introduces block table schema
Browse files Browse the repository at this point in the history
  • Loading branch information
staheri14 committed Aug 16, 2023
1 parent 9109b54 commit f1eced2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/trace/schema/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -12,6 +13,7 @@ func ConsensusTables() []string {
return []string{
RoundStateTable,
BlockPartsTable,
BlockTable,
}
}

Expand Down Expand Up @@ -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,
})
}

0 comments on commit f1eced2

Please sign in to comment.