Skip to content

Commit

Permalink
add option to specify host for rpc server
Browse files Browse the repository at this point in the history
  • Loading branch information
shunjizhan committed Feb 22, 2024
1 parent 579e6c1 commit 0b19835
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/eth-rpc-adapter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export async function start(): Promise<void> {
version : ${version}
endpoint url : ${opts.endpoint}
subquery url : ${opts.subqlUrl}
listening to : ${opts.port}
server host : ${opts.host}
server port : ${opts.port}
max blockCache : ${opts.maxBlockCacheSize}
max batchSize : ${opts.maxBatchSize}
max storageSize : ${opts.storageCacheSize}
Expand Down
3 changes: 2 additions & 1 deletion packages/eth-rpc-adapter/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { errorHandler } from './middlewares';
import { logger } from './utils/logger';

export interface EthRpcServerOptions extends ServerOptions {
host?: string;
port: number;
batchSize: number;
middleware?: HandleFunction[];
Expand Down Expand Up @@ -101,7 +102,7 @@ export default class EthRpcServer {
}

start(): void {
this.server.listen(this.options.port);
this.server.listen(this.options.port, this.options.host);
}

stop(): void {
Expand Down
8 changes: 8 additions & 0 deletions packages/eth-rpc-adapter/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const sleep = async (time = 1000): Promise<void> => new Promise(resolve =
const {
ENDPOINT_URL,
SUBQL_URL,
HOST,
PORT,
MAX_CACHE_SIZE,
MAX_BATCH_SIZE,
Expand Down Expand Up @@ -43,6 +44,13 @@ export const yargsOptions = yargs(hideBin(process.argv))
'Subquery url: *optional* if testing contracts locally that doesn\'t query logs or historical Tx, otherwise *required*',
type: 'string',
},
host: {
alias: 'h',
demandOption: false,
default: HOST ?? 'localhost',
describe: 'host to listen for http and ws requests',
type: 'string',
},
port: {
alias: 'p',
demandOption: false,
Expand Down

0 comments on commit 0b19835

Please sign in to comment.