Skip to content

Commit

Permalink
Fix flags for offerEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikiyer56 committed Nov 15, 2024
1 parent 410b29e commit 9a54e6d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
21 changes: 10 additions & 11 deletions ingest/offers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ const (

// Base struct with common fields for all offer events.
type OfferEventData struct {
SellerId string
OfferID int64

BuyingAsset xdr.Asset
SellingAsset xdr.Asset

RemainingAmount int64 // Remaining amount that still needs to be filled for this offer
PriceN int32
PriceD int32

SellerId string
OfferID int64
BuyingAsset xdr.Asset
SellingAsset xdr.Asset
RemainingAmount int64 // Remaining amount that still needs to be filled for this offer
PriceN int32
PriceD int32
Flags int32
IsPassive bool
LastModifiedLedger uint32
Sponsor null.String
Expand Down Expand Up @@ -108,7 +106,8 @@ func populateOfferData(e *xdr.LedgerEntry) OfferEventData {
RemainingAmount: int64(offer.Amount),
PriceN: int32(offer.Price.N),
PriceD: int32(offer.Price.D),
IsPassive: (offer.Flags & 0x1) != 0,
Flags: int32(offer.Flags),
IsPassive: int32(offer.Flags) == int32(xdr.OfferEntryFlagsPassiveFlag),
LastModifiedLedger: uint32(e.LastModifiedLedgerSeq),
Sponsor: utils.LedgerEntrySponsorToNullString(*e),
}
Expand Down
29 changes: 12 additions & 17 deletions services/horizon/internal/ingest/processors/offers_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,19 @@ func (p *OffersProcessor) ProcessChange(ctx context.Context, change ingest.Chang

}

func (p *OffersProcessor) offerEventToRow(event offers.OfferEventData) history.Offer {
flags := int32(0)
if event.IsPassive {
flags = 1
}

func (p *OffersProcessor) offerEventToRow(e offers.OfferEventData) history.Offer {
return history.Offer{
SellerID: event.SellerId,
OfferID: event.OfferID,
SellingAsset: event.SellingAsset,
BuyingAsset: event.BuyingAsset,
Amount: event.RemainingAmount,
Pricen: event.PriceN,
Priced: event.PriceD,
Price: float64(event.PriceN) / float64(event.PriceD),
Flags: flags,
LastModifiedLedger: event.LastModifiedLedger,
Sponsor: event.Sponsor,
SellerID: e.SellerId,
OfferID: e.OfferID,
SellingAsset: e.SellingAsset,
BuyingAsset: e.BuyingAsset,
Amount: e.RemainingAmount,
Pricen: e.PriceN,
Priced: e.PriceD,
Price: float64(e.PriceN) / float64(e.PriceD),
Flags: e.Flags,
LastModifiedLedger: e.LastModifiedLedger,
Sponsor: e.Sponsor,
}
}

Expand Down

0 comments on commit 9a54e6d

Please sign in to comment.