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 {
88
88
89
89
type Config struct {
90
90
BlockFunc BlockFunc
91
+ BatchDoneFunc BatchDoneFunc
91
92
RequestRangeFunc RequestRangeFunc
92
93
BatchStartTimeout time.Duration
93
94
BlockTimeout time.Duration
@@ -102,6 +103,7 @@ type CallbackContext struct {
102
103
103
104
// Callback function types
104
105
type BlockFunc func (CallbackContext , uint , ledger.Block ) error
106
+ type BatchDoneFunc func (CallbackContext ) error
105
107
type RequestRangeFunc func (CallbackContext , common.Point , common.Point ) error
106
108
107
109
func New (protoOptions protocol.ProtocolOptions , cfg * Config ) * BlockFetch {
@@ -132,6 +134,12 @@ func WithBlockFunc(blockFunc BlockFunc) BlockFetchOptionFunc {
132
134
}
133
135
}
134
136
137
+ func WithBatchDoneFunc (batchDoneFunc BatchDoneFunc ) BlockFetchOptionFunc {
138
+ return func (c * Config ) {
139
+ c .BatchDoneFunc = batchDoneFunc
140
+ }
141
+ }
142
+
135
143
func WithRequestRangeFunc (
136
144
requestRangeFunc RequestRangeFunc ,
137
145
) BlockFetchOptionFunc {
Original file line number Diff line number Diff line change @@ -283,6 +283,12 @@ func (c *Client) handleBatchDone() error {
283
283
"role" , "client" ,
284
284
"connection_id" , c .callbackContext .ConnectionId .String (),
285
285
)
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
+ }
286
292
c .busyMutex .Unlock ()
287
293
return nil
288
294
}
You can’t perform that action at this time.
0 commit comments