Skip to content

Commit 6f38096

Browse files
authored
feat: add block type to blockfetch Block callback (#684)
1 parent 996c877 commit 6f38096

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

cmd/gouroboros/chainsync.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ func chainSyncRollForwardHandler(
324324

325325
func blockFetchBlockHandler(
326326
ctx blockfetch.CallbackContext,
327+
blockType uint,
327328
blockData ledger.Block,
328329
) error {
329330
switch block := blockData.(type) {

protocol/blockfetch/blockfetch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ type CallbackContext struct {
101101
}
102102

103103
// Callback function types
104-
type BlockFunc func(CallbackContext, ledger.Block) error
104+
type BlockFunc func(CallbackContext, uint, ledger.Block) error
105105
type RequestRangeFunc func(CallbackContext, common.Point, common.Point) error
106106

107107
func New(protoOptions protocol.ProtocolOptions, cfg *Config) *BlockFetch {

protocol/blockfetch/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func (c *Client) handleBlock(msgGeneric protocol.Message) error {
191191
}
192192
// We use the callback when requesting ranges and the internal channel for a single block
193193
if c.blockUseCallback {
194-
if err := c.config.BlockFunc(c.callbackContext, blk); err != nil {
194+
if err := c.config.BlockFunc(c.callbackContext, wrappedBlock.Type, blk); err != nil {
195195
return err
196196
}
197197
} else {

0 commit comments

Comments
 (0)