Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add transaction count to chainsync Block event #113

Merged
merged 1 commit into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions input/chainsync/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ type BlockContext struct {
}

type BlockEvent struct {
BlockBodySize uint64 `json:"blockBodySize"`
IssuerVkey string `json:"issuerVkey"`
BlockHash string `json:"blockHash"`
BlockCbor byteSliceJsonHex `json:"blockCbor,omitempty"`
BlockBodySize uint64 `json:"blockBodySize"`
IssuerVkey string `json:"issuerVkey"`
BlockHash string `json:"blockHash"`
BlockCbor byteSliceJsonHex `json:"blockCbor,omitempty"`
TransactionCount uint64 `json:"transactionCount"`
}

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

func NewBlockEvent(block ledger.Block, includeCbor bool) BlockEvent {
evt := BlockEvent{
BlockBodySize: block.BlockBodySize(),
BlockHash: block.Hash(),
IssuerVkey: block.IssuerVkey().Hash().String(),
BlockBodySize: block.BlockBodySize(),
BlockHash: block.Hash(),
IssuerVkey: block.IssuerVkey().Hash().String(),
TransactionCount: uint64(len(block.Transactions())),
}
if includeCbor {
evt.BlockCbor = block.Cbor()
Expand Down
3 changes: 2 additions & 1 deletion output/notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ func (n *NotifyOutput) Start() error {
err := beeep.Notify(
n.title,
fmt.Sprintf(
"New Block!\nBlockNumber: %d, SlotNumber: %d\nHash: %s",
"New Block!\nBlockNumber: %d, SlotNumber: %d, TransactionCount: %d\nHash: %s",
bc.BlockNumber,
bc.SlotNumber,
be.TransactionCount,
be.BlockHash,
),
"assets/snek-icon.png",
Expand Down
Loading