Skip to content

Commit

Permalink
feat: add block type to blockfetch Block callback (#684)
Browse files Browse the repository at this point in the history
  • Loading branch information
agaffney authored Aug 16, 2024
1 parent 996c877 commit 6f38096
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/gouroboros/chainsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ func chainSyncRollForwardHandler(

func blockFetchBlockHandler(
ctx blockfetch.CallbackContext,
blockType uint,
blockData ledger.Block,
) error {
switch block := blockData.(type) {
Expand Down
2 changes: 1 addition & 1 deletion protocol/blockfetch/blockfetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ type CallbackContext struct {
}

// Callback function types
type BlockFunc func(CallbackContext, ledger.Block) error
type BlockFunc func(CallbackContext, uint, ledger.Block) error
type RequestRangeFunc func(CallbackContext, common.Point, common.Point) error

func New(protoOptions protocol.ProtocolOptions, cfg *Config) *BlockFetch {
Expand Down
2 changes: 1 addition & 1 deletion protocol/blockfetch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (c *Client) handleBlock(msgGeneric protocol.Message) error {
}
// We use the callback when requesting ranges and the internal channel for a single block
if c.blockUseCallback {
if err := c.config.BlockFunc(c.callbackContext, blk); err != nil {
if err := c.config.BlockFunc(c.callbackContext, wrappedBlock.Type, blk); err != nil {
return err
}
} else {
Expand Down

0 comments on commit 6f38096

Please sign in to comment.