Skip to content

Commit 9e8cc6a

Browse files
authored
add option to specify host for rpc server (#948)
1 parent 579e6c1 commit 9e8cc6a

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

packages/eth-rpc-adapter/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export async function start(): Promise<void> {
5555
version : ${version}
5656
endpoint url : ${opts.endpoint}
5757
subquery url : ${opts.subqlUrl}
58-
listening to : ${opts.port}
58+
server host : ${opts.host}
59+
server port : ${opts.port}
5960
max blockCache : ${opts.maxBlockCacheSize}
6061
max batchSize : ${opts.maxBatchSize}
6162
max storageSize : ${opts.storageCacheSize}

packages/eth-rpc-adapter/src/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { errorHandler } from './middlewares';
1010
import { logger } from './utils/logger';
1111

1212
export interface EthRpcServerOptions extends ServerOptions {
13+
host?: string;
1314
port: number;
1415
batchSize: number;
1516
middleware?: HandleFunction[];
@@ -101,7 +102,7 @@ export default class EthRpcServer {
101102
}
102103

103104
start(): void {
104-
this.server.listen(this.options.port);
105+
this.server.listen(this.options.port, this.options.host);
105106
}
106107

107108
stop(): void {

packages/eth-rpc-adapter/src/utils/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const sleep = async (time = 1000): Promise<void> => new Promise(resolve =
66
const {
77
ENDPOINT_URL,
88
SUBQL_URL,
9+
HOST,
910
PORT,
1011
MAX_CACHE_SIZE,
1112
MAX_BATCH_SIZE,
@@ -43,6 +44,13 @@ export const yargsOptions = yargs(hideBin(process.argv))
4344
'Subquery url: *optional* if testing contracts locally that doesn\'t query logs or historical Tx, otherwise *required*',
4445
type: 'string',
4546
},
47+
host: {
48+
alias: 'h',
49+
demandOption: false,
50+
default: HOST ?? 'localhost',
51+
describe: 'host to listen for http and ws requests',
52+
type: 'string',
53+
},
4654
port: {
4755
alias: 'p',
4856
demandOption: false,

0 commit comments

Comments
 (0)