What does the field PreviousTxnID refer to? Does it refer to the most recent transaction? Not sure what it specifically means. Help would be appreciated.
1 Answer
The PreviousTxnID
field has two uses. One is in transactions, is deprecated, and should never be used. So let's forget about that.
The other one is in ledger entries. The PreviousTxnID
field appears in ledger entries, along with the PreviousTxnLgrSeq
field, that are "threaded". Threaded ledger entries maintain a thread of transactions that affected them to allow their state to be walked backwards.
So, for example, say you look at an Offer
ledger entry. You will see PreviousTxnID
and previousTxnLgrSeq
fields that identify the ID and ledger sequence number of the last transaction to affect that entry. If you look at the metadata for that transaction, you will find out how that transaction affected this ledger entry and you will get the old values of these fields. With the old values, you can walk the thread back to the previous transaction and so on to see the history of the ledger entry.
When an Offer
entry is removed, it is threaded to the AccountRoot
of its owner. This prevents the thread from being lost and allows you to walk an AccountRoot
s thread to find all the Offer
s it owned.
This was a very early feature added to the ledger in 2012 and was intended to make it easier for light clients to walk the ledger's transaction history without having to trust a server.