Skip to content

Commit

Permalink
Unhook all of the subscription augmenters so that we can refactor and…
Browse files Browse the repository at this point in the history
… build them back up, one by one
  • Loading branch information
steveluscher committed Oct 4, 2024
1 parent 8c2cb9f commit e4260af
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 183 deletions.
2 changes: 0 additions & 2 deletions packages/rpc-subscriptions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
],
"dependencies": {
"@solana/errors": "workspace:*",
"@solana/fast-stable-stringify": "workspace:*",
"@solana/functional": "workspace:*",
"@solana/promises": "workspace:*",
"@solana/rpc-subscriptions-api": "workspace:*",
"@solana/rpc-subscriptions-spec": "workspace:*",
Expand Down

This file was deleted.

This file was deleted.

37 changes: 8 additions & 29 deletions packages/rpc-subscriptions/src/rpc-subscriptions-transport.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import { pipe } from '@solana/functional';
import { createWebSocketTransport } from '@solana/rpc-subscriptions-transport-websocket';
import type { ClusterUrl } from '@solana/rpc-types';

import { getWebSocketTransportWithAutoping } from './rpc-subscriptions-autopinger';
import { RpcSubscriptionsTransportFromClusterUrl } from './rpc-subscriptions-clusters';
import { getWebSocketTransportWithConnectionSharding } from './rpc-subscriptions-connection-sharding';

export type DefaultRpcSubscriptionsTransportConfig<TClusterUrl extends ClusterUrl> = Readonly<{
/**
* You might like to open more subscriptions per connection than your RPC provider allows
* for. Using the initial payload as input, return a shard key from this method to assign
* subscriptions to separate connections. One socket will be opened per shard key.
*/
getShard?: (payload: unknown) => string;
intervalMs?: number;
sendBufferHighWatermark?: number;
url: TClusterUrl;
Expand All @@ -21,24 +12,12 @@ export type DefaultRpcSubscriptionsTransportConfig<TClusterUrl extends ClusterUr
export function createDefaultRpcSubscriptionsTransport<TClusterUrl extends ClusterUrl>(
config: DefaultRpcSubscriptionsTransportConfig<TClusterUrl>,
): RpcSubscriptionsTransportFromClusterUrl<TClusterUrl> {
const { getShard, intervalMs, ...rest } = config;
return pipe(
createWebSocketTransport({
...rest,
sendBufferHighWatermark:
config.sendBufferHighWatermark ??
// Let 128KB of data into the WebSocket buffer before buffering it in the app.
131_072,
}) as RpcSubscriptionsTransportFromClusterUrl<TClusterUrl>,
transport =>
getWebSocketTransportWithAutoping({
intervalMs: intervalMs ?? 5_000,
transport,
}),
transport =>
getWebSocketTransportWithConnectionSharding({
getShard,
transport,
}),
);
const { /* `intervalMs` will make a comeback; stay tuned */ ...rest } = config;
return createWebSocketTransport({
...rest,
sendBufferHighWatermark:
config.sendBufferHighWatermark ??
// Let 128KB of data into the WebSocket buffer before buffering it in the app.
131_072,
}) as RpcSubscriptionsTransportFromClusterUrl<TClusterUrl>;
}
18 changes: 4 additions & 14 deletions packages/rpc-subscriptions/src/rpc-subscriptions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import fastStableStringify from '@solana/fast-stable-stringify';
import { pipe } from '@solana/functional';
import type { SolanaRpcSubscriptionsApi, SolanaRpcSubscriptionsApiUnstable } from '@solana/rpc-subscriptions-api';
import { createSolanaRpcSubscriptionsApi } from '@solana/rpc-subscriptions-api';
import {
Expand All @@ -11,7 +9,6 @@ import { ClusterUrl } from '@solana/rpc-types';

import { DEFAULT_RPC_SUBSCRIPTIONS_CONFIG } from './rpc-default-config';
import type { RpcSubscriptionsFromTransport } from './rpc-subscriptions-clusters';
import { getRpcSubscriptionsWithSubscriptionCoalescing } from './rpc-subscriptions-coalescer';
import {
createDefaultRpcSubscriptionsTransport,
DefaultRpcSubscriptionsTransportConfig,
Expand Down Expand Up @@ -39,17 +36,10 @@ export function createSolanaRpcSubscriptionsFromTransport<
TTransport extends RpcSubscriptionsTransport,
TApi extends RpcSubscriptionsApiMethods = SolanaRpcSubscriptionsApi,
>(transport: TTransport) {
return pipe(
createSubscriptionRpc({
api: createSolanaRpcSubscriptionsApi<TApi>(DEFAULT_RPC_SUBSCRIPTIONS_CONFIG),
transport,
}),
rpcSubscriptions =>
getRpcSubscriptionsWithSubscriptionCoalescing({
getDeduplicationKey: (...args) => fastStableStringify(args),
rpcSubscriptions,
}),
) as RpcSubscriptionsFromTransport<TApi, TTransport>;
return createSubscriptionRpc({
api: createSolanaRpcSubscriptionsApi<TApi>(DEFAULT_RPC_SUBSCRIPTIONS_CONFIG),
transport,
}) as RpcSubscriptionsFromTransport<TApi, TTransport>;
}

export function createSolanaRpcSubscriptionsFromTransport_UNSTABLE<TTransport extends RpcSubscriptionsTransport>(
Expand Down
6 changes: 0 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e4260af

Please sign in to comment.