File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ type BlockFetch struct {
8888
8989type Config struct {
9090 BlockFunc BlockFunc
91+ BatchDoneFunc BatchDoneFunc
9192 RequestRangeFunc RequestRangeFunc
9293 BatchStartTimeout time.Duration
9394 BlockTimeout time.Duration
@@ -102,6 +103,7 @@ type CallbackContext struct {
102103
103104// Callback function types
104105type BlockFunc func (CallbackContext , uint , ledger.Block ) error
106+ type BatchDoneFunc func (CallbackContext ) error
105107type RequestRangeFunc func (CallbackContext , common.Point , common.Point ) error
106108
107109func New (protoOptions protocol.ProtocolOptions , cfg * Config ) * BlockFetch {
@@ -132,6 +134,12 @@ func WithBlockFunc(blockFunc BlockFunc) BlockFetchOptionFunc {
132134 }
133135}
134136
137+ func WithBatchDoneFunc (batchDoneFunc BatchDoneFunc ) BlockFetchOptionFunc {
138+ return func (c * Config ) {
139+ c .BatchDoneFunc = batchDoneFunc
140+ }
141+ }
142+
135143func WithRequestRangeFunc (
136144 requestRangeFunc RequestRangeFunc ,
137145) BlockFetchOptionFunc {
Original file line number Diff line number Diff line change @@ -283,6 +283,12 @@ func (c *Client) handleBatchDone() error {
283283 "role" , "client" ,
284284 "connection_id" , c .callbackContext .ConnectionId .String (),
285285 )
286+ // Notify the user if requested
287+ if c .blockUseCallback && c .config .BatchDoneFunc != nil {
288+ if err := c .config .BatchDoneFunc (c .callbackContext ); err != nil {
289+ return err
290+ }
291+ }
286292 c .busyMutex .Unlock ()
287293 return nil
288294}
You can’t perform that action at this time.
0 commit comments