Skip to content

Commit

Permalink
process and save transaction cids when header watcher enabled (#53)
Browse files Browse the repository at this point in the history
* process and save transaction cids when header watcher enabled

* bump version
  • Loading branch information
ramilexe authored May 13, 2021
1 parent 3adda52 commit 9f544b0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:
image: postgres:10.12-alpine
environment:
- POSTGRES_USER=vdbm
- POSTGRES_DB=vulcanize_public
- POSTGRES_DB=indexer
- POSTGRES_PASSWORD=password
volumes:
- indexer_db_data:/var/lib/postgresql/data
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vulcanize/eth-watcher-ts",
"version": "0.0.19",
"version": "0.0.20",
"type": "commonjs",
"types": "./dist",
"main": "./dist/server.js",
Expand Down
17 changes: 17 additions & 0 deletions src/repositories/graphqlRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,23 @@ export default class GraphqlRepository {
txRoot
uncleRoot
stateRoot
ethTransactionCidsByHeaderId {
nodes {
id
cid
headerId
index
mhKey
nodeId
dst
src
txData
txHash
blockByMhKey {
data
}
}
}
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dotenv.config();

import { EthWatcherServer } from './server';
import DataService from './services/dataService';
import HeaderCids from "./models/eth/headerCids";

process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at:', p, 'reason:', reason);
Expand All @@ -20,7 +21,15 @@ process.on('unhandledRejection', (reason, p) => {
}
dataService.processState(data.relatedNode)
},
processHeader: (data) => dataService.processHeader(data),
processHeader: async (data) => {
const header: HeaderCids = await dataService.processHeader(data);
if (data?.ethTransactionCidsByHeaderId?.nodes && data?.ethTransactionCidsByHeaderId?.nodes.length > 0) {
const txs = data.ethTransactionCidsByHeaderId.nodes;
for (const tx of txs) {
await dataService.processTransaction(tx, header.id);
}
}
},
processEvent: (data) => {
if (!data) {
return;
Expand Down
5 changes: 5 additions & 0 deletions src/types/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export type EthTransactionCid = {
blockByMhKey: BlockByMhKey;
};

export type ethTransactionCids = {
nodes: EthTransactionCid[];
}

export type EthHeaderCid = {
td: string;
cid: string;
Expand All @@ -42,6 +46,7 @@ export type EthHeaderCid = {
uncleRoot: string;
timesValidated: number;
timestamp: string;
ethTransactionCidsByHeaderId: ethTransactionCids;
}

export type EthStateCid = {
Expand Down

0 comments on commit 9f544b0

Please sign in to comment.