Skip to content

Commit

Permalink
Merge pull request #29 from 0xPolygon/new-architecture
Browse files Browse the repository at this point in the history
pass db collection name to producers
  • Loading branch information
nitinmittal23 authored Mar 4, 2024
2 parents 667fe45 + 25d71d0 commit 9c18b91
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions internal/interfaces/block_producer_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface IBlockProducerConfig extends IProducerConfig {
startBlock?: number,
rpcWsEndpoints?: string[],
mongoUrl?: string,
dbCollection?: string,
maxReOrgDepth?: number,
maxRetries?: number,
blockPollingTimeout?: number,
Expand Down
4 changes: 3 additions & 1 deletion public/block_producers/block_polling_producer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ export class BlockPollerProducer extends BlockProducer {
const endpoint = config.rpcWsEndpoints?.[0] || "";
const startBlock = config.startBlock || 0;
const mongoUrl = config.mongoUrl || "mongodb://localhost:27017/chain-indexer";
const dbCollection = config.dbCollection || "producedblocks";
const blockPollingTimeout = config.blockPollingTimeout || 2000;
const maxRetries = config.maxRetries || 0;
const maxReOrgDepth = config.maxReOrgDepth || 0;

delete config.rpcWsEndpoints;
delete config.startBlock;
delete config.mongoUrl;
delete config.dbCollection;
delete config.maxReOrgDepth;
delete config.maxRetries;
delete config.blockPollingTimeout;
Expand Down Expand Up @@ -60,7 +62,7 @@ export class BlockPollerProducer extends BlockProducer {
database.model<IProducedBlock, IProducedBlocksModel<IProducedBlock>>(
"ProducedBlocks",
ProducedBlocksModel,
"producedblocks"
dbCollection
),
startBlock,
maxReOrgDepth
Expand Down
4 changes: 3 additions & 1 deletion public/block_producers/block_producer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class BlockProducer extends InternalBlockProducer {
const endpoints = config.rpcWsEndpoints || [];
const startBlock = config.startBlock || 0;
const mongoUrl = config.mongoUrl || "mongodb://localhost:27017/chain-indexer";
const dbCollection = config.dbCollection || "producedblocks";
const maxReOrgDepth = config.maxReOrgDepth || 0;
const maxRetries = config.maxRetries || 0;
const blockSubscriptionTimeout = config.blockSubscriptionTimeout;
Expand All @@ -36,6 +37,7 @@ export class BlockProducer extends InternalBlockProducer {
delete config.rpcWsEndpoints;
delete config.startBlock;
delete config.mongoUrl;
delete config.dbCollection;
delete config.maxReOrgDepth;
delete config.maxRetries;
delete config.blockSubscriptionTimeout;
Expand Down Expand Up @@ -75,7 +77,7 @@ export class BlockProducer extends InternalBlockProducer {
database.model<IProducedBlock, IProducedBlocksModel<IProducedBlock>>(
"ProducedBlocks",
ProducedBlocksModel,
"producedblocks"
dbCollection
),
startBlock,
maxReOrgDepth
Expand Down
4 changes: 3 additions & 1 deletion public/block_producers/erigon_block_producer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class ErigonBlockProducer extends BlockProducer {
const endpoints = config.rpcWsEndpoints || [];
const startBlock = config.startBlock || 0;
const mongoUrl = config.mongoUrl || "mongodb://localhost:27017/chain-indexer";
const dbCollection = config.dbCollection || "producedblocks";
const maxReOrgDepth = config.maxReOrgDepth || 0;
const maxRetries = config.maxRetries || 0;
const blockSubscriptionTimeout = config.blockSubscriptionTimeout;
Expand All @@ -34,6 +35,7 @@ export class ErigonBlockProducer extends BlockProducer {
delete config.rpcWsEndpoints;
delete config.startBlock;
delete config.mongoUrl;
delete config.dbCollection;
delete config.maxReOrgDepth;
delete config.maxRetries;
delete config.blockSubscriptionTimeout;
Expand Down Expand Up @@ -73,7 +75,7 @@ export class ErigonBlockProducer extends BlockProducer {
database.model<IProducedBlock, IProducedBlocksModel<IProducedBlock>>(
"ProducedBlocks",
ProducedBlocksModel,
"producedblocks"
dbCollection
),
startBlock,
maxReOrgDepth
Expand Down
4 changes: 3 additions & 1 deletion public/block_producers/quicknode_block_producer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class QuickNodeBlockProducer extends BlockProducer {
const endpoints = config.rpcWsEndpoints || [];
const startBlock = config.startBlock || 0;
const mongoUrl = config.mongoUrl || "mongodb://localhost:27017/chain-indexer";
const dbCollection = config.dbCollection || "producedblocks";
const maxReOrgDepth = config.maxReOrgDepth || 0;
const maxRetries = config.maxRetries || 0;
const blockSubscriptionTimeout = config.blockSubscriptionTimeout;
Expand All @@ -38,6 +39,7 @@ export class QuickNodeBlockProducer extends BlockProducer {
delete config.rpcWsEndpoints;
delete config.startBlock;
delete config.mongoUrl;
delete config.dbCollection;
delete config.maxReOrgDepth;
delete config.maxRetries;
delete config.blockDelay;
Expand Down Expand Up @@ -85,7 +87,7 @@ export class QuickNodeBlockProducer extends BlockProducer {
database.model<IProducedBlock, IProducedBlocksModel<IProducedBlock>>(
"ProducedBlocks",
ProducedBlocksModel,
"producedblocks"
dbCollection
),
startBlock,
maxReOrgDepth
Expand Down

0 comments on commit 9c18b91

Please sign in to comment.