@gearbox-protocol/sdk 9.13.1 → 9.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -114,7 +114,7 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
114
114
|
for (const [key, group] of Object.entries(groupedFeeds)) {
|
|
115
115
|
const [dataServiceId, signersStr] = key.split(":");
|
|
116
116
|
const uniqueSignersCount = parseInt(signersStr, 10);
|
|
117
|
-
const payloads = await this.#
|
|
117
|
+
const payloads = await this.#safeGetPayloads(
|
|
118
118
|
dataServiceId,
|
|
119
119
|
group,
|
|
120
120
|
uniqueSignersCount
|
|
@@ -154,6 +154,41 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
154
154
|
);
|
|
155
155
|
return results;
|
|
156
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Gets payloads, retries once if it has expired while inflight
|
|
159
|
+
* @param dataServiceId
|
|
160
|
+
* @param dataFeedsIds
|
|
161
|
+
* @param uniqueSignersCount
|
|
162
|
+
* @returns
|
|
163
|
+
*/
|
|
164
|
+
async #safeGetPayloads(dataServiceId, dataFeedsIds, uniqueSignersCount) {
|
|
165
|
+
let result = await this.#getPayloads(
|
|
166
|
+
dataServiceId,
|
|
167
|
+
dataFeedsIds,
|
|
168
|
+
uniqueSignersCount
|
|
169
|
+
);
|
|
170
|
+
if (this.#historicalTimestampMs) {
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
let expired = false;
|
|
174
|
+
for (const { timestamp, dataFeedId } of result) {
|
|
175
|
+
const delta = Number(this.sdk.timestamp) - timestamp;
|
|
176
|
+
if (delta >= 240 && delta < 255) {
|
|
177
|
+
this.#logger?.warn(
|
|
178
|
+
`payload for ${dataFeedId} has expired by ${delta} seconds`
|
|
179
|
+
);
|
|
180
|
+
expired = true;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (expired) {
|
|
184
|
+
result = await this.#getPayloads(
|
|
185
|
+
dataServiceId,
|
|
186
|
+
dataFeedsIds,
|
|
187
|
+
uniqueSignersCount
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
157
192
|
/**
|
|
158
193
|
* Gets redstone payloads in one request for multiple feeds with the same dataServiceId and uniqueSignersCount
|
|
159
194
|
* If historicalTimestamp is set, responses will be cached
|
|
@@ -92,7 +92,7 @@ class RedstoneUpdater extends SDKConstruct {
|
|
|
92
92
|
for (const [key, group] of Object.entries(groupedFeeds)) {
|
|
93
93
|
const [dataServiceId, signersStr] = key.split(":");
|
|
94
94
|
const uniqueSignersCount = parseInt(signersStr, 10);
|
|
95
|
-
const payloads = await this.#
|
|
95
|
+
const payloads = await this.#safeGetPayloads(
|
|
96
96
|
dataServiceId,
|
|
97
97
|
group,
|
|
98
98
|
uniqueSignersCount
|
|
@@ -132,6 +132,41 @@ class RedstoneUpdater extends SDKConstruct {
|
|
|
132
132
|
);
|
|
133
133
|
return results;
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Gets payloads, retries once if it has expired while inflight
|
|
137
|
+
* @param dataServiceId
|
|
138
|
+
* @param dataFeedsIds
|
|
139
|
+
* @param uniqueSignersCount
|
|
140
|
+
* @returns
|
|
141
|
+
*/
|
|
142
|
+
async #safeGetPayloads(dataServiceId, dataFeedsIds, uniqueSignersCount) {
|
|
143
|
+
let result = await this.#getPayloads(
|
|
144
|
+
dataServiceId,
|
|
145
|
+
dataFeedsIds,
|
|
146
|
+
uniqueSignersCount
|
|
147
|
+
);
|
|
148
|
+
if (this.#historicalTimestampMs) {
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
let expired = false;
|
|
152
|
+
for (const { timestamp, dataFeedId } of result) {
|
|
153
|
+
const delta = Number(this.sdk.timestamp) - timestamp;
|
|
154
|
+
if (delta >= 240 && delta < 255) {
|
|
155
|
+
this.#logger?.warn(
|
|
156
|
+
`payload for ${dataFeedId} has expired by ${delta} seconds`
|
|
157
|
+
);
|
|
158
|
+
expired = true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (expired) {
|
|
162
|
+
result = await this.#getPayloads(
|
|
163
|
+
dataServiceId,
|
|
164
|
+
dataFeedsIds,
|
|
165
|
+
uniqueSignersCount
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
135
170
|
/**
|
|
136
171
|
* Gets redstone payloads in one request for multiple feeds with the same dataServiceId and uniqueSignersCount
|
|
137
172
|
* If historicalTimestamp is set, responses will be cached
|