Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix type comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
John Doe committed May 18, 2022
1 parent c3090ba commit 67c1a5f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/database/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,25 +196,29 @@ async function findMissingBlocks(hashList: string[]): Promise<UnsyncedBlock[]> {
);

for await (const rowResult of result) {
const matchingRow = hashListObject[rowResult.height.toString()];
const matchingRow = hashListObject[rowResult.height.toNumber()];

if (
matchingRow &&
R.equals(matchingRow["hash"], rowResult.indep_hash) &&
R.equals(matchingRow["height"], rowResult.height)
R.equals(matchingRow["hash"], rowResult.indep_hash.toString()) &&
R.equals(matchingRow["height"], rowResult.height.toNumber())
) {
delete hashListObject[rowResult.height];
delete hashListObject[rowResult.height.toNumber()];
} else {
if (!matchingRow) {
log.info(`Found missing block: ${rowResult.height}`);
} else if (!R.equals(matchingRow["height"], rowResult.height)) {
} else if (!R.equals(matchingRow["height"], rowResult.height.toNumber())) {
log.info(
`Found mismatching block at: ${rowResult.height} because ${matchingRow["height"]} != ${rowResult.height}`
);
} else if (!R.equals(matchingRow["hash"], rowResult.indep_hash)) {
} else if (!R.equals(matchingRow["hash"], rowResult.indep_hash.toString())) {
log.info(
`Found mismatching block at: ${rowResult.height} because ${matchingRow["hash"]} != ${rowResult.indep_hash}`
);
} else {
log.info(
`Found mismatching block at: ${rowResult.height} for unknown reason`
);
}
}
}
Expand Down

0 comments on commit 67c1a5f

Please sign in to comment.