Skip to content

Commit

Permalink
Router supports multiple services (#118)
Browse files Browse the repository at this point in the history
* Add custody service

* trying out sendResponse

* re-arrange

* refactor to packages

* In progress

* more

* finishing touches
  • Loading branch information
grod220 authored Oct 19, 2023
1 parent 627635c commit a335a2c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './src/block-processor';
export * from './src/root-querier';
4 changes: 2 additions & 2 deletions src/block-processor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Nullifier } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core
import { SpendableNoteRecord } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1alpha1/view_pb';
import { Code, ConnectError } from '@connectrpc/connect';
import { backOff } from 'exponential-backoff';
import { IndexedDbInterface, ViewServerInterface } from 'penumbra-types';
import { BlockProcessorInterface, IndexedDbInterface, ViewServerInterface } from 'penumbra-types';
import { decodeNctRoot } from 'penumbra-wasm-ts/src/sct';
import { RootQuerier } from '../root-querier';
import { generateMetadata } from './metadata';
Expand All @@ -17,7 +17,7 @@ interface QueryClientProps {
viewServer: ViewServerInterface;
}

export class BlockProcessor {
export class BlockProcessor implements BlockProcessorInterface {
private readonly fullViewingKey: string;
private readonly querier: RootQuerier;
private readonly indexedDb: IndexedDbInterface;
Expand Down
3 changes: 2 additions & 1 deletion src/queriers/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import {
KeyValueResponse_Value,
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/app/v1alpha1/app_pb';
import { QueryService } from '@buf/penumbra-zone_penumbra.connectrpc_es/penumbra/core/app/v1alpha1/app_connect';
import { AppQuerierInterface } from 'penumbra-types/src/querier';

export class AppQuerier {
export class AppQuerier implements AppQuerierInterface {
private readonly client: PromiseClient<typeof QueryService>;

constructor({ grpcEndpoint }: { grpcEndpoint: string }) {
Expand Down
9 changes: 2 additions & 7 deletions src/queriers/compact-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ import { PromiseClient } from '@connectrpc/connect';
import { CompactBlockRangeRequest } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/compact_block/v1alpha1/compact_block_pb';
import { QueryService } from '@buf/penumbra-zone_penumbra.connectrpc_es/penumbra/core/component/compact_block/v1alpha1/compact_block_connect';
import { createClient } from './utils';
import { CompactBlockQuerierInterface, CompactBlockRangeParams } from 'penumbra-types';

interface CompactBlockRangeParams {
startHeight: bigint;
keepAlive: boolean; // Will continuously receive blocks as long as service worker is running
abortSignal: AbortSignal;
}

export class CompactBlockQuerier {
export class CompactBlockQuerier implements CompactBlockQuerierInterface {
private readonly client: PromiseClient<typeof QueryService>;

constructor({ grpcEndpoint }: { grpcEndpoint: string }) {
Expand Down
3 changes: 2 additions & 1 deletion src/queriers/shielded-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import {
AssetId,
DenomMetadata,
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1alpha1/asset_pb';
import { ShieldedPoolQuerierInterface } from 'penumbra-types/src/querier';

export class ShieldedPoolQuerier {
export class ShieldedPoolQuerier implements ShieldedPoolQuerierInterface {
private readonly client: PromiseClient<typeof QueryService>;

constructor({ grpcEndpoint }: { grpcEndpoint: string }) {
Expand Down
3 changes: 2 additions & 1 deletion src/queriers/tendermint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import {
GetStatusRequest,
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/util/tendermint_proxy/v1alpha1/tendermint_proxy_pb';
import { TendermintProxyService } from '@buf/penumbra-zone_penumbra.connectrpc_es/penumbra/util/tendermint_proxy/v1alpha1/tendermint_proxy_connect';
import { TendermintQuerierInterface } from 'penumbra-types/src/querier';

export class TendermintQuerier {
export class TendermintQuerier implements TendermintQuerierInterface {
private readonly client: PromiseClient<typeof TendermintProxyService>;

constructor({ grpcEndpoint }: { grpcEndpoint: string }) {
Expand Down
3 changes: 2 additions & 1 deletion src/root-querier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { CompactBlockQuerier } from './queriers/compact-block';
import { AppQuerier } from './queriers/app';
import { TendermintQuerier } from './queriers/tendermint';
import { ShieldedPoolQuerier } from './queriers/shielded-pool';
import { RootQuerierInterface } from 'penumbra-types/src/querier';

// Given the amount of query services, this root querier aggregates them all
// to make it easier for consumers
export class RootQuerier {
export class RootQuerier implements RootQuerierInterface {
readonly app: AppQuerier;
readonly compactBlock: CompactBlockQuerier;
readonly tendermint: TendermintQuerier;
Expand Down

0 comments on commit a335a2c

Please sign in to comment.