File tree Expand file tree Collapse file tree 5 files changed +22
-36
lines changed
pkg/chain/ethereum/ethutil
tools/generators/ethereum Expand file tree Collapse file tree 5 files changed +22
-36
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,22 @@ const (
1313 // pulled from the chain by the subscription monitoring mechanism if no
1414 // other value is provided in SubscribeOpts when creating the subscription.
1515 DefaultSubscribeOptsPastBlocks = 100
16+
17+ // SubscriptionBackoffMax is the maximum backoff time between event
18+ // resubscription attempts.
19+ SubscriptionBackoffMax = 2 * time .Minute
20+
21+ // SubscriptionAlertThreshold is time threshold below which event
22+ // resubscription emits an error to the logs.
23+ // WS connection can be dropped at any moment and event resubscription will
24+ // follow. However, if WS connection for event subscription is getting
25+ // dropped too often, it may indicate something is wrong with Ethereum
26+ // client. This constant defines the minimum lifetime of an event
27+ // subscription required before the subscription failure happens and
28+ // resubscription follows so that the resubscription does not emit an error
29+ // to the logs alerting about potential problems with Ethereum client
30+ // connection.
31+ SubscriptionAlertThreshold = 15 * time .Minute
1632)
1733
1834// SubscribeOpts specifies optional configuration options that can be passed
Original file line number Diff line number Diff line change @@ -26,21 +26,6 @@ import (
2626// included or excluded from logging at startup by name.
2727var {{.ShortVar }}Logger = log.Logger (" keep-contract-{{.Class}}" )
2828
29- const (
30- // Maximum backoff time between event resubscription attempts.
31- {{.ShortVar }}SubscriptionBackoffMax = 2 * time.Minute
32-
33- // Threshold below which event resubscription emits an error to the logs.
34- // WS connection can be dropped at any moment and event resubscription will
35- // follow. However, if WS connection for event subscription is getting
36- // dropped too often, it may indicate something is wrong with Ethereum
37- // client. This constant defines the minimum lifetime of an event
38- // subscription required before the subscription failure happens and
39- // resubscription follows so that the resubscription does not emit an error
40- // to the logs alerting about potential problems with Ethereum client.
41- {{.ShortVar }}SubscriptionAlertThreshold = 15 * time.Minute
42- )
43-
4429type {{.Class }} struct {
4530 contract *abi. {{.AbiClass }}
4631 contractAddress common.Address
Original file line number Diff line number Diff line change @@ -150,10 +150,10 @@ func ({{$contract.ShortVar}} *{{$contract.Class}}) watch{{$event.CapsName}}(
150150 )
151151 }
152152
153- sub := ethutil.WithResubscription (
154- {{ $contract .ShortVar }} SubscriptionBackoffMax,
153+ return ethutil.WithResubscription (
154+ ethutil . SubscriptionBackoffMax ,
155155 subscribeFn,
156- {{ $contract .ShortVar }} SubscriptionAlertThreshold,
156+ ethutil . SubscriptionAlertThreshold ,
157157 thresholdViolatedFn,
158158 subscriptionFailedFn,
159159 )
Original file line number Diff line number Diff line change @@ -153,10 +153,10 @@ func ({{$contract.ShortVar}} *{{$contract.Class}}) watch{{$event.CapsName}}(
153153 )
154154 }
155155
156- sub := ethutil.WithResubscription(
157- {{$contract.ShortVar}} SubscriptionBackoffMax,
156+ return ethutil.WithResubscription(
157+ ethutil. SubscriptionBackoffMax,
158158 subscribeFn,
159- {{$contract.ShortVar}} SubscriptionAlertThreshold,
159+ ethutil. SubscriptionAlertThreshold,
160160 thresholdViolatedFn,
161161 subscriptionFailedFn,
162162 )
Original file line number Diff line number Diff line change @@ -29,21 +29,6 @@ import (
2929// included or excluded from logging at startup by name.
3030var {{.ShortVar}}Logger = log.Logger("keep-contract-{{.Class}}")
3131
32- const (
33- // Maximum backoff time between event resubscription attempts.
34- {{.ShortVar}}SubscriptionBackoffMax = 2 * time.Minute
35-
36- // Threshold below which event resubscription emits an error to the logs.
37- // WS connection can be dropped at any moment and event resubscription will
38- // follow. However, if WS connection for event subscription is getting
39- // dropped too often, it may indicate something is wrong with Ethereum
40- // client. This constant defines the minimum lifetime of an event
41- // subscription required before the subscription failure happens and
42- // resubscription follows so that the resubscription does not emit an error
43- // to the logs alerting about potential problems with Ethereum client.
44- {{.ShortVar}}SubscriptionAlertThreshold = 15 * time.Minute
45- )
46-
4732type {{.Class}} struct {
4833 contract *abi.{{.AbiClass}}
4934 contractAddress common.Address
You can’t perform that action at this time.
0 commit comments