src/Stratis.FederatedPeg.Features.FederationGateway/TargetChain/CrossChainTransferStore.cs
/// <summary>
/// Used to handle reorg (if required) and revert status from <see cref="CrossChainTransferStatus.SeenInBlock"/> to
/// <see cref="CrossChainTransferStatus.FullySigned"/>. Also returns a flag to indicate whether we are behind the current tip.
/// </summary>
/// <returns>Returns <c>true</c> if a rewind was performed and <c>false</c> otherwise.</returns>
Used to handle reorg (if required) and revert status from  to
. Also returns a flag to indicate whether we are behind the current tip.
Used to handle reorg ( if required ) and revert status from to . Also returns a flag to indicate whether we are behind the current tip .
private bool RewindIfRequired()
        {
            HashHeightPair tipToChase = this.TipToChase();
            if (tipToChase.Hash == this.TipHashAndHeight.HashBlock)
            {
                this.logger.LogTrace("(-)[SYNCHRONIZED]:false");
                return false;
            }
            if (this.chain.GetBlock(tipToChase.Hash) == null)
            {
                ICollection<uint256> locators = this.federationWalletManager.GetWallet().BlockLocator;
                var blockLocator = new BlockLocator { Blocks = locators.ToList() };
                ChainedHeader fork = this.chain.FindFork(blockLocator);
                this.federationWalletManager.RemoveBlocks(fork);
                tipToChase = this.TipToChase();
            }
            if (this.TipHashAndHeight != null && (this.TipHashAndHeight.Height > tipToChase.Height ||
                this.chain.GetBlock(this.TipHashAndHeight.HashBlock)?.Height != this.TipHashAndHeight.Height))
            {
                ChainedHeader fork = this.chain.FindFork(this.TipHashAndHeight.GetLocator()) ?? this.chain.GetBlock(0);
                while (fork.Height > tipToChase.Height)
                    fork = fork.Previous;
                using (DBreeze.Transactions.Transaction dbreezeTransaction = this.DBreeze.GetTransaction())
                {
                    dbreezeTransaction.SynchronizeTables(transferTableName, commonTableName);
                    dbreezeTransaction.ValuesLazyLoadingIsOn = false;
                    ChainedHeader prevTip = this.TipHashAndHeight;
                    try
                    {
                        StatusChangeTracker tracker = this.OnDeleteBlocks(dbreezeTransaction, fork.Height);
                        this.SaveTipHashAndHeight(dbreezeTransaction, fork);
                        dbreezeTransaction.Commit();
                        this.UndoLookups(tracker);
                    }
                    catch (Exception err)
                    {
                        this.TipHashAndHeight = prevTip;
                        this.RollbackAndThrowTransactionError(dbreezeTransaction, err, "REWIND_ERROR");
                    }
                }
                this.ValidateCrossChainTransfers();
                return true;
            }
            return false;
        }
private bool RewindIfRequired ( ) { HashHeightPair tipToChase = this . TipToChase ( ) ; if ( tipToChase . Hash == this . TipHashAndHeight . HashBlock ) { this . logger . LogTrace ( " " ) ; return false ; } if ( this . chain . GetBlock ( tipToChase . Hash ) == null ) { ICollection < uint256 > locators = this . federationWalletManager . GetWallet ( ) . BlockLocator ; var blockLocator = new BlockLocator { Blocks = locators . ToList ( ) } ; ChainedHeader fork = this . chain . FindFork ( blockLocator ) ; this . federationWalletManager . RemoveBlocks ( fork ) ; tipToChase = this . TipToChase ( ) ; } if ( this . TipHashAndHeight != null && ( this . TipHashAndHeight . Height > tipToChase . Height || this . chain . GetBlock ( this . TipHashAndHeight . HashBlock ) ? . Height != this . TipHashAndHeight . Height ) ) { ChainedHeader fork = this . chain . FindFork ( this . TipHashAndHeight . GetLocator ( ) ) ?? this . chain . GetBlock ( 0 ) ; while ( fork . Height > tipToChase . Height ) fork = fork . Previous ; using ( DBreeze . Transactions . Transaction dbreezeTransaction = this . DBreeze . GetTransaction ( ) ) { dbreezeTransaction . SynchronizeTables ( transferTableName , commonTableName ) ; dbreezeTransaction . ValuesLazyLoadingIsOn = false ; ChainedHeader prevTip = this . TipHashAndHeight ; try { StatusChangeTracker tracker = this . OnDeleteBlocks ( dbreezeTransaction , fork . Height ) ; this . SaveTipHashAndHeight ( dbreezeTransaction , fork ) ; dbreezeTransaction . Commit ( ) ; this . UndoLookups ( tracker ) ; } catch ( Exception err ) { this . TipHashAndHeight = prevTip ; this . RollbackAndThrowTransactionError ( dbreezeTransaction , err , " " ) ; } } this . ValidateCrossChainTransfers ( ) ; return true ; } return false ; }
Used to handle reorg (if required) and revert status from  to
.
Used to handle reorg ( if required ) and revert status from to .
// Indicate that we are synchronized. // We are dependent on the wallet manager having dealt with any fork by now. // If the chain does not contain our tip. // We are ahead of the current chain or on the wrong chain. // Must not exceed wallet height otherise transaction validations may fail. // Restore expected store state in case the calling code retries / continues using the store. // Indicate that we are behind the current chain.
None