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

fix type comparison #36

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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