Skip to content

Commit

Permalink
pass db collection name to producers
Browse files Browse the repository at this point in the history
  • Loading branch information
py-zoid committed Mar 4, 2024
1 parent 667fe45 commit 5e823cb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 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
2 changes: 1 addition & 1 deletion schemas/mappings.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ message Mappings {
message Metadata {
string name = 1;
string symbol = 2;
uint32 decimal = 3;
uint32 decimals = 3;
}

message MappingEvent {
Expand Down

0 comments on commit 5e823cb

Please sign in to comment.