Skip to content

Commit 3dcf7a6

Browse files
committed
fix(slasher): use a tx db when storing offenses
1 parent 4ffdee5 commit 3dcf7a6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

yarn-project/slasher/src/stores/offenses_store.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ export class SlasherOffensesStore {
7676
/** Adds a new offense (defaults to pending, but will be slashed if markAsSlashed had been called for it) */
7777
public async addPendingOffense(offense: Offense): Promise<void> {
7878
const key = this.getOffenseKey(offense);
79-
await this.offenses.set(key, serializeOffense(offense));
8079
const round = getRoundForOffense(offense, this.settings);
81-
await this.roundsOffenses.set(this.getRoundKey(round), key);
80+
await this.kvStore.transactionAsync(async () => {
81+
await this.offenses.set(key, serializeOffense(offense));
82+
await this.roundsOffenses.set(this.getRoundKey(round), key);
83+
});
8284
this.log.trace(`Adding pending offense ${key} for round ${round}`);
8385
}
8486

0 commit comments

Comments
 (0)