Skip to content

Commit

Permalink
Report system chunk transactions within a block
Browse files Browse the repository at this point in the history
  • Loading branch information
m-Peter committed Jun 19, 2023
1 parent 6c48d41 commit f6d6e43
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions internal/blocks/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,31 @@ func get(
}

collections := make([]*flowsdk.Collection, 0)
collectionTxs := 0
if command.ContainsFlag(blockFlags.Include, "transactions") {
var lastCollection *flowsdk.Collection
for _, guarantee := range block.CollectionGuarantees {
collection, err := flow.GetCollection(context.Background(), guarantee.CollectionID)
if err != nil {
return nil, err
}
collections = append(collections, collection)
collectionTxs += len(collection.TransactionIDs)
lastCollection = collection
}

transactions, _, err := flow.GetTransactionsByBlockID(context.Background(), block.ID)
if err != nil {
return nil, err
}
// The last transaction returned from `flow.GetTransactionsByBlockID`,
// is the system chunk transaction. We add it as the last transaction
// in the last collection.
if lastCollection != nil && len(transactions) == (collectionTxs+1) {
lastCollection.TransactionIDs = append(
lastCollection.TransactionIDs,
transactions[collectionTxs].ID(),
)
}
}

Expand Down

0 comments on commit f6d6e43

Please sign in to comment.