Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map out offer input and output data structures for CLI #25

Closed
Isaiah-Turner opened this issue Jul 6, 2020 · 2 comments
Closed

Map out offer input and output data structures for CLI #25

Isaiah-Turner opened this issue Jul 6, 2020 · 2 comments
Assignees

Comments

@Isaiah-Turner
Copy link
Contributor

What

We need to map out what information we get about offers from the new ingestion system. We also need to know what the output to BigQuery should look like. Part of #19.

Why

This issue helps us know what information about offers we can get from the ingestion system and what information may have to be reconstructed or omitted.

@Isaiah-Turner
Copy link
Contributor Author

There are two different ways to get the information on Offers. The first is to use a LedgerTransactionReader and read
in Transactions one at a time. Then for each transaction, by looking at the Offers and their types, we can isolate what is relevant to offers. The Operation types that affect offers are: OperationTypeManageSellOffer (3), OperationTypeCreatePassiveSellOffer (4), and OperationTypeManageBuyOffer (12). Keeping track of these operations would allow us to create a list of offer operations and their timestamps. We also can use MakeSingleLedgerStateReader() to get the changes in a given ledger. Each change has a type, the relevant one being LedgerEntryTypeOffer. It also contains the LedgerEntry for before and after. This allows us to reconstruct the offer table in BigQuery.
For a given change of the correct type, we can do offer := change.Post.Data.Offer to get offer data in the ledger.
In order reconstruct the table, we need a struct with the following fields:

seller_id: string - get from offer.SellerId.GetAddress()
offer_id: integer - get from offer.OfferId
selling_asset: string - get from offer.Selling; call on xdr.MarshalBase64() on the asset to put into table
buying_asset: string  - get from offer.Buying; call xdr.MarshalBase64() on the asset to put into table
amount: integer - get from offer.Amount
price_fraction: Price struct - get from offer.Price
price: float - get from offer.Price.N/offer.Price.D
flags: integer - get from offer.Flags
last_modified_ledger: integer - get from change.Post.LastModifiedLedgerSeq
deleted: boolean - should be false if there is information in change.Post, true otherwise

@debnil
Copy link
Contributor

debnil commented Jul 13, 2020

Sweet, this looks great!

@debnil debnil closed this as completed Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants