src/Stratis.FederatedPeg.Features.FederationGateway/TargetChain/CrossChainTransferStore.cs
/// <summary>
/// Forgets transfer information for the blocks being removed and returns information for updating the transient lookups.
/// </summary>
/// <param name="dbreezeTransaction">The DBreeze transaction context to use.</param>
/// <param name="lastBlockHeight">The last block to retain.</param>
/// <returns>A tracker with all the cross chain transfers that were affected.</returns>
Forgets transfer information for the blocks being removed and returns information for updating the transient lookups.
Forgets transfer information for the blocks being removed and returns information for updating the transient lookups .
private StatusChangeTracker OnDeleteBlocks(DBreeze.Transactions.Transaction dbreezeTransaction, int lastBlockHeight)
        {
            var depositIds = new HashSet<uint256>();
            uint256[] blocksToRemove = this.blockHeightsByBlockHash.Where(a => a.Value > lastBlockHeight).Select(a => a.Key).ToArray();
            foreach (HashSet<uint256> deposits in blocksToRemove.Select(a => this.depositIdsByBlockHash[a]))
            {
                depositIds.UnionWith(deposits);
            }
            var tracker = new StatusChangeTracker();
            CrossChainTransfer[] crossChainTransfers = this.Get(dbreezeTransaction, depositIds.ToArray());
            foreach (CrossChainTransfer transfer in crossChainTransfers)
            {
                if (transfer.DepositHeight == null)
                {
                    tracker.SetTransferStatus(transfer);
                    this.DeleteTransfer(dbreezeTransaction, transfer);
                }
                else
                {
                    tracker.SetTransferStatus(transfer, CrossChainTransferStatus.FullySigned);
                    this.PutTransfer(dbreezeTransaction, transfer);
                }
            }
            return tracker;
        }
private StatusChangeTracker OnDeleteBlocks ( DBreeze . Transactions . Transaction dbreezeTransaction , int lastBlockHeight ) { var depositIds = new HashSet < uint256 > ( ) ; uint256 [ ] blocksToRemove = this . blockHeightsByBlockHash . Where ( a => a . Value > lastBlockHeight ) . Select ( a => a . Key ) . ToArray ( ) ; foreach ( HashSet < uint256 > deposits in blocksToRemove . Select ( a => this . depositIdsByBlockHash [ a ] ) ) { depositIds . UnionWith ( deposits ) ; } var tracker = new StatusChangeTracker ( ) ; CrossChainTransfer [ ] crossChainTransfers = this . Get ( dbreezeTransaction , depositIds . ToArray ( ) ) ; foreach ( CrossChainTransfer transfer in crossChainTransfers ) { if ( transfer . DepositHeight == null ) { tracker . SetTransferStatus ( transfer ) ; this . DeleteTransfer ( dbreezeTransaction , transfer ) ; } else { tracker . SetTransferStatus ( transfer , CrossChainTransferStatus . FullySigned ) ; this . PutTransfer ( dbreezeTransaction , transfer ) ; } } return tracker ; }
Forgets transfer information for the blocks being removed and returns information for updating the transient lookups.
Forgets transfer information for the blocks being removed and returns information for updating the transient lookups .
// Gather all the deposit ids that may have had transactions in the blocks being deleted. // Find the transfers related to these deposit ids in the database. // Transfers that only exist in the DB due to having been seen in a block should be removed completely. // Trigger deletion from the status lookup. // Delete the transfer completely. // Transaction is no longer seen. // Write the transfer status to the database.
A tracker with all the cross chain transfers that were affected.
A tracker with all the cross chain transfers that were affected .
dbreezeTransaction
DBreeze.Transactions.Transaction
The DBreeze transaction context to use.
The DBreeze transaction context to use .
lastBlockHeight
int
The last block to retain.
The last block to retain .