From 45fe766dd592efd41eb84254a25255a177445aa0 Mon Sep 17 00:00:00 2001 From: Chris Hibbert Date: Fri, 21 Jul 2023 11:18:45 -0700 Subject: [PATCH] refactor: DRY on cleanup when bids are deleted --- .../inter-protocol/src/auction/offerBook.js | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/packages/inter-protocol/src/auction/offerBook.js b/packages/inter-protocol/src/auction/offerBook.js index 89081644688..0facad2ef58 100644 --- a/packages/inter-protocol/src/auction/offerBook.js +++ b/packages/inter-protocol/src/auction/offerBook.js @@ -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) { @@ -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); } } }, @@ -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) { @@ -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); } } },