Open tamirms opened 2 months ago
I prototyped the merge function here . However, I ran into a problem related to the specific order in which ledger entry changes are applied.
Changes within a ledger should be applied in the following order:
- fee changes of all transactions
- transaction meta changes of all transactions
- upgrade changes
So if we have two ledgers the order of application for those two ledgers will be:
However, if we try to merge ledgers 1 and 2 into a single ledger we can no longer maintain the ordering above and instead we will obtain the following order:
Given the importance of having the correct application order, I think we cannot proceed with combining several ledger objects into one. Instead, I think we'll need to refactor ingestion to support ingesting multiple ledgers within a single DB transaction as an approximation of having one large ledger which is the union of a bunch of smaller ledgers.
We want a function which takes two LedgerCloseMeta xdr objects and returns a LedgerCloseMeta object which includes all the transactions and meta from the two source LedgerCloseMeta xdr objects. The purpose of this function is to create ledgers with arbitrarily an large number of transactions. Instead of generating fake transactions and meta we can combine existing ledgers to create large ledgers.