mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-07-29 11:22:08 +00:00
Fix null parent. (#244)
Co-authored-by: nabarun <nabarun@deepstacksoft.com>
This commit is contained in:
parent
06bed1c13b
commit
a9dc34f704
@ -83,9 +83,7 @@ export class EthClient {
|
|||||||
block: {
|
block: {
|
||||||
number: blockNumHex,
|
number: blockNumHex,
|
||||||
timestamp: timestampHex,
|
timestamp: timestampHex,
|
||||||
parent: {
|
parent
|
||||||
hash: parentHash
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} = result;
|
} = result;
|
||||||
|
|
||||||
@ -93,9 +91,7 @@ export class EthClient {
|
|||||||
hash: vars.blockHash,
|
hash: vars.blockHash,
|
||||||
number: parseInt(blockNumHex, 16),
|
number: parseInt(blockNumHex, 16),
|
||||||
timestamp: parseInt(timestampHex, 16),
|
timestamp: parseInt(timestampHex, 16),
|
||||||
parent: {
|
parent
|
||||||
hash: parentHash
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const logs = resultLogs.map((logEntry: any) => _.merge({}, logEntry, { transaction: { block } }));
|
const logs = resultLogs.map((logEntry: any) => _.merge({}, logEntry, { transaction: { block } }));
|
||||||
|
@ -17,7 +17,7 @@ export class BlockProgress implements BlockProgressInterface {
|
|||||||
@Column('varchar', { length: 66 })
|
@Column('varchar', { length: 66 })
|
||||||
blockHash!: string;
|
blockHash!: string;
|
||||||
|
|
||||||
@Column('varchar', { length: 66 })
|
@Column('varchar', { length: 66, nullable: true })
|
||||||
parentHash!: string;
|
parentHash!: string;
|
||||||
|
|
||||||
@Column('integer')
|
@Column('integer')
|
||||||
|
@ -17,7 +17,7 @@ export class BlockProgress implements BlockProgressInterface {
|
|||||||
@Column('varchar', { length: 66 })
|
@Column('varchar', { length: 66 })
|
||||||
blockHash!: string;
|
blockHash!: string;
|
||||||
|
|
||||||
@Column('varchar', { length: 66 })
|
@Column('varchar', { length: 66, nullable: true })
|
||||||
parentHash!: string;
|
parentHash!: string;
|
||||||
|
|
||||||
@Column('integer')
|
@Column('integer')
|
||||||
|
@ -474,7 +474,7 @@ export class Indexer implements IndexerInterface {
|
|||||||
blockHash,
|
blockHash,
|
||||||
blockNumber: block.number,
|
blockNumber: block.number,
|
||||||
blockTimestamp: block.timestamp,
|
blockTimestamp: block.timestamp,
|
||||||
parentHash: block.parent.hash
|
parentHash: block.parent?.hash
|
||||||
};
|
};
|
||||||
|
|
||||||
await this._db.saveEvents(dbTx, block, dbEvents);
|
await this._db.saveEvents(dbTx, block, dbEvents);
|
||||||
|
@ -197,9 +197,10 @@ export class Database {
|
|||||||
} = block;
|
} = block;
|
||||||
|
|
||||||
assert(blockHash);
|
assert(blockHash);
|
||||||
assert(blockNumber);
|
assert(blockNumber !== undefined);
|
||||||
assert(blockTimestamp);
|
assert(blockNumber > -1);
|
||||||
assert(parentHash);
|
assert(blockTimestamp !== undefined);
|
||||||
|
assert(blockTimestamp > -1);
|
||||||
|
|
||||||
// In a transaction:
|
// In a transaction:
|
||||||
// (1) Save all the events in the database.
|
// (1) Save all the events in the database.
|
||||||
|
@ -35,6 +35,12 @@ export const fillBlocks = async (
|
|||||||
if (blockProgress) {
|
if (blockProgress) {
|
||||||
log(`Block number ${blockNumber}, block hash ${blockHash} already known, skip filling`);
|
log(`Block number ${blockNumber}, block hash ${blockHash} already known, skip filling`);
|
||||||
} else {
|
} else {
|
||||||
|
const syncStatus = await indexer.getSyncStatus();
|
||||||
|
|
||||||
|
if (!syncStatus || syncStatus.chainHeadBlockNumber < blockNumber) {
|
||||||
|
await indexer.updateSyncStatusChainHead(blockHash, blockNumber);
|
||||||
|
}
|
||||||
|
|
||||||
await jobQueue.pushJob(QUEUE_BLOCK_PROCESSING, { kind: JOB_KIND_INDEX, blockHash, blockNumber, parentHash, timestamp });
|
await jobQueue.pushJob(QUEUE_BLOCK_PROCESSING, { kind: JOB_KIND_INDEX, blockHash, blockNumber, parentHash, timestamp });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ export class JobRunner {
|
|||||||
const parent = await this._indexer.getBlockProgress(parentHash);
|
const parent = await this._indexer.getBlockProgress(parentHash);
|
||||||
|
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
const { number: parentBlockNumber, parent: { hash: grandparentHash }, timestamp: parentTimestamp } = await this._indexer.getBlock(parentHash);
|
const { number: parentBlockNumber, parent: grandparent, timestamp: parentTimestamp } = await this._indexer.getBlock(parentHash);
|
||||||
|
|
||||||
// Create a higher priority job to index parent block and then abort.
|
// Create a higher priority job to index parent block and then abort.
|
||||||
// We don't have to worry about aborting as this job will get retried later.
|
// We don't have to worry about aborting as this job will get retried later.
|
||||||
@ -148,7 +148,7 @@ export class JobRunner {
|
|||||||
kind: JOB_KIND_INDEX,
|
kind: JOB_KIND_INDEX,
|
||||||
blockHash: parentHash,
|
blockHash: parentHash,
|
||||||
blockNumber: parentBlockNumber,
|
blockNumber: parentBlockNumber,
|
||||||
parentHash: grandparentHash,
|
parentHash: grandparent?.hash,
|
||||||
timestamp: parentTimestamp,
|
timestamp: parentTimestamp,
|
||||||
priority: newPriority
|
priority: newPriority
|
||||||
}, { priority: newPriority });
|
}, { priority: newPriority });
|
||||||
|
Loading…
Reference in New Issue
Block a user