11package chainsync
22
33import (
4+ "time"
5+
46 "github.com/cloudstruct/go-ouroboros-network/protocol"
57 "github.com/cloudstruct/go-ouroboros-network/protocol/common"
68)
@@ -93,6 +95,8 @@ type ChainSync struct {
9395type Config struct {
9496 RollBackwardFunc RollBackwardFunc
9597 RollForwardFunc RollForwardFunc
98+ IntersectTimeout time.Duration
99+ BlockTimeout time.Duration
96100}
97101
98102// Callback function types
@@ -110,7 +114,14 @@ func New(protoOptions protocol.ProtocolOptions, cfg *Config) *ChainSync {
110114type ChainSyncOptionFunc func (* Config )
111115
112116func NewConfig (options ... ChainSyncOptionFunc ) Config {
113- c := Config {}
117+ c := Config {
118+ IntersectTimeout : 5 * time .Second ,
119+ // We should really use something more useful like 30-60s, but we've seen 55s between blocks
120+ // in the preview network
121+ // https://preview.cexplorer.io/block/cb08a386363a946d2606e912fcd81ffed2bf326cdbc4058297b14471af4f67e9
122+ // https://preview.cexplorer.io/block/86806dca4ba735b233cbeee6da713bdece36fd41fb5c568f9ef5a3f5cbf572a3
123+ BlockTimeout : 180 * time .Second ,
124+ }
114125 // Apply provided options functions
115126 for _ , option := range options {
116127 option (& c )
@@ -129,3 +140,15 @@ func WithRollForwardFunc(rollForwardFunc RollForwardFunc) ChainSyncOptionFunc {
129140 c .RollForwardFunc = rollForwardFunc
130141 }
131142}
143+
144+ func WithIntersectTimeout (timeout time.Duration ) ChainSyncOptionFunc {
145+ return func (c * Config ) {
146+ c .IntersectTimeout = timeout
147+ }
148+ }
149+
150+ func WithBlockTimeout (timeout time.Duration ) ChainSyncOptionFunc {
151+ return func (c * Config ) {
152+ c .BlockTimeout = timeout
153+ }
154+ }
0 commit comments