@triton-one/yellowstone-grpc 5.0.8 → 5.0.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/README.md +70 -0
- package/dist/cjs/grpc/geyser.js +414 -8
- package/dist/cjs/grpc/geyser.js.map +1 -1
- package/dist/cjs/grpc/solana-storage.js +21 -2
- package/dist/cjs/grpc/solana-storage.js.map +1 -1
- package/dist/cjs/index.js +128 -103
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/napi/index.js +54 -52
- package/dist/cjs/napi/index.js.map +1 -1
- package/dist/esm/grpc/geyser.js +406 -4
- package/dist/esm/grpc/solana-storage.js +20 -1
- package/dist/esm/index.js +118 -106
- package/dist/esm/napi/index.js +54 -52
- package/dist/types/grpc/geyser.d.ts +40 -0
- package/dist/types/grpc/solana-storage.d.ts +1 -0
- package/dist/types/index.d.ts +31 -4
- package/dist/types/napi/index.d.ts +45 -445
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -25,6 +25,76 @@ npm run build
|
|
|
25
25
|
|
|
26
26
|
Please refer to [examples/typescript](../examples/typescript/README.md) for some usage examples.
|
|
27
27
|
|
|
28
|
+
### Auto reconnect
|
|
29
|
+
|
|
30
|
+
Standard `subscribe` streams can opt into the native Rust client's reconnect,
|
|
31
|
+
backfill, and deduplication layer by passing reconnect options as the fourth
|
|
32
|
+
constructor argument:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
const client = new Client(endpoint, xToken, channelOptions, {
|
|
36
|
+
backoff: {
|
|
37
|
+
initialIntervalMs: 100,
|
|
38
|
+
multiplier: 2,
|
|
39
|
+
maxRetries: 10,
|
|
40
|
+
},
|
|
41
|
+
slotRetention: 250,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
await client.connect();
|
|
45
|
+
const stream = await client.subscribe(request);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Omit the fourth argument, or pass `{ enabled: false }`, to keep the previous
|
|
49
|
+
no-reconnect behavior. Deshred subscriptions are unchanged.
|
|
50
|
+
|
|
51
|
+
### Compressed account filters
|
|
52
|
+
|
|
53
|
+
For large account sets, use `CompressedAccountFilterSet` to send a compact
|
|
54
|
+
cuckoo filter instead of a full explicit account list. The local set keeps exact
|
|
55
|
+
membership for false-positive filtering.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import Client, {
|
|
59
|
+
CompressedAccountFilterSet,
|
|
60
|
+
SubscribeRequest,
|
|
61
|
+
} from "@triton-one/yellowstone-grpc";
|
|
62
|
+
|
|
63
|
+
const accounts = new CompressedAccountFilterSet(2_000_000);
|
|
64
|
+
for (const pubkey of trackedPubkeys) {
|
|
65
|
+
accounts.insert(pubkey); // base58 string, Buffer, or Uint8Array
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const request: SubscribeRequest = {
|
|
69
|
+
accounts: {},
|
|
70
|
+
slots: {},
|
|
71
|
+
transactions: {},
|
|
72
|
+
transactionsStatus: {},
|
|
73
|
+
blocks: {},
|
|
74
|
+
blocksMeta: {},
|
|
75
|
+
entry: {},
|
|
76
|
+
accountsDataSlice: [],
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
accounts.insertIntoSubscribeRequest(request, "tracked");
|
|
80
|
+
const stream = await client.subscribe(request);
|
|
81
|
+
|
|
82
|
+
stream.on("data", (update) => {
|
|
83
|
+
const pubkey = update.account?.account?.pubkey;
|
|
84
|
+
if (pubkey && accounts.contains(pubkey)) {
|
|
85
|
+
// exact local match
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
accounts.insert(newPubkey);
|
|
90
|
+
accounts.remove(oldPubkey);
|
|
91
|
+
accounts.insertIntoSubscribeRequest(request, "tracked");
|
|
92
|
+
stream.write(request);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Use `insertIntoBlockSubscribeRequest(request, name)` when filtering account
|
|
96
|
+
includes inside block subscriptions.
|
|
97
|
+
|
|
28
98
|
## Troubleshooting
|
|
29
99
|
|
|
30
100
|
### For macOS:
|