diff --git a/node/config/engine.go b/node/config/engine.go index 7667b5d..707080f 100644 --- a/node/config/engine.go +++ b/node/config/engine.go @@ -1,5 +1,7 @@ package config +import "time" + type EngineConfig struct { ProvingKeyId string `yaml:"provingKeyId"` Filter string `yaml:"filter"` @@ -24,6 +26,8 @@ type EngineConfig struct { // Automatically merges coins after minting once a sufficient number has been // accrued AutoMergeCoins bool `yaml:"autoMergeCoins"` + // Maximum wait time for a frame to be downloaded from a peer. + SyncTimeout time.Duration `yaml:"syncTimeout"` // Values used only for testing – do not override these in production, your // node will get kicked out diff --git a/node/consensus/data/consensus_frames.go b/node/consensus/data/consensus_frames.go index 103cd02..82e4514 100644 --- a/node/consensus/data/consensus_frames.go +++ b/node/consensus/data/consensus_frames.go @@ -20,6 +20,8 @@ import ( "source.quilibrium.com/quilibrium/monorepo/node/protobufs" ) +const defaultSyncTimeout = 2 * time.Second + func (e *DataClockConsensusEngine) collect( enqueuedFrame *protobufs.ClockFrame, ) (*protobufs.ClockFrame, error) { @@ -310,8 +312,13 @@ func (e *DataClockConsensusEngine) sync( client := protobufs.NewDataServiceClient(cc) + syncTimeout := e.config.Engine.SyncTimeout + if syncTimeout == 0 { + syncTimeout = defaultSyncTimeout + } + for e.GetState() < consensus.EngineStateStopping { - ctx, cancel := context.WithTimeout(e.ctx, 2*time.Second) + ctx, cancel := context.WithTimeout(e.ctx, syncTimeout) response, err := client.GetDataFrame( ctx, &protobufs.GetDataFrameRequest{