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 transaction input and output data structures for CLI #43

Closed
Isaiah-Turner opened this issue Jul 7, 2020 · 1 comment
Closed
Assignees

Comments

@Isaiah-Turner
Copy link
Contributor

What

We need to map out what information we get about transactions 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 transaction information is easily accessible from the ingestion system and what information may have to be reconstructed or omitted.

@Isaiah-Turner
Copy link
Contributor Author

Isaiah-Turner commented Jul 9, 2020

In order to get transaction information, we would call getLedger with the sequence number of the desired ledger.
Then ledger.V0.LedgerHeader.TxSet.Tx gives a slice of TransactionEnvelope structs.
For a given envelope e, we can access the signatures by doing e.Signatures, and access the transaction by doing e.Tx. The transaction is defined as

type Transaction struct {
    SourceAccount MuxedAccount
    Fee           Uint32
    SeqNum        SequenceNumber
    TimeBounds    *TimeBounds
    Memo          Memo
    Operations    []Operation `xdrmaxsize:"100"`
    Ext           TransactionExt
}

In order to export the data to BigQuery, we need a struct with the following fields:

transaction_hash: string - get from ledger.V0.TxProcessing[index].Result.TransactionHash
ledger_sequence: integer - get from ledger sequence that was passed in to getLedger
application_order: integer - get from ledger.V0.TxProcessing, which is sorted in apply order
account: string - get from SourceAccount.ToAccountId()
account_sequence: integer - get from SeqNum
max_fee: integer - get from Fee
operation_count: integer - get from len(Operations)
created_at: timestamp - same as the close time of the parent ledger, which is in ledger.V0.LedgerHeader.ScpValue.CloseTime
updated_at: timestamp - Not sure about this one
memo_type: string - get from Memo.Type.String()
memo: string - get from Memo.Text
time_bounds: string - get from TimeBounds; format as "[minTime, maxTime)"
successful: boolean - get from ledger.V0.LedgerHeader.TxProcessing[index].Result.Successful()
fee_charged: integer - get from ledger.V0.LedgerHeader.TxProcessing[index].Result.FeeCharged

In order to connect the transaction result and the transaction itself, use a LedgerTransactionReader, which packages the transaction envelope, results, and fee changes. It allows for reading in this packaged data one transaction at a time. See Bartek's stats.go for an example.

In order to transform the xdr.Hash into a hex string, convert the Hash to a byte array and use
the EncodeToString function in the encoding/hex package.

Created and updated at times need to be converted to Unix timestamps, right now they are integers.
Use Unix function from time package to get a Time object; format as a UTC time

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

1 participant