Skip to content

Commit

Permalink
logLevel log when reset
Browse files Browse the repository at this point in the history
  • Loading branch information
wighawag committed Nov 25, 2023
1 parent 838da53 commit 7042a49
Show file tree
Hide file tree
Showing 32 changed files with 154 additions and 16 deletions.
6 changes: 6 additions & 0 deletions examples/event-processor-bleeps/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# event-processor-bleeps

## 0.0.48

### Patch Changes

- ethereum-indexer-js-processor@0.6.22

## 0.0.47

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/event-processor-bleeps/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "event-processor-bleeps",
"private": true,
"version": "0.0.47",
"version": "0.0.48",
"description": "",
"type": "module",
"main": "dist/index.cjs",
Expand Down
6 changes: 6 additions & 0 deletions examples/event-processor-conquest-eth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# event-processor-conquest-eth

## 0.0.48

### Patch Changes

- ethereum-indexer-js-processor@0.6.22

## 0.0.47

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/event-processor-conquest-eth/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "event-processor-conquest-eth",
"private": true,
"version": "0.0.47",
"version": "0.0.48",
"description": "",
"type": "module",
"main": "dist/index.cjs",
Expand Down
6 changes: 6 additions & 0 deletions examples/event-processor-conquest-fplay/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# event-processor-conquest-fplay

## 0.0.48

### Patch Changes

- ethereum-indexer-js-processor@0.6.22

## 0.0.47

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/event-processor-conquest-fplay/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "event-processor-conquest-fplay",
"private": true,
"version": "0.0.47",
"version": "0.0.48",
"description": "",
"type": "module",
"main": "dist/index.cjs",
Expand Down
6 changes: 6 additions & 0 deletions examples/event-processor-nfts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# event-processor-nfts

## 0.0.48

### Patch Changes

- ethereum-indexer-js-processor@0.6.22

## 0.0.47

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/event-processor-nfts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "event-processor-nfts",
"private": true,
"version": "0.0.47",
"version": "0.0.48",
"description": "",
"type": "module",
"main": "dist/index.cjs",
Expand Down
12 changes: 12 additions & 0 deletions examples/mud/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# web-demo

## 0.1.49

### Patch Changes

- Updated dependencies
- ethereum-indexer@0.6.17
- ethereum-indexer-browser@0.6.21
- ethereum-indexer-js-processor@0.6.22
- event-processor-bleeps@0.0.48
- event-processor-conquest-eth@0.0.48
- event-processor-nfts@0.0.48

## 0.1.48

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/mud/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mud-demo",
"private": true,
"version": "0.1.48",
"version": "0.1.49",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
11 changes: 11 additions & 0 deletions examples/web-demo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# web-demo

## 0.1.49

### Patch Changes

- Updated dependencies
- ethereum-indexer@0.6.17
- ethereum-indexer-browser@0.6.21
- event-processor-bleeps@0.0.48
- event-processor-conquest-eth@0.0.48
- event-processor-nfts@0.0.48

## 0.1.48

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/web-demo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "web-demo",
"private": true,
"version": "0.1.48",
"version": "0.1.49",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
7 changes: 7 additions & 0 deletions packages/ethereum-indexer-browser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# ethereum-indexer-browser

## 0.6.21

### Patch Changes

- Updated dependencies
- ethereum-indexer@0.6.17

## 0.6.20

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-indexer-browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethereum-indexer-browser",
"version": "0.6.20",
"version": "0.6.21",
"publishConfig": {
"access": "public"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/ethereum-indexer-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# ethereum-indexer-cli

## 0.6.22

### Patch Changes

- Updated dependencies
- ethereum-indexer@0.6.17
- ethereum-indexer-utils@0.6.11

## 0.6.21

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-indexer-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethereum-indexer-cli",
"version": "0.6.21",
"version": "0.6.22",
"description": "",
"keywords": [],
"author": "",
Expand Down
8 changes: 8 additions & 0 deletions packages/ethereum-indexer-db-processors/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# ethereum-indexer-db-processors

## 0.6.17

### Patch Changes

- Updated dependencies
- ethereum-indexer@0.6.17
- ethereum-indexer-db-utils@0.6.17

## 0.6.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-indexer-db-processors/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethereum-indexer-db-processors",
"version": "0.6.16",
"version": "0.6.17",
"description": "",
"publishConfig": {
"access": "public"
Expand Down
7 changes: 7 additions & 0 deletions packages/ethereum-indexer-db-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# ethereum-indexer-db-utils

## 0.6.17

### Patch Changes

- Updated dependencies
- ethereum-indexer@0.6.17

## 0.6.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-indexer-db-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethereum-indexer-db-utils",
"version": "0.6.16",
"version": "0.6.17",
"description": "",
"publishConfig": {
"access": "public"
Expand Down
7 changes: 7 additions & 0 deletions packages/ethereum-indexer-fs-cache/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# ethereum-indexer-fs-event-store

## 0.6.17

### Patch Changes

- Updated dependencies
- ethereum-indexer@0.6.17

## 0.6.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-indexer-fs-cache/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethereum-indexer-fs-cache",
"version": "0.6.16",
"version": "0.6.17",
"description": "",
"publishConfig": {
"access": "public"
Expand Down
7 changes: 7 additions & 0 deletions packages/ethereum-indexer-js-processor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# ethereum-indexer-js-processor

## 0.6.22

### Patch Changes

- Updated dependencies
- ethereum-indexer@0.6.17

## 0.6.21

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-indexer-js-processor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethereum-indexer-js-processor",
"version": "0.6.21",
"version": "0.6.22",
"description": "",
"keywords": [],
"author": "",
Expand Down
10 changes: 10 additions & 0 deletions packages/ethereum-indexer-server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# ethereum-indexer-server

## 0.6.25

### Patch Changes

- Updated dependencies
- ethereum-indexer@0.6.17
- ethereum-indexer-db-utils@0.6.17
- ethereum-indexer-fs-cache@0.6.17
- ethereum-indexer-utils@0.6.11

## 0.6.24

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-indexer-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethereum-indexer-server",
"version": "0.6.24",
"version": "0.6.25",
"description": "",
"keywords": [],
"author": "",
Expand Down
8 changes: 8 additions & 0 deletions packages/ethereum-indexer-streams/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# ethereum-indexer-server

## 0.6.22

### Patch Changes

- Updated dependencies
- ethereum-indexer@0.6.17
- ethereum-indexer-utils@0.6.11

## 0.6.21

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-indexer-streams/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethereum-indexer-streams",
"version": "0.6.21",
"version": "0.6.22",
"description": "",
"keywords": [],
"author": "",
Expand Down
6 changes: 6 additions & 0 deletions packages/ethereum-indexer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# ethereum-indexer

## 0.6.17

### Patch Changes

- log when reset logLevel

## 0.6.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-indexer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethereum-indexer",
"version": "0.6.16",
"version": "0.6.17",
"publishConfig": {
"access": "public"
},
Expand Down
24 changes: 23 additions & 1 deletion packages/ethereum-indexer/src/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,14 @@ export class EthereumIndexer<ABI extends Abi, ProcessResultType = void> {
const newProvider = update.provider || this.provider;
const oldSource = this.source;

const processorVersionHash = this.processor.getVersionHash();
const resetNeeded = !indexerMatches(newSourceHashes, newConfigHash, 0, {
source: this.sourceHashes,
config: this.streamConfigHash,
processor: this.processor.getVersionHash(),
processor: processorVersionHash,
});


// TODO remove, this is the responsibility of the developer to ensure it pass correct data when indexer context changes
// for now we do a minimum check of chainId
// if this has been updated but the source remain unchanged, then the developer must have forgot to send a different source
Expand All @@ -242,6 +244,16 @@ export class EthereumIndexer<ABI extends Abi, ProcessResultType = void> {
`
);
}
} else {
if (this.config?.logLevel && this.config.logLevel >= 1) {
console.log(`updateIndexer: Reset needed, Indexer do not match`, {
newSourceHashes,
newConfigHash,
sourceHashes: this.sourceHashes,
streamConfigHash: this.streamConfigHash,
processorVersionHash
});
}
}

this._feed.reset();
Expand Down Expand Up @@ -327,6 +339,16 @@ export class EthereumIndexer<ABI extends Abi, ProcessResultType = void> {
this._onStateUpdated(state);
} else {
namedLogger.log(`STATE DISCARDED AS PROCESSOR CHANGED`);
if (this.config?.logLevel && this.config.logLevel >= 1) {
console.log(`State Discarded: processor changed`, JSON.stringify({
sourceHashes: this.sourceHashes,
loadedSourceHashes: loaded.lastSync.context.source,
streamConfigHash: this.streamConfigHash,
loadedStreamConfigHash: loaded.lastSync.context.config,
processorHash,
loadedProcessorHash: loadedLastSync.context.processor
}, null, 2));
}
await this.processor.clear();
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/ethereum-indexer/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export type ProvidedIndexerConfig<ABI extends Abi> = {
feedBatchSize?: number;
keepStream?: ExistingStream<ABI>;
skipGenesisCheck?: boolean;
logLevel?: number;
};

export type UsedIndexerConfig<ABI extends Abi> = ProvidedIndexerConfig<ABI> & {
Expand Down

0 comments on commit 7042a49

Please sign in to comment.