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

Commit 67c1a5f

Browse files
author
John Doe
committed
fix type comparison
1 parent c3090ba commit 67c1a5f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/database/sync.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,25 +196,29 @@ async function findMissingBlocks(hashList: string[]): Promise<UnsyncedBlock[]> {
196196
);
197197

198198
for await (const rowResult of result) {
199-
const matchingRow = hashListObject[rowResult.height.toString()];
199+
const matchingRow = hashListObject[rowResult.height.toNumber()];
200200

201201
if (
202202
matchingRow &&
203-
R.equals(matchingRow["hash"], rowResult.indep_hash) &&
204-
R.equals(matchingRow["height"], rowResult.height)
203+
R.equals(matchingRow["hash"], rowResult.indep_hash.toString()) &&
204+
R.equals(matchingRow["height"], rowResult.height.toNumber())
205205
) {
206-
delete hashListObject[rowResult.height];
206+
delete hashListObject[rowResult.height.toNumber()];
207207
} else {
208208
if (!matchingRow) {
209209
log.info(`Found missing block: ${rowResult.height}`);
210-
} else if (!R.equals(matchingRow["height"], rowResult.height)) {
210+
} else if (!R.equals(matchingRow["height"], rowResult.height.toNumber())) {
211211
log.info(
212212
`Found mismatching block at: ${rowResult.height} because ${matchingRow["height"]} != ${rowResult.height}`
213213
);
214-
} else if (!R.equals(matchingRow["hash"], rowResult.indep_hash)) {
214+
} else if (!R.equals(matchingRow["hash"], rowResult.indep_hash.toString())) {
215215
log.info(
216216
`Found mismatching block at: ${rowResult.height} because ${matchingRow["hash"]} != ${rowResult.indep_hash}`
217217
);
218+
} else {
219+
log.info(
220+
`Found mismatching block at: ${rowResult.height} for unknown reason`
221+
);
218222
}
219223
}
220224
}

0 commit comments

Comments
 (0)