@orbitflare/sdk 0.5.0 → 0.6.0
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 +116 -3
- package/dist/address.d.ts +2 -1
- package/dist/address.d.ts.map +1 -1
- package/dist/address.js +13 -1
- package/dist/address.js.map +1 -1
- package/dist/apex.d.ts.map +1 -1
- package/dist/apex.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +14 -1
- package/dist/error.js.map +1 -1
- package/dist/events.d.ts +45 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +98 -0
- package/dist/events.js.map +1 -0
- package/dist/grpc.d.ts +51 -19
- package/dist/grpc.d.ts.map +1 -1
- package/dist/grpc.js +210 -119
- package/dist/grpc.js.map +1 -1
- package/dist/jetstream/index.d.ts +14 -18
- package/dist/jetstream/index.d.ts.map +1 -1
- package/dist/jetstream/index.js +66 -106
- package/dist/jetstream/index.js.map +1 -1
- package/dist/jetstream/v2.d.ts +23 -28
- package/dist/jetstream/v2.d.ts.map +1 -1
- package/dist/jetstream/v2.js +112 -196
- package/dist/jetstream/v2.js.map +1 -1
- package/dist/proto/geyser.d.ts +247 -3
- package/dist/proto/geyser.d.ts.map +1 -1
- package/dist/proto/geyser.js +5038 -1780
- package/dist/proto/geyser.js.map +1 -1
- package/dist/proto/google/protobuf/timestamp.d.ts +2 -1
- package/dist/proto/google/protobuf/timestamp.d.ts.map +1 -1
- package/dist/proto/google/protobuf/timestamp.js +61 -31
- package/dist/proto/google/protobuf/timestamp.js.map +1 -1
- package/dist/proto/jetstream.d.ts +2 -1
- package/dist/proto/jetstream.d.ts.map +1 -1
- package/dist/proto/jetstream.js +1328 -976
- package/dist/proto/jetstream.js.map +1 -1
- package/dist/proto/jetstream_v2.d.ts +170 -26
- package/dist/proto/jetstream_v2.d.ts.map +1 -1
- package/dist/proto/jetstream_v2.js +1662 -721
- package/dist/proto/jetstream_v2.js.map +1 -1
- package/dist/proto/solana-storage.d.ts +21 -1
- package/dist/proto/solana-storage.d.ts.map +1 -1
- package/dist/proto/solana-storage.js +909 -681
- package/dist/proto/solana-storage.js.map +1 -1
- package/dist/streaming.d.ts +58 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +169 -0
- package/dist/streaming.js.map +1 -0
- package/package.json +7 -5
package/dist/grpc.d.ts
CHANGED
|
@@ -1,49 +1,72 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type ClientDuplexStream } from '@grpc/grpc-js';
|
|
2
2
|
import { OrbitflareError } from './error.js';
|
|
3
|
+
import { type ConnectionEvents } from './events.js';
|
|
3
4
|
import { type Logger, type LogLevel } from './logger.js';
|
|
4
5
|
import { type RetryPolicy } from './retry.js';
|
|
5
|
-
import {
|
|
6
|
+
import { Reconnector, type StreamOptions } from './streaming.js';
|
|
7
|
+
import { type SubscribeRequest, type SubscribeRequestFilterAccounts, type SubscribeRequestFilterBlockFooter, type SubscribeRequestFilterBlocks, type SubscribeRequestFilterDeshredTransactions, type SubscribeRequestFilterSlots, type SubscribeRequestFilterTransactions, type SubscribeUpdate } from './proto/geyser.js';
|
|
6
8
|
import { Commitment, Lamports, Memcmp } from './filters.js';
|
|
7
9
|
export { Commitment, Lamports, Memcmp } from './filters.js';
|
|
8
10
|
export type { LamportsCmp, MemcmpData } from './filters.js';
|
|
11
|
+
export { ConnectionEvents, type ConnectionEvent } from './events.js';
|
|
12
|
+
export interface ConnectInfo {
|
|
13
|
+
endpoint: string;
|
|
14
|
+
attempt: number;
|
|
15
|
+
reconnect: boolean;
|
|
16
|
+
lastSlot?: bigint;
|
|
17
|
+
}
|
|
18
|
+
type RequestSource = {
|
|
19
|
+
kind: 'fixed';
|
|
20
|
+
request: SubscribeRequest;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'build';
|
|
23
|
+
build: (info: ConnectInfo) => SubscribeRequest;
|
|
24
|
+
};
|
|
25
|
+
export declare class GeyserHandle {
|
|
26
|
+
private readonly stream;
|
|
27
|
+
constructor(stream: GeyserStream);
|
|
28
|
+
update(request: SubscribeRequest): void;
|
|
29
|
+
}
|
|
9
30
|
export declare class GeyserStream {
|
|
10
|
-
private readonly
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
-
private
|
|
14
|
-
private
|
|
15
|
-
|
|
31
|
+
private readonly rc;
|
|
32
|
+
private source;
|
|
33
|
+
private inbox;
|
|
34
|
+
private call?;
|
|
35
|
+
private pending;
|
|
36
|
+
private abort?;
|
|
37
|
+
_connectedBefore: boolean;
|
|
38
|
+
_lastSlot?: bigint;
|
|
39
|
+
constructor(rc: Reconnector, source: RequestSource);
|
|
16
40
|
next(): Promise<SubscribeUpdate | undefined>;
|
|
17
41
|
[Symbol.asyncIterator](): AsyncIterableIterator<SubscribeUpdate>;
|
|
42
|
+
handle(): GeyserHandle;
|
|
43
|
+
update(request: SubscribeRequest): void;
|
|
44
|
+
events(): ConnectionEvents;
|
|
18
45
|
close(): void;
|
|
46
|
+
_request(info: ConnectInfo): SubscribeRequest;
|
|
47
|
+
_attach(call: ClientDuplexStream<SubscribeRequest, SubscribeUpdate> | undefined, abort?: () => void): void;
|
|
19
48
|
_push(update: SubscribeUpdate): void;
|
|
20
49
|
_fail(err: OrbitflareError): void;
|
|
21
50
|
}
|
|
22
|
-
interface GeyserClientOptions {
|
|
23
|
-
endpoints: EndpointSet;
|
|
24
|
-
retry: RetryPolicy;
|
|
25
|
-
timeoutSecs: number;
|
|
26
|
-
keepaliveSecs: number;
|
|
27
|
-
pingIntervalSecs: number;
|
|
28
|
-
maxMissedPongs: number;
|
|
29
|
-
channelCapacity: number;
|
|
30
|
-
logger: Logger;
|
|
31
|
-
}
|
|
32
51
|
export declare class GeyserClient {
|
|
33
52
|
private readonly opts;
|
|
34
|
-
constructor(opts:
|
|
53
|
+
constructor(opts: StreamOptions);
|
|
35
54
|
subscribeYaml(path: string): GeyserStream;
|
|
36
55
|
subscribe(request: SubscribeRequest): GeyserStream;
|
|
56
|
+
subscribeWith(build: (info: ConnectInfo) => SubscribeRequest): GeyserStream;
|
|
57
|
+
private spawn;
|
|
37
58
|
}
|
|
38
59
|
export declare class GeyserClientBuilder {
|
|
39
60
|
private _url?;
|
|
40
61
|
private _fallbacks;
|
|
62
|
+
private _apiKey?;
|
|
41
63
|
private _retry;
|
|
42
64
|
private _timeoutSecs;
|
|
43
65
|
private _keepaliveSecs;
|
|
44
66
|
private _pingIntervalSecs;
|
|
45
67
|
private _maxMissedPongs;
|
|
46
68
|
private _channelCapacity;
|
|
69
|
+
private _maxDecodingMessageSize;
|
|
47
70
|
private _logger?;
|
|
48
71
|
private _logLevel?;
|
|
49
72
|
url(url: string): this;
|
|
@@ -52,12 +75,14 @@ export declare class GeyserClientBuilder {
|
|
|
52
75
|
urls(urls: string[]): this;
|
|
53
76
|
fallbackUrl(url: string): this;
|
|
54
77
|
fallbackUrls(urls: string[]): this;
|
|
78
|
+
apiKey(key: string): this;
|
|
55
79
|
retry(policy: RetryPolicy): this;
|
|
56
80
|
timeoutSecs(secs: number): this;
|
|
57
81
|
keepaliveSecs(secs: number): this;
|
|
58
82
|
pingIntervalSecs(secs: number): this;
|
|
59
83
|
maxMissedPongs(n: number): this;
|
|
60
84
|
channelCapacity(cap: number): this;
|
|
85
|
+
maxDecodingMessageSize(bytes: number): this;
|
|
61
86
|
build(): GeyserClient;
|
|
62
87
|
}
|
|
63
88
|
export declare class TransactionFilter {
|
|
@@ -107,6 +132,11 @@ export declare class BlockFilter {
|
|
|
107
132
|
includeEntries(value: boolean): this;
|
|
108
133
|
toProto(): SubscribeRequestFilterBlocks;
|
|
109
134
|
}
|
|
135
|
+
export declare class BlockFooterFilter {
|
|
136
|
+
private _includeCertificates?;
|
|
137
|
+
includeCertificates(value: boolean): this;
|
|
138
|
+
toProto(): SubscribeRequestFilterBlockFooter;
|
|
139
|
+
}
|
|
110
140
|
export declare class DeshredTransactionFilter {
|
|
111
141
|
private _vote?;
|
|
112
142
|
private _accountInclude;
|
|
@@ -126,6 +156,7 @@ export declare class SubscribeRequestBuilder {
|
|
|
126
156
|
private _blocks;
|
|
127
157
|
private _blocksMeta;
|
|
128
158
|
private _entry;
|
|
159
|
+
private _blockFooter;
|
|
129
160
|
private _commitment?;
|
|
130
161
|
private _accountsDataSlice;
|
|
131
162
|
private _fromSlot?;
|
|
@@ -136,6 +167,7 @@ export declare class SubscribeRequestBuilder {
|
|
|
136
167
|
blocks(name: string, filter: BlockFilter): this;
|
|
137
168
|
blocksMeta(name: string): this;
|
|
138
169
|
entry(name: string): this;
|
|
170
|
+
blockFooter(name: string, filter: BlockFooterFilter): this;
|
|
139
171
|
commitment(commitment: Commitment): this;
|
|
140
172
|
accountsDataSlice(offset: number, length: number): this;
|
|
141
173
|
fromSlot(slot: number): this;
|
package/dist/grpc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc.d.ts","sourceRoot":"","sources":["../src/grpc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"grpc.d.ts","sourceRoot":"","sources":["../src/grpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAA+B,MAAM,eAAe,CAAC;AAIrF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAiB,MAAM,aAAa,CAAC;AACxE,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAOL,WAAW,EACX,KAAK,aAAa,EAEnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,8BAA8B,EAEnC,KAAK,iCAAiC,EACtC,KAAK,4BAA4B,EACjC,KAAK,yCAAyC,EAC9C,KAAK,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EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAKjE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI;IAK/C,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK9B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKzB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAK1D,UAAU,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAKxC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAKvD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK5B,KAAK,IAAI,gBAAgB;CA0B1B"}
|
package/dist/grpc.js
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
|
+
import { Metadata } from '@grpc/grpc-js';
|
|
1
2
|
import { parseAddress } from './address.js';
|
|
2
3
|
import { EndpointSet } from './endpoint.js';
|
|
3
|
-
import { OrbitflareError
|
|
4
|
+
import { OrbitflareError } from './error.js';
|
|
5
|
+
import { endpointLabel } from './events.js';
|
|
4
6
|
import { resolveLogger } from './logger.js';
|
|
5
|
-
import { defaultRetryPolicy
|
|
7
|
+
import { defaultRetryPolicy } from './retry.js';
|
|
8
|
+
import { clientOptions, DEFAULT_KEEPALIVE_SECS, DEFAULT_MAX_DECODING_MESSAGE_SIZE, DEFAULT_MAX_MISSED_PONGS, DEFAULT_PING_INTERVAL_SECS, Inbox, Reconnector, toGrpcError, } from './streaming.js';
|
|
6
9
|
import { GeyserClient as ProtoGeyserClient, } from './proto/geyser.js';
|
|
7
10
|
import { geyserConfigToRequest, loadGeyserConfig } from './config.js';
|
|
8
11
|
export { Commitment, Lamports, Memcmp } from './filters.js';
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
+
export { ConnectionEvents } from './events.js';
|
|
13
|
+
const REPLAY_INFO_TIMEOUT_MS = 10_000;
|
|
14
|
+
export class GeyserHandle {
|
|
15
|
+
stream;
|
|
16
|
+
constructor(stream) {
|
|
17
|
+
this.stream = stream;
|
|
18
|
+
}
|
|
19
|
+
update(request) {
|
|
20
|
+
this.stream.update(request);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
12
23
|
export class GeyserStream {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return undefined;
|
|
28
|
-
return new Promise((resolve) => {
|
|
29
|
-
this.waiting.push(resolve);
|
|
30
|
-
});
|
|
24
|
+
rc;
|
|
25
|
+
source;
|
|
26
|
+
inbox = new Inbox();
|
|
27
|
+
call;
|
|
28
|
+
pending = [];
|
|
29
|
+
abort;
|
|
30
|
+
_connectedBefore = false;
|
|
31
|
+
_lastSlot;
|
|
32
|
+
constructor(rc, source) {
|
|
33
|
+
this.rc = rc;
|
|
34
|
+
this.source = source;
|
|
35
|
+
}
|
|
36
|
+
next() {
|
|
37
|
+
return this.inbox.next();
|
|
31
38
|
}
|
|
32
39
|
async *[Symbol.asyncIterator]() {
|
|
33
40
|
while (true) {
|
|
@@ -37,32 +44,53 @@ export class GeyserStream {
|
|
|
37
44
|
yield v;
|
|
38
45
|
}
|
|
39
46
|
}
|
|
47
|
+
handle() {
|
|
48
|
+
return new GeyserHandle(this);
|
|
49
|
+
}
|
|
50
|
+
update(request) {
|
|
51
|
+
if (this.inbox.closed)
|
|
52
|
+
throw OrbitflareError.stream('stream closed');
|
|
53
|
+
const update = { ...request, fromSlot: undefined };
|
|
54
|
+
if (this.source.kind === 'fixed')
|
|
55
|
+
this.source = { kind: 'fixed', request: update };
|
|
56
|
+
if (this.call) {
|
|
57
|
+
try {
|
|
58
|
+
this.call.write(update);
|
|
59
|
+
}
|
|
60
|
+
catch { }
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
this.pending.push(update);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
events() {
|
|
67
|
+
return this.rc.events.subscribe();
|
|
68
|
+
}
|
|
40
69
|
close() {
|
|
41
|
-
if (this.
|
|
70
|
+
if (!this.inbox.close())
|
|
42
71
|
return;
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
while (this.waiting.length > 0)
|
|
46
|
-
this.waiting.shift()(undefined);
|
|
72
|
+
this.rc.stop();
|
|
73
|
+
this.abort?.();
|
|
47
74
|
}
|
|
48
|
-
|
|
49
|
-
|
|
75
|
+
_request(info) {
|
|
76
|
+
this.pending = [];
|
|
77
|
+
return this.source.kind === 'fixed' ? this.source.request : this.source.build(info);
|
|
78
|
+
}
|
|
79
|
+
_attach(call, abort) {
|
|
80
|
+
this.call = call;
|
|
81
|
+
this.abort = abort;
|
|
82
|
+
if (!call)
|
|
50
83
|
return;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
84
|
+
const pending = this.pending;
|
|
85
|
+
this.pending = [];
|
|
86
|
+
for (const update of pending)
|
|
87
|
+
call.write(update);
|
|
88
|
+
}
|
|
89
|
+
_push(update) {
|
|
90
|
+
this.inbox.push(update);
|
|
57
91
|
}
|
|
58
92
|
_fail(err) {
|
|
59
|
-
|
|
60
|
-
return;
|
|
61
|
-
this.errored = err;
|
|
62
|
-
this.closed = true;
|
|
63
|
-
this.onClose();
|
|
64
|
-
while (this.waiting.length > 0)
|
|
65
|
-
this.waiting.shift()(undefined);
|
|
93
|
+
this.inbox.fail(err);
|
|
66
94
|
}
|
|
67
95
|
}
|
|
68
96
|
export class GeyserClient {
|
|
@@ -75,55 +103,89 @@ export class GeyserClient {
|
|
|
75
103
|
return this.subscribe(geyserConfigToRequest(cfg));
|
|
76
104
|
}
|
|
77
105
|
subscribe(request) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const idx = this.opts.endpoints.pick();
|
|
88
|
-
const url = this.opts.endpoints.get(idx);
|
|
89
|
-
logger.info('connecting (grpc)', { endpoint: sanitizeUrl(url), attempt });
|
|
90
|
-
try {
|
|
91
|
-
await runConnection(url, request, stream, this.opts, () => shutdownRequested, () => {
|
|
92
|
-
attempt = 0;
|
|
93
|
-
logger.info('connected, streaming (grpc)');
|
|
94
|
-
});
|
|
95
|
-
this.opts.endpoints.markSuccess(idx);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
catch (e) {
|
|
99
|
-
this.opts.endpoints.markFailure(idx);
|
|
100
|
-
const err = e instanceof OrbitflareError ? e : OrbitflareError.transport(e);
|
|
101
|
-
if (!hasAttemptsLeft(this.opts.retry, attempt)) {
|
|
102
|
-
stream._fail(err.withEndpoint(url));
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const delayMs = delayForAttempt(this.opts.retry, attempt);
|
|
106
|
-
logger.warn('reconnecting (grpc)', {
|
|
107
|
-
error: err,
|
|
108
|
-
endpoint: sanitizeUrl(url),
|
|
109
|
-
attempt,
|
|
110
|
-
delayMs,
|
|
111
|
-
});
|
|
112
|
-
await sleep(delayMs);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
})();
|
|
106
|
+
return this.spawn({ kind: 'fixed', request });
|
|
107
|
+
}
|
|
108
|
+
subscribeWith(build) {
|
|
109
|
+
return this.spawn({ kind: 'build', build });
|
|
110
|
+
}
|
|
111
|
+
spawn(source) {
|
|
112
|
+
const rc = new Reconnector(this.opts, 'grpc');
|
|
113
|
+
const stream = new GeyserStream(rc, source);
|
|
114
|
+
void rc.run((url, idx) => runConnection(url, idx, rc, stream), (err) => stream._fail(err));
|
|
116
115
|
return stream;
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
118
|
+
function slotOf(update) {
|
|
119
|
+
return (update.slot?.slot ??
|
|
120
|
+
update.transaction?.slot ??
|
|
121
|
+
update.transactionStatus?.slot ??
|
|
122
|
+
update.account?.slot ??
|
|
123
|
+
update.block?.slot ??
|
|
124
|
+
update.blockMeta?.slot ??
|
|
125
|
+
update.entry?.slot);
|
|
126
|
+
}
|
|
127
|
+
async function replayFrom(client, rc, wanted) {
|
|
128
|
+
const answer = await new Promise((resolve) => {
|
|
129
|
+
client.subscribeReplayInfo({}, new Metadata(), { deadline: Date.now() + REPLAY_INFO_TIMEOUT_MS }, (err, resp) => resolve(err ?? resp));
|
|
130
|
+
});
|
|
131
|
+
if (answer instanceof Error) {
|
|
132
|
+
rc.opts.logger.debug('replay window lookup failed; using fromSlot as is', {
|
|
133
|
+
error: answer.message,
|
|
134
|
+
});
|
|
135
|
+
return wanted;
|
|
136
|
+
}
|
|
137
|
+
const available = answer.firstAvailable;
|
|
138
|
+
if (available === undefined) {
|
|
139
|
+
rc.opts.logger.warn('endpoint does not support replay; starting live', { requested: wanted });
|
|
140
|
+
rc.emit({ type: 'replayUnavailable', requested: wanted });
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
if (wanted < available) {
|
|
144
|
+
rc.opts.logger.warn('fromSlot is older than the replay window; starting at the oldest available slot', { requested: wanted, available });
|
|
145
|
+
rc.emit({ type: 'replayClamped', requested: wanted, available });
|
|
146
|
+
return available;
|
|
147
|
+
}
|
|
148
|
+
return wanted;
|
|
149
|
+
}
|
|
150
|
+
function pingRequest(id) {
|
|
151
|
+
return {
|
|
152
|
+
accounts: {},
|
|
153
|
+
slots: {},
|
|
154
|
+
transactions: {},
|
|
155
|
+
transactionsStatus: {},
|
|
156
|
+
blocks: {},
|
|
157
|
+
blocksMeta: {},
|
|
158
|
+
entry: {},
|
|
159
|
+
commitment: undefined,
|
|
160
|
+
accountsDataSlice: [],
|
|
161
|
+
ping: { id },
|
|
162
|
+
fromSlot: undefined,
|
|
163
|
+
blockFooter: {},
|
|
125
164
|
};
|
|
126
|
-
|
|
165
|
+
}
|
|
166
|
+
async function runConnection(url, idx, rc, stream) {
|
|
167
|
+
const { target, credentials } = parseAddress(url);
|
|
168
|
+
const client = new ProtoGeyserClient(target, credentials, clientOptions(rc.opts));
|
|
169
|
+
let request;
|
|
170
|
+
try {
|
|
171
|
+
request = stream._request({
|
|
172
|
+
endpoint: endpointLabel(url),
|
|
173
|
+
attempt: rc.currentAttempt,
|
|
174
|
+
reconnect: stream._connectedBefore,
|
|
175
|
+
lastSlot: stream._lastSlot,
|
|
176
|
+
});
|
|
177
|
+
if (request.fromSlot !== undefined) {
|
|
178
|
+
request = { ...request, fromSlot: await replayFrom(client, rc, request.fromSlot) };
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
client.close();
|
|
183
|
+
throw e;
|
|
184
|
+
}
|
|
185
|
+
if (rc.shouldStop) {
|
|
186
|
+
client.close();
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
127
189
|
let call;
|
|
128
190
|
try {
|
|
129
191
|
call = client.subscribe();
|
|
@@ -145,20 +207,30 @@ async function runConnection(url, request, stream, opts, shouldShutdown, onConne
|
|
|
145
207
|
const cleanup = () => {
|
|
146
208
|
if (pingTimer)
|
|
147
209
|
clearInterval(pingTimer);
|
|
210
|
+
stream._attach(undefined);
|
|
148
211
|
try {
|
|
149
|
-
call.
|
|
212
|
+
call.cancel();
|
|
150
213
|
}
|
|
151
214
|
catch { }
|
|
152
215
|
client.close();
|
|
153
216
|
};
|
|
217
|
+
const markConnected = () => {
|
|
218
|
+
if (connected)
|
|
219
|
+
return;
|
|
220
|
+
connected = true;
|
|
221
|
+
rc.onConnected(idx);
|
|
222
|
+
stream._connectedBefore = true;
|
|
223
|
+
};
|
|
224
|
+
call.on('metadata', markConnected);
|
|
154
225
|
call.on('data', (update) => {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (update.pong) {
|
|
160
|
-
missedPongs = 0;
|
|
226
|
+
markConnected();
|
|
227
|
+
missedPongs = 0;
|
|
228
|
+
rc.onMessage();
|
|
229
|
+
if (update.pong)
|
|
161
230
|
return;
|
|
231
|
+
const slot = slotOf(update);
|
|
232
|
+
if (slot !== undefined && (stream._lastSlot === undefined || slot > stream._lastSlot)) {
|
|
233
|
+
stream._lastSlot = slot;
|
|
162
234
|
}
|
|
163
235
|
stream._push(update);
|
|
164
236
|
});
|
|
@@ -172,36 +244,32 @@ async function runConnection(url, request, stream, opts, shouldShutdown, onConne
|
|
|
172
244
|
});
|
|
173
245
|
try {
|
|
174
246
|
call.write(request);
|
|
247
|
+
stream._attach(call, () => {
|
|
248
|
+
resolveDone();
|
|
249
|
+
cleanup();
|
|
250
|
+
});
|
|
175
251
|
}
|
|
176
252
|
catch (e) {
|
|
177
253
|
cleanup();
|
|
178
254
|
throw OrbitflareError.transport(e);
|
|
179
255
|
}
|
|
256
|
+
if (rc.shouldStop) {
|
|
257
|
+
resolveDone();
|
|
258
|
+
cleanup();
|
|
259
|
+
}
|
|
180
260
|
pingTimer = setInterval(() => {
|
|
181
|
-
if (
|
|
182
|
-
cleanup();
|
|
261
|
+
if (rc.shouldStop) {
|
|
183
262
|
resolveDone();
|
|
263
|
+
cleanup();
|
|
184
264
|
return;
|
|
185
265
|
}
|
|
186
|
-
if (missedPongs >= opts.maxMissedPongs) {
|
|
266
|
+
if (missedPongs >= rc.opts.maxMissedPongs) {
|
|
187
267
|
cleanup();
|
|
188
|
-
rejectDone(OrbitflareError.stream(`no pong after ${opts.maxMissedPongs} pings`));
|
|
268
|
+
rejectDone(OrbitflareError.stream(`no pong after ${rc.opts.maxMissedPongs} pings`));
|
|
189
269
|
return;
|
|
190
270
|
}
|
|
191
271
|
try {
|
|
192
|
-
call.write(
|
|
193
|
-
accounts: {},
|
|
194
|
-
slots: {},
|
|
195
|
-
transactions: {},
|
|
196
|
-
transactionsStatus: {},
|
|
197
|
-
blocks: {},
|
|
198
|
-
blocksMeta: {},
|
|
199
|
-
entry: {},
|
|
200
|
-
commitment: undefined,
|
|
201
|
-
accountsDataSlice: [],
|
|
202
|
-
ping: { id: pingId },
|
|
203
|
-
fromSlot: undefined,
|
|
204
|
-
});
|
|
272
|
+
call.write(pingRequest(pingId));
|
|
205
273
|
pingId += 1;
|
|
206
274
|
missedPongs += 1;
|
|
207
275
|
}
|
|
@@ -209,23 +277,20 @@ async function runConnection(url, request, stream, opts, shouldShutdown, onConne
|
|
|
209
277
|
cleanup();
|
|
210
278
|
rejectDone(OrbitflareError.stream('outbound closed'));
|
|
211
279
|
}
|
|
212
|
-
}, opts.pingIntervalSecs * 1000);
|
|
280
|
+
}, rc.opts.pingIntervalSecs * 1000);
|
|
213
281
|
await done;
|
|
214
282
|
}
|
|
215
|
-
function toGrpcError(e) {
|
|
216
|
-
const code = typeof e?.code === 'number' ? e.code : 2;
|
|
217
|
-
const message = typeof e?.details === 'string' ? e.details : (e?.message ?? 'grpc error');
|
|
218
|
-
return OrbitflareError.grpc(code, message);
|
|
219
|
-
}
|
|
220
283
|
export class GeyserClientBuilder {
|
|
221
284
|
_url;
|
|
222
285
|
_fallbacks = [];
|
|
286
|
+
_apiKey;
|
|
223
287
|
_retry = defaultRetryPolicy();
|
|
224
288
|
_timeoutSecs = 30;
|
|
225
|
-
_keepaliveSecs =
|
|
289
|
+
_keepaliveSecs = DEFAULT_KEEPALIVE_SECS;
|
|
226
290
|
_pingIntervalSecs = DEFAULT_PING_INTERVAL_SECS;
|
|
227
291
|
_maxMissedPongs = DEFAULT_MAX_MISSED_PONGS;
|
|
228
292
|
_channelCapacity = 4096;
|
|
293
|
+
_maxDecodingMessageSize = DEFAULT_MAX_DECODING_MESSAGE_SIZE;
|
|
229
294
|
_logger;
|
|
230
295
|
_logLevel;
|
|
231
296
|
url(url) {
|
|
@@ -255,6 +320,10 @@ export class GeyserClientBuilder {
|
|
|
255
320
|
this._fallbacks.push(...urls);
|
|
256
321
|
return this;
|
|
257
322
|
}
|
|
323
|
+
apiKey(key) {
|
|
324
|
+
this._apiKey = key;
|
|
325
|
+
return this;
|
|
326
|
+
}
|
|
258
327
|
retry(policy) {
|
|
259
328
|
this._retry = policy;
|
|
260
329
|
return this;
|
|
@@ -279,6 +348,10 @@ export class GeyserClientBuilder {
|
|
|
279
348
|
this._channelCapacity = cap;
|
|
280
349
|
return this;
|
|
281
350
|
}
|
|
351
|
+
maxDecodingMessageSize(bytes) {
|
|
352
|
+
this._maxDecodingMessageSize = bytes;
|
|
353
|
+
return this;
|
|
354
|
+
}
|
|
282
355
|
build() {
|
|
283
356
|
const url = this._url ?? process.env.ORBITFLARE_GRPC_URL;
|
|
284
357
|
if (!url) {
|
|
@@ -286,12 +359,14 @@ export class GeyserClientBuilder {
|
|
|
286
359
|
}
|
|
287
360
|
return new GeyserClient({
|
|
288
361
|
endpoints: new EndpointSet(url, this._fallbacks),
|
|
362
|
+
apiKey: this._apiKey ?? process.env.ORBITFLARE_LICENSE_KEY,
|
|
289
363
|
retry: this._retry,
|
|
290
364
|
timeoutSecs: this._timeoutSecs,
|
|
291
365
|
keepaliveSecs: this._keepaliveSecs,
|
|
292
366
|
pingIntervalSecs: this._pingIntervalSecs,
|
|
293
367
|
maxMissedPongs: this._maxMissedPongs,
|
|
294
368
|
channelCapacity: this._channelCapacity,
|
|
369
|
+
maxDecodingMessageSize: this._maxDecodingMessageSize,
|
|
295
370
|
logger: resolveLogger(this._logger, this._logLevel),
|
|
296
371
|
});
|
|
297
372
|
}
|
|
@@ -458,6 +533,16 @@ export class BlockFilter {
|
|
|
458
533
|
};
|
|
459
534
|
}
|
|
460
535
|
}
|
|
536
|
+
export class BlockFooterFilter {
|
|
537
|
+
_includeCertificates;
|
|
538
|
+
includeCertificates(value) {
|
|
539
|
+
this._includeCertificates = value;
|
|
540
|
+
return this;
|
|
541
|
+
}
|
|
542
|
+
toProto() {
|
|
543
|
+
return { includeCertificates: this._includeCertificates };
|
|
544
|
+
}
|
|
545
|
+
}
|
|
461
546
|
export class DeshredTransactionFilter {
|
|
462
547
|
_vote;
|
|
463
548
|
_accountInclude = [];
|
|
@@ -496,6 +581,7 @@ export class SubscribeRequestBuilder {
|
|
|
496
581
|
_blocks = {};
|
|
497
582
|
_blocksMeta = [];
|
|
498
583
|
_entry = [];
|
|
584
|
+
_blockFooter = {};
|
|
499
585
|
_commitment;
|
|
500
586
|
_accountsDataSlice = [];
|
|
501
587
|
_fromSlot;
|
|
@@ -527,6 +613,10 @@ export class SubscribeRequestBuilder {
|
|
|
527
613
|
this._entry.push(name);
|
|
528
614
|
return this;
|
|
529
615
|
}
|
|
616
|
+
blockFooter(name, filter) {
|
|
617
|
+
this._blockFooter[name] = filter;
|
|
618
|
+
return this;
|
|
619
|
+
}
|
|
530
620
|
commitment(commitment) {
|
|
531
621
|
this._commitment = commitment;
|
|
532
622
|
return this;
|
|
@@ -563,6 +653,7 @@ export class SubscribeRequestBuilder {
|
|
|
563
653
|
// and ignores its filters, so the subscription would never start.
|
|
564
654
|
ping: undefined,
|
|
565
655
|
fromSlot: this._fromSlot === undefined ? undefined : BigInt(this._fromSlot),
|
|
656
|
+
blockFooter: mapValues(this._blockFooter, (f) => f.toProto()),
|
|
566
657
|
};
|
|
567
658
|
}
|
|
568
659
|
}
|