11package blockfetch
22
33import (
4+ "time"
5+
46 "github.com/cloudstruct/go-ouroboros-network/protocol"
57)
68
@@ -67,10 +69,12 @@ type BlockFetch struct {
6769}
6870
6971type Config struct {
70- StartBatchFunc StartBatchFunc
71- NoBlocksFunc NoBlocksFunc
72- BlockFunc BlockFunc
73- BatchDoneFunc BatchDoneFunc
72+ StartBatchFunc StartBatchFunc
73+ NoBlocksFunc NoBlocksFunc
74+ BlockFunc BlockFunc
75+ BatchDoneFunc BatchDoneFunc
76+ BatchStartTimeout time.Duration
77+ BlockTimeout time.Duration
7478}
7579
7680// Callback function types
@@ -90,7 +94,10 @@ func New(protoOptions protocol.ProtocolOptions, cfg *Config) *BlockFetch {
9094type BlockFetchOptionFunc func (* Config )
9195
9296func NewConfig (options ... BlockFetchOptionFunc ) Config {
93- c := Config {}
97+ c := Config {
98+ BatchStartTimeout : 5 * time .Second ,
99+ BlockTimeout : 5 * time .Second ,
100+ }
94101 // Apply provided options functions
95102 for _ , option := range options {
96103 option (& c )
@@ -121,3 +128,15 @@ func WithBatchDoneFunc(BatchDoneFunc BatchDoneFunc) BlockFetchOptionFunc {
121128 c .BatchDoneFunc = BatchDoneFunc
122129 }
123130}
131+
132+ func WithBatchStartTimeout (timeout time.Duration ) BlockFetchOptionFunc {
133+ return func (c * Config ) {
134+ c .BatchStartTimeout = timeout
135+ }
136+ }
137+
138+ func WithBlockTimeout (timeout time.Duration ) BlockFetchOptionFunc {
139+ return func (c * Config ) {
140+ c .BlockTimeout = timeout
141+ }
142+ }
0 commit comments