44 "time"
55
66 "github.com/smartcontractkit/chainlink-common/pkg/config"
7-
8- "github.com/smartcontractkit/chainlink-framework/multinode"
97)
108
119// MultiNodeConfig is a wrapper to provide required functions while keeping configs Public
@@ -24,6 +22,7 @@ type MultiNode struct {
2422 SyncThreshold * uint32
2523 NodeIsSyncingEnabled * bool
2624 LeaseDuration * config.Duration
25+ NewHeadsPollInterval * config.Duration
2726 FinalizedBlockPollInterval * config.Duration
2827 EnforceRepeatableRead * bool
2928 DeathDeclarationDelay * config.Duration
@@ -62,6 +61,10 @@ func (c *MultiNodeConfig) NodeIsSyncingEnabled() bool {
6261
6362func (c * MultiNodeConfig ) LeaseDuration () time.Duration { return c .MultiNode .LeaseDuration .Duration () }
6463
64+ func (c * MultiNodeConfig ) NewHeadsPollInterval () time.Duration {
65+ return c .MultiNode .NewHeadsPollInterval .Duration ()
66+ }
67+
6568func (c * MultiNodeConfig ) FinalizedBlockPollInterval () time.Duration {
6669 return c .MultiNode .FinalizedBlockPollInterval .Duration ()
6770}
@@ -86,73 +89,6 @@ func (c *MultiNodeConfig) FinalityTagEnabled() bool { return *c.MultiNode.Finali
8689
8790func (c * MultiNodeConfig ) FinalizedBlockOffset () uint32 { return * c .MultiNode .FinalizedBlockOffset }
8891
89- func (c * MultiNodeConfig ) SetDefaults () {
90- // MultiNode is disabled as it's not fully implemented yet: BCFR-122
91- if c .MultiNode .Enabled == nil {
92- c .MultiNode .Enabled = ptr (false )
93- }
94-
95- /* Node Configs */
96- // Failure threshold for polling set to 5 to tolerate some polling failures before taking action.
97- if c .MultiNode .PollFailureThreshold == nil {
98- c .MultiNode .PollFailureThreshold = ptr (uint32 (5 ))
99- }
100- // Poll interval is set to 15 seconds to ensure timely updates while minimizing resource usage.
101- if c .MultiNode .PollInterval == nil {
102- c .MultiNode .PollInterval = config .MustNewDuration (15 * time .Second )
103- }
104- // Selection mode defaults to priority level to enable using node priorities
105- if c .MultiNode .SelectionMode == nil {
106- c .MultiNode .SelectionMode = ptr (multinode .NodeSelectionModePriorityLevel )
107- }
108- // The sync threshold is set to 10 to allow for some flexibility in node synchronization before considering it out of sync.
109- if c .MultiNode .SyncThreshold == nil {
110- c .MultiNode .SyncThreshold = ptr (uint32 (10 ))
111- }
112- // Lease duration is set to 1 minute by default to allow node locks for a reasonable amount of time.
113- if c .MultiNode .LeaseDuration == nil {
114- c .MultiNode .LeaseDuration = config .MustNewDuration (time .Minute )
115- }
116- // Node syncing is not relevant for Solana and is disabled by default.
117- if c .MultiNode .NodeIsSyncingEnabled == nil {
118- c .MultiNode .NodeIsSyncingEnabled = ptr (false )
119- }
120- // The finalized block polling interval is set to 5 seconds to ensure timely updates while minimizing resource usage.
121- if c .MultiNode .FinalizedBlockPollInterval == nil {
122- c .MultiNode .FinalizedBlockPollInterval = config .MustNewDuration (5 * time .Second )
123- }
124- // Repeatable read guarantee should be enforced by default.
125- if c .MultiNode .EnforceRepeatableRead == nil {
126- c .MultiNode .EnforceRepeatableRead = ptr (true )
127- }
128- // The delay before declaring a node dead is set to 20 seconds to give nodes time to recover from temporary issues.
129- if c .MultiNode .DeathDeclarationDelay == nil {
130- c .MultiNode .DeathDeclarationDelay = config .MustNewDuration (20 * time .Second )
131- }
132-
133- /* Chain Configs */
134- // Threshold for no new heads is set to 20 seconds, assuming that heads should update at a reasonable pace.
135- if c .MultiNode .NodeNoNewHeadsThreshold == nil {
136- c .MultiNode .NodeNoNewHeadsThreshold = config .MustNewDuration (20 * time .Second )
137- }
138- // Similar to heads, finalized heads should be updated within 20 seconds.
139- if c .MultiNode .NoNewFinalizedHeadsThreshold == nil {
140- c .MultiNode .NoNewFinalizedHeadsThreshold = config .MustNewDuration (20 * time .Second )
141- }
142- // Finality tags are used in Solana and enabled by default.
143- if c .MultiNode .FinalityTagEnabled == nil {
144- c .MultiNode .FinalityTagEnabled = ptr (true )
145- }
146- // Finality depth will not be used since finality tags are enabled.
147- if c .MultiNode .FinalityDepth == nil {
148- c .MultiNode .FinalityDepth = ptr (uint32 (0 ))
149- }
150- // Finalized block offset allows for RPCs to be slightly behind the finalized block.
151- if c .MultiNode .FinalizedBlockOffset == nil {
152- c .MultiNode .FinalizedBlockOffset = ptr (uint32 (50 ))
153- }
154- }
155-
15692func (c * MultiNodeConfig ) SetFrom (f * MultiNodeConfig ) {
15793 if f .MultiNode .Enabled != nil {
15894 c .MultiNode .Enabled = f .MultiNode .Enabled
@@ -177,6 +113,9 @@ func (c *MultiNodeConfig) SetFrom(f *MultiNodeConfig) {
177113 if f .MultiNode .LeaseDuration != nil {
178114 c .MultiNode .LeaseDuration = f .MultiNode .LeaseDuration
179115 }
116+ if f .MultiNode .NewHeadsPollInterval != nil {
117+ c .MultiNode .NewHeadsPollInterval = f .MultiNode .NewHeadsPollInterval
118+ }
180119 if f .MultiNode .FinalizedBlockPollInterval != nil {
181120 c .MultiNode .FinalizedBlockPollInterval = f .MultiNode .FinalizedBlockPollInterval
182121 }
@@ -204,7 +143,3 @@ func (c *MultiNodeConfig) SetFrom(f *MultiNodeConfig) {
204143 c .MultiNode .FinalizedBlockOffset = f .MultiNode .FinalizedBlockOffset
205144 }
206145}
207-
208- func ptr [T any ](t T ) * T {
209- return & t
210- }
0 commit comments