Shuffle mempool transactions before saving disk cache. (#398)

fixes #397
This commit is contained in:
softsimon
2021-03-19 13:47:37 +07:00
committed by GitHub
parent 9440bb7505
commit aa43511e0a
2 changed files with 10 additions and 1 deletions

View File

@@ -71,6 +71,13 @@ export class Common {
}, ms);
});
}
static shuffleArray(array: any[]) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}
static setRelativesAndGetCpfpInfo(tx: TransactionExtended, memPool: { [txid: string]: TransactionExtended }): CpfpInfo {
const parents = this.findAllParents(tx, memPool);
@@ -129,5 +136,4 @@ export class Common {
});
return parents;
}
}