Skip to content

Commit

Permalink
refactor: DRY on cleanup when bids are deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Jul 21, 2023
1 parent 79a4753 commit 33d8e17
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions packages/inter-protocol/src/auction/offerBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ export const prepareScaledBidBook = (baggage, makeRecorderKit) => {
delete(key) {
const { records } = this.state;
void deleteNodeIfPresent(key);
bidDataKits.delete(key);
if (bidDataKits.has(key)) {
bidDataKits.delete(key);
}
records.delete(key);
},
updateReceived(key, sold) {
Expand All @@ -205,11 +207,7 @@ export const prepareScaledBidBook = (baggage, makeRecorderKit) => {
for (const [key, { seat }] of records.entries()) {
if (!seat.hasExited()) {
seat.exit();
if (bidDataKits.has(key)) {
bidDataKits.delete(key);
}
records.delete(key);
void deleteNodeIfPresent(key);
this.self.delete(key);
}
}
},
Expand Down Expand Up @@ -334,7 +332,9 @@ export const preparePriceBook = (baggage, makeRecorderKit) => {
delete(key) {
const { records } = this.state;
void deleteNodeIfPresent(key);
bidDataKits.delete(key);
if (bidDataKits.has(key)) {
bidDataKits.delete(key);
}
records.delete(key);
},
updateReceived(key, sold) {
Expand All @@ -353,11 +353,7 @@ export const preparePriceBook = (baggage, makeRecorderKit) => {
for (const [key, { seat }] of records.entries()) {
if (!seat.hasExited()) {
seat.exit();
if (bidDataKits.has(key)) {
bidDataKits.delete(key);
}
void deleteNodeIfPresent(key);
records.delete(key);
this.self.delete(key);
}
}
},
Expand Down

0 comments on commit 33d8e17

Please sign in to comment.