Skip to content

Commit

Permalink
Adds connection keep-alive and response compresion to RPC calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrés Elizondo committed Feb 7, 2025
1 parent 8d46caa commit c6ffaf9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/data_sources/events/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import { RawLog } from 'ethereum-types';

const Web3 = require('web3');
const Web3HttpProvider = require('web3-providers-http');

export { BlockWithTransactionData, BlockWithoutTransactionData, Transaction, TransactionReceipt } from './web3_updated';

Expand All @@ -32,8 +33,15 @@ export class Web3Source {
private readonly _web3Wrapper: Web3Wrapper;
private readonly _web3: any;
constructor(provider: Web3ProviderEngine, wsProvider: string) {
const web3HttpOptions = {
keepAlive: true,
headers: [
{ name: 'Accept-Encoding', value: 'gzip'}
]
};

this._web3Wrapper = new Web3Wrapper(provider);
this._web3 = new Web3(wsProvider);
this._web3 = new Web3(new Web3HttpProvider(wsProvider, web3HttpOptions));

if (BLOCK_RECEIPTS_MODE === 'standard') {
this._web3.eth.extend({
Expand Down

0 comments on commit c6ffaf9

Please sign in to comment.