@drift-labs/sdk 2.85.0-beta.8 → 2.85.0-beta.9
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.
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.85.0-beta.
|
|
1
|
+
2.85.0-beta.9
|
|
@@ -45,23 +45,30 @@ class BlockhashSubscriber {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
async updateBlockhash() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
try {
|
|
49
|
+
const [resp, lastConfirmedBlockHeight] = await Promise.all([
|
|
50
|
+
this.connection.getLatestBlockhashAndContext({
|
|
51
|
+
commitment: this.commitment,
|
|
52
|
+
}),
|
|
53
|
+
this.connection.getBlockHeight({ commitment: this.commitment }),
|
|
54
|
+
]);
|
|
55
|
+
this.latestBlockHeight = lastConfirmedBlockHeight;
|
|
56
|
+
this.latestBlockHeightContext = resp.context;
|
|
57
|
+
// avoid caching duplicate blockhashes
|
|
58
|
+
if (this.blockhashes.length > 0) {
|
|
59
|
+
if (resp.value.blockhash ===
|
|
60
|
+
this.blockhashes[this.blockhashes.length - 1].blockhash) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
61
63
|
}
|
|
64
|
+
this.blockhashes.push(resp.value);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
console.error('Error updating blockhash:\n', e);
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
this.pruneBlockhashes();
|
|
62
71
|
}
|
|
63
|
-
this.blockhashes.push(resp.value);
|
|
64
|
-
this.pruneBlockhashes();
|
|
65
72
|
}
|
|
66
73
|
async subscribe() {
|
|
67
74
|
if (this.isSubscribed) {
|
package/package.json
CHANGED
|
@@ -75,27 +75,32 @@ export class BlockhashSubscriber {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
async updateBlockhash() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
78
|
+
try {
|
|
79
|
+
const [resp, lastConfirmedBlockHeight] = await Promise.all([
|
|
80
|
+
this.connection.getLatestBlockhashAndContext({
|
|
81
|
+
commitment: this.commitment,
|
|
82
|
+
}),
|
|
83
|
+
this.connection.getBlockHeight({ commitment: this.commitment }),
|
|
84
|
+
]);
|
|
85
|
+
this.latestBlockHeight = lastConfirmedBlockHeight;
|
|
86
|
+
this.latestBlockHeightContext = resp.context;
|
|
87
|
+
|
|
88
|
+
// avoid caching duplicate blockhashes
|
|
89
|
+
if (this.blockhashes.length > 0) {
|
|
90
|
+
if (
|
|
91
|
+
resp.value.blockhash ===
|
|
92
|
+
this.blockhashes[this.blockhashes.length - 1].blockhash
|
|
93
|
+
) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
94
96
|
}
|
|
95
|
-
}
|
|
96
97
|
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
this.blockhashes.push(resp.value);
|
|
99
|
+
} catch (e) {
|
|
100
|
+
console.error('Error updating blockhash:\n', e);
|
|
101
|
+
} finally {
|
|
102
|
+
this.pruneBlockhashes();
|
|
103
|
+
}
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
async subscribe() {
|