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 a29a826 commit 45fe766
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 @@ -190,7 +190,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 @@ -209,11 +211,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 @@ -338,7 +336,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 @@ -357,11 +357,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 45fe766

Please sign in to comment.