@0xbow/privacy-pools-core-sdk 0.0.0-c084059 → 0.0.0-c42a71a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/account.service.ts +19 -8
package/package.json
CHANGED
|
@@ -488,12 +488,7 @@ export class AccountService {
|
|
|
488
488
|
|
|
489
489
|
const depositMap = new Map<Hash, DepositEvent>();
|
|
490
490
|
for (const event of depositEvents) {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
// If no existing event, or current event is older (earlier block), use current event
|
|
494
|
-
if (!existingEvent || event.blockNumber < existingEvent.blockNumber) {
|
|
495
|
-
depositMap.set(event.precommitment, event);
|
|
496
|
-
}
|
|
491
|
+
depositMap.set(event.precommitment, event);
|
|
497
492
|
}
|
|
498
493
|
|
|
499
494
|
return depositMap;
|
|
@@ -626,7 +621,12 @@ export class AccountService {
|
|
|
626
621
|
scope: Hash,
|
|
627
622
|
depositEvents: Map<Hash, DepositEvent>
|
|
628
623
|
): void {
|
|
629
|
-
|
|
624
|
+
const MAX_CONSECUTIVE_MISSES = 10; // Large enough to avoid and tx failures
|
|
625
|
+
|
|
626
|
+
const foundIndices = new Set<bigint>();
|
|
627
|
+
let consecutiveMisses = 0;
|
|
628
|
+
|
|
629
|
+
for (let index = BigInt(0); ; index++) {
|
|
630
630
|
// Generate nullifier, secret, and precommitment for this index
|
|
631
631
|
const { nullifier, secret, precommitment } = this.createDepositSecrets(
|
|
632
632
|
scope,
|
|
@@ -637,9 +637,18 @@ export class AccountService {
|
|
|
637
637
|
const event = depositEvents.get(precommitment);
|
|
638
638
|
|
|
639
639
|
if (!event) {
|
|
640
|
-
|
|
640
|
+
consecutiveMisses++;
|
|
641
|
+
if (consecutiveMisses >= MAX_CONSECUTIVE_MISSES) {
|
|
642
|
+
break;
|
|
643
|
+
}
|
|
644
|
+
continue;
|
|
641
645
|
}
|
|
642
646
|
|
|
647
|
+
// Can reset counter in case if user had any tx failures for
|
|
648
|
+
// newer deposits
|
|
649
|
+
consecutiveMisses = 0;
|
|
650
|
+
foundIndices.add(index);
|
|
651
|
+
|
|
643
652
|
// Create a new pool account for this deposit
|
|
644
653
|
this.addPoolAccount(
|
|
645
654
|
scope,
|
|
@@ -650,6 +659,8 @@ export class AccountService {
|
|
|
650
659
|
event.blockNumber,
|
|
651
660
|
event.transactionHash
|
|
652
661
|
);
|
|
662
|
+
|
|
663
|
+
this.logger.debug(`Found deposit at index ${index} for scope ${scope}`);
|
|
653
664
|
}
|
|
654
665
|
}
|
|
655
666
|
|