diff --git a/ingest/change.go b/ingest/change.go index 57c2328ce4..727c69f1cc 100644 --- a/ingest/change.go +++ b/ingest/change.go @@ -18,12 +18,13 @@ import ( // If an entry is removed: Pre is not nil and Post is nil. // If this change is caused by a operation in a transaction, include the operation information. Wont work when changes are compacted type Change struct { - Type xdr.LedgerEntryType - Pre *xdr.LedgerEntry - Post *xdr.LedgerEntry - reason LedgerEntryChangeReason - TransactionData *TransactionEnvelopeAndResult - operationInfo *OperationInfo + Type xdr.LedgerEntryType + Pre *xdr.LedgerEntry + Post *xdr.LedgerEntry + Reason LedgerEntryChangeReason + operationIdx uint32 + tx *LedgerTransaction + lcm *xdr.LedgerCloseMeta } type LedgerEntryChangeReason uint16 diff --git a/ingest/ledger_change_reader.go b/ingest/ledger_change_reader.go index 4cd030c66d..3a53402e49 100644 --- a/ingest/ledger_change_reader.go +++ b/ingest/ledger_change_reader.go @@ -188,7 +188,8 @@ func (r *LedgerChangeReader) Read() (Change, error) { Type: entry.Data.Type, Pre: &entry, Post: nil, - reason: Eviction, + Reason: Eviction, + lcm: &r.lcm, } } sortChanges(changes) @@ -202,7 +203,8 @@ func (r *LedgerChangeReader) Read() (Change, error) { r.LedgerTransactionReader.lcm.UpgradesProcessing()[r.upgradeIndex].Changes, ) for _, change := range changes { - change.reason = ProtocolUpgrade // Is there any other information that we can add here? + change.Reason = ProtocolUpgrade // Is there any other information that we can add here? + change.lcm = &r.lcm } r.pending = append(r.pending, changes...) r.upgradeIndex++ diff --git a/ingest/ledger_transaction.go b/ingest/ledger_transaction.go index 05b71b6652..1a9d9f3000 100644 --- a/ingest/ledger_transaction.go +++ b/ingest/ledger_transaction.go @@ -17,6 +17,7 @@ type LedgerTransaction struct { FeeChanges xdr.LedgerEntryChanges UnsafeMeta xdr.TransactionMeta LedgerVersion uint32 + lcm *xdr.LedgerCloseMeta // This is read-only and not to be modified by downstream functions } func (t *LedgerTransaction) txInternalError() bool { @@ -27,10 +28,10 @@ func (t *LedgerTransaction) txInternalError() bool { // connected to fees. func (t *LedgerTransaction) GetFeeChanges() []Change { changes := GetChangesFromLedgerEntryChanges(t.FeeChanges) - txData := &TransactionEnvelopeAndResult{Envelope: &t.Envelope, Result: &t.Result} for _, change := range changes { - change.reason = FeeChange - change.TransactionData = txData + change.Reason = FeeChange + change.tx = t + change.lcm = t.lcm } return changes } @@ -42,10 +43,10 @@ func (t *LedgerTransaction) GetFeeChanges() []Change { func (t *LedgerTransaction) getTransactionChanges(ledgerEntryChanges xdr.LedgerEntryChanges) []Change { changes := GetChangesFromLedgerEntryChanges(ledgerEntryChanges) - txData := &TransactionEnvelopeAndResult{Envelope: &t.Envelope, Result: &t.Result} for _, change := range changes { - change.reason = Transaction - change.TransactionData = txData + change.Reason = Transaction + change.tx = t + change.lcm = t.lcm } return changes } @@ -169,24 +170,14 @@ func (t *LedgerTransaction) operationChanges(ops []xdr.OperationMeta, index uint operationMeta := ops[index] changes := GetChangesFromLedgerEntryChanges(operationMeta.Changes) - op, found := t.GetOperation(index) - operationInfo := &OperationInfo{ - operationIdx: index, - operation: &op, - } - txData := &TransactionEnvelopeAndResult{Envelope: &t.Envelope, Result: &t.Result} - res := make([]Change, 0, len(changes)) for _, change := range changes { - if !found { - continue - } - change.operationInfo = operationInfo - change.reason = Operation - change.TransactionData = txData - res = append(res, change) + change.Reason = Operation + change.tx = t + change.operationIdx = index + change.lcm = t.lcm } - return res + return changes } // GetDiagnosticEvents returns all contract events emitted by a given operation. diff --git a/ingest/ledger_transaction_reader.go b/ingest/ledger_transaction_reader.go index 5d2ad1d237..b975299576 100644 --- a/ingest/ledger_transaction_reader.go +++ b/ingest/ledger_transaction_reader.go @@ -94,6 +94,7 @@ func (reader *LedgerTransactionReader) Read() (LedgerTransaction, error) { UnsafeMeta: reader.lcm.TxApplyProcessing(i), FeeChanges: reader.lcm.FeeProcessing(i), LedgerVersion: uint32(reader.lcm.LedgerHeaderHistoryEntry().Header.LedgerVersion), + lcm: &reader.lcm, }, nil }