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 block type to blockfetch Block callback #684

Merged
merged 1 commit into from
Aug 16, 2024
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
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