Skip to content

Commit 7cb7131

Browse files
authored
Merge pull request #113 from blinklabs-io/feat-transaction-count
feat: add transaction count to chainsync Block event
2 parents 5779c24 + c0ebe4e commit 7cb7131

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

input/chainsync/block.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ type BlockContext struct {
2525
}
2626

2727
type BlockEvent struct {
28-
BlockBodySize uint64 `json:"blockBodySize"`
29-
IssuerVkey string `json:"issuerVkey"`
30-
BlockHash string `json:"blockHash"`
31-
BlockCbor byteSliceJsonHex `json:"blockCbor,omitempty"`
28+
BlockBodySize uint64 `json:"blockBodySize"`
29+
IssuerVkey string `json:"issuerVkey"`
30+
BlockHash string `json:"blockHash"`
31+
BlockCbor byteSliceJsonHex `json:"blockCbor,omitempty"`
32+
TransactionCount uint64 `json:"transactionCount"`
3233
}
3334

3435
func NewBlockContext(block ledger.Block, networkMagic uint32) BlockContext {
@@ -50,9 +51,10 @@ func NewBlockHeaderContext(block ledger.BlockHeader) BlockContext {
5051

5152
func NewBlockEvent(block ledger.Block, includeCbor bool) BlockEvent {
5253
evt := BlockEvent{
53-
BlockBodySize: block.BlockBodySize(),
54-
BlockHash: block.Hash(),
55-
IssuerVkey: block.IssuerVkey().Hash().String(),
54+
BlockBodySize: block.BlockBodySize(),
55+
BlockHash: block.Hash(),
56+
IssuerVkey: block.IssuerVkey().Hash().String(),
57+
TransactionCount: uint64(len(block.Transactions())),
5658
}
5759
if includeCbor {
5860
evt.BlockCbor = block.Cbor()

output/notify/notify.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ func (n *NotifyOutput) Start() error {
6565
err := beeep.Notify(
6666
n.title,
6767
fmt.Sprintf(
68-
"New Block!\nBlockNumber: %d, SlotNumber: %d\nHash: %s",
68+
"New Block!\nBlockNumber: %d, SlotNumber: %d, TransactionCount: %d\nHash: %s",
6969
bc.BlockNumber,
7070
bc.SlotNumber,
71+
be.TransactionCount,
7172
be.BlockHash,
7273
),
7374
"assets/snek-icon.png",

0 commit comments

Comments
 (0)