Skip to content

Commit

Permalink
Invoke OnReorg with onReorgEventArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Suho committed Aug 5, 2020
1 parent 851569b commit c736c78
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Libplanet/Blockchain/BlockChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1293,12 +1293,20 @@ IEnumerable<TxId> GetTxIdsWithRange(BlockChain<T> chain, Block<T> start, Block<T
Hash = other.Tip.Hash,
Index = other.Tip.Index,
};

var onReorgEventArgs = new OnReorgEventArgs
{
oldTip = Tip,
newTip = other.Tip,
branchPoint = topmostCommon,
};

Guid obsoleteId = Id;
Id = other.Id;
Store.SetCanonicalChainId(Id);
_blocks = new BlockSet<T>(Store);
TipChanged?.Invoke(this, tipChangedEventArgs);
OnReorg?.Invoke(this, new OnReorgEventArgs());
OnReorg?.Invoke(this, onReorgEventArgs);
_transactions = new TransactionSet<T>(Store);
Store.DeleteChainId(obsoleteId);
}
Expand Down Expand Up @@ -1579,6 +1587,11 @@ public class TipChangedEventArgs : EventArgs
/// </summary>
public class OnReorgEventArgs : EventArgs
{
public Block<T> oldTip { get; set; }

public Block<T> newTip { get; set; }

public Block<T> branchPoint { get; set; }
}
}
}

0 comments on commit c736c78

Please sign in to comment.