Skip to content

Commit

Permalink
refactor: publishOffer delete exited seats before writing
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Jul 13, 2023
1 parent 7dc1a87 commit c47eec7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/inter-protocol/src/auction/offerBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ export const prepareScaledBidBook = (baggage, makeRecorderKit) => {
publishOffer(record) {
const key = toScaledRateOfferKey(record.bidScaling, record.seqNum);

// users can exit seats
if (record.seat.hasExited()) {
this.self.delete(key);
return;
}

return E(getBidDataRecorder(key)).write(
harden({
bidScaling: record.bidScaling,
Expand Down Expand Up @@ -290,6 +296,12 @@ export const preparePriceBook = (baggage, makeRecorderKit) => {
publishOffer(record) {
const key = toPriceOfferKey(record.price, record.seqNum);

// users can exit seats
if (record.seat.hasExited()) {
this.self.delete(key);
return;
}

return E(getBidDataRecorder(key)).write(
harden({
price: record.price,
Expand Down

0 comments on commit c47eec7

Please sign in to comment.