// Add writes an effect to the database while automatically tracking the index // to use. func (ei *EffectIngestion) Add(aid xdr.AccountId, typ history.EffectType, details interface{}) bool { if ei.err != nil { return false } ei.added++ var haid int64 haid, ei.err = ei.Accounts.Get(aid.Address()) if ei.err != nil { return false } ei.err = ei.Dest.Effect(haid, ei.OperationID, ei.added, typ, details) if ei.err != nil { return false } return true }
func (is *Session) tradeDetails(buyer, seller xdr.AccountId, claim xdr.ClaimOfferAtom) (bd map[string]interface{}, sd map[string]interface{}) { bd = map[string]interface{}{ "offer_id": claim.OfferId, "seller": seller.Address(), "bought_amount": amount.String(claim.AmountSold), "sold_amount": amount.String(claim.AmountBought), } is.assetDetails(bd, claim.AssetSold, "bought_") is.assetDetails(bd, claim.AssetBought, "sold_") sd = map[string]interface{}{ "offer_id": claim.OfferId, "seller": buyer.Address(), "bought_amount": amount.String(claim.AmountBought), "sold_amount": amount.String(claim.AmountSold), } is.assetDetails(sd, claim.AssetBought, "bought_") is.assetDetails(sd, claim.AssetSold, "sold_") return }
// Operation ingests the provided operation data into a new row in the // `history_operations` table func (ingest *Ingestion) Operation( id int64, txid int64, order int32, source xdr.AccountId, typ xdr.OperationType, details map[string]interface{}, ) error { djson, err := json.Marshal(details) if err != nil { return err } sql := ingest.operations.Values(id, txid, order, source.Address(), typ, djson) _, err = ingest.DB.Exec(sql) if err != nil { return err } return nil }