Skip to content

Commit

Permalink
Add IsTransactionBlock helper (#180)
Browse files Browse the repository at this point in the history
* Add IsTransactionBlock helper

* Fmt
  • Loading branch information
cmmarslender authored Nov 23, 2024
1 parent 86ba0cb commit 7784312
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/config/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestChiaConfig_SetFieldByPath_Lists(t *testing.T) {
// First reset
defaultConfig.Seeder.StaticPeers = []string{}
assert.Equal(t, []string{}, defaultConfig.Seeder.StaticPeers)
err = defaultConfig.SetFieldByPath([]string{"seeder", "static_peers"}, []string{"node-test.chia.net","node-test-2.chia.net"})
err = defaultConfig.SetFieldByPath([]string{"seeder", "static_peers"}, []string{"node-test.chia.net", "node-test-2.chia.net"})
assert.NoError(t, err)
assert.Equal(t, []string{"node-test.chia.net", "node-test-2.chia.net"}, defaultConfig.Seeder.StaticPeers)

Expand All @@ -126,8 +126,8 @@ func TestChiaConfig_SetFieldByPath_Lists(t *testing.T) {
defaultConfig.FullNode.FullNodePeers = []config.Peer{}
assert.Equal(t, []config.Peer{}, defaultConfig.FullNode.FullNodePeers)
err = defaultConfig.SetFieldByPath([]string{"full_node", "full_node_peers"}, []config.Peer{
{Host: "testnode.example.com",Port:1234},
{Host:"testnode2.example.com",Port:5678},
{Host: "testnode.example.com", Port: 1234},
{Host: "testnode2.example.com", Port: 5678},
})
assert.NoError(t, err)
assert.Equal(t, []config.Peer{
Expand Down
8 changes: 8 additions & 0 deletions pkg/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ type BlockRecord struct {
SubEpochSummaryIncluded mo.Option[SubEpochSummary] `json:"sub_epoch_summary_included"`
}

// IsTransactionBlock returns true if the block is considered a transaction block
// Only transaction blocks have timestamps
// Also matches how chia determines what is a transaction block
// https://github.com/Chia-Network/chia-blockchain/blob/dfaf70895a0923d5ac60774dd1d64a200f445e6a/chia/consensus/block_record.py#L31
func (b *BlockRecord) IsTransactionBlock() bool {
return b.Timestamp.IsPresent()
}

// FullBlock a full block
// https://github.com/Chia-Network/chia_rs/blob/main/crates/chia-protocol/src/fullblock.rs#L13
type FullBlock struct {
Expand Down

0 comments on commit 7784312

Please sign in to comment.