Skip to content

Commit

Permalink
Minining on Sidechain members (#60)
Browse files Browse the repository at this point in the history
* Only use the federation members to mine

* Added handling of reorged blocks

* Removed some unnecessary null checks

* Set the federation debug file to Trace by default

* Added the recover cal to the setup Fiddler session
  • Loading branch information
bokobza authored and monsieurleberre committed Jun 21, 2018
1 parent b218d78 commit 3295f5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ public void CreateSession(CrossChainTransactionInfo crossChainTransactionInfo)
/// <inheritdoc/>>
public void ProcessBlock(Block block)
{
Guard.NotNull(block, nameof(block));
this.logger.LogTrace("({0}:'{1}')", nameof(block.GetHash), block.GetHash());

ChainedHeader newTip = this.concurrentChain.GetBlock(block.GetHash());
if (newTip == null)
{
this.logger.LogTrace("(-)[NEW_TIP_REORG]");
return;
}

var chainBlockTip = this.concurrentChain.GetBlock(block.GetHash());
int blockNumber = chainBlockTip.Height;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ internal sealed class BlockObserver : SignalObserver<Block>
/// <summary>
/// Initialize the block observer with the wallet manager and the cross chain monitor.
/// </summary>
/// <param name="crossChainTransactionMonitor"></param>
/// <param name="walletSyncManager">The wallet sync manager to pass new incoming blocks to.</param>
/// <param name="crossChainTransactionMonitor">The crosschain transaction monitor to pass new incoming blocks to.</param>
public BlockObserver(IFederationWalletSyncManager walletSyncManager, ICrossChainTransactionMonitor crossChainTransactionMonitor)
{
Guard.NotNull(walletSyncManager, nameof(walletSyncManager));
Expand All @@ -36,8 +37,8 @@ public BlockObserver(IFederationWalletSyncManager walletSyncManager, ICrossChain
/// <param name="block">The new block.</param>
protected override void OnNextCore(Block block)
{
crossChainTransactionMonitor?.ProcessBlock(block);
walletSyncManager?.ProcessBlock(block);
crossChainTransactionMonitor.ProcessBlock(block);
walletSyncManager.ProcessBlock(block);
}
}
}

0 comments on commit 3295f5a

Please sign in to comment.