Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ export class RpcClient {
} else {
rpc = new _rpcClient(connectionString, { maxRetries: 0 });
rpc_retry = new _rpcClient(connectionString, { maxRetries: Config.rpc.rpcMaxRetries, timeoutMs: Config.rpc.rpcTimeoutMs, retryDelayMs: Config.rpc.rpcRetryDelayMs });
// Hack: overide the underlying protocol to reuse connections
// The underlying library allows specifying custom options for the client, re: https://github.com/bitpay/bitcoind-rpc/blob/96257629cfa36f9e1a36500f69d209cdc3cba0a7/lib/index.js#L85-L89
// Here we enforce the usage of our own agent which has keep-alive enabled.
if (!rpc.httpOptions) {
rpc.httpOptions = {}
}
rpc.httpOptions.agent = new rpc.protocol.Agent({keepAlive: true})
if (!rpc_retry.httpOptions) {
rpc_retry.httpOptions = {}
}
rpc_retry.httpOptions.agent = new rpc_retry.protocol.Agent({keepAlive: true})

}
}

Expand Down