Skip to content

Commit

Permalink
Call OnReorg when it reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Suho committed Aug 5, 2020
1 parent 8d81300 commit 851569b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Libplanet/Blockchain/BlockChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ bool render
/// </summary>
public event EventHandler<TipChangedEventArgs> TipChanged;

/// <summary>
/// An event which is invoked when <see cref="Tip"/> is changed.
/// </summary>
public event EventHandler<OnReorgEventArgs> OnReorg;

public IBlockPolicy<T> Policy { get; }

/// <summary>
Expand Down Expand Up @@ -1293,6 +1298,7 @@ IEnumerable<TxId> GetTxIdsWithRange(BlockChain<T> chain, Block<T> start, Block<T
Store.SetCanonicalChainId(Id);
_blocks = new BlockSet<T>(Store);
TipChanged?.Invoke(this, tipChangedEventArgs);
OnReorg?.Invoke(this, new OnReorgEventArgs());
_transactions = new TransactionSet<T>(Store);
Store.DeleteChainId(obsoleteId);
}
Expand Down Expand Up @@ -1567,5 +1573,12 @@ public class TipChangedEventArgs : EventArgs
/// </summary>
public HashDigest<SHA256> Hash { get; set; }
}

/// <summary>
/// Provides data for the <see cref="TipChanged"/> event.
/// </summary>
public class OnReorgEventArgs : EventArgs
{
}
}
}

0 comments on commit 851569b

Please sign in to comment.