Skip to content

Commit

Permalink
Merge pull request #106 from pingpongsneak/master
Browse files Browse the repository at this point in the history
Fixes for preview 1
  • Loading branch information
pingpongsneak committed Aug 7, 2022
2 parents 7985304 + 3eeb093 commit 5f7bc07
Show file tree
Hide file tree
Showing 23 changed files with 1,023 additions and 243 deletions.
6 changes: 3 additions & 3 deletions core/Consensus/Blockmania.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Blockmania(Config cfg, ILogger logger)
// Self, Round, NodeCount, Nodes, TotalNodes,
// f, Quorumf1, Quorum2f, Quorum2f1);

_ = Task.Factory.StartNew(async () => { await RunAsync(_entries.Reader); });
_ = Task.Factory.StartNew(async () => { await Run(_entries.Reader); });
}

private void OnBlockmaniaDelivered(InterpretedEventArgs e)
Expand Down Expand Up @@ -515,12 +515,12 @@ private IMessage ProcessMessage(State s, ulong sender, ulong receiver, Block ori
///
/// </summary>
/// <param name="reader"></param>
private async Task RunAsync(ChannelReader<BlockGraph> reader)
private async Task Run(ChannelReader<BlockGraph> reader)
{
while (await reader.WaitToReadAsync())
while (reader.TryRead(out var data))
{
await _graphMutex.WaitOneAsync();
_graphMutex.WaitOne();
var entries = new Entry[data.Dependencies.Count];
var max = data.Block.Round;
var round = Round;
Expand Down
39 changes: 20 additions & 19 deletions core/CypherNetworkCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class CypherNetworkCore : ICypherNetworkCore
private ISync _sync;
private IMemoryPool _memoryPool;
private IWalletSession _walletSession;

/// <summary>
/// </summary>
/// <param name="applicationLifetime"></param>
Expand Down Expand Up @@ -151,7 +151,7 @@ public IValidator Validator()
}
catch (Exception ex)
{
_logger.Here().Error("{@Message}",ex.Message);
_logger.Here().Error("{@Message}", ex.Message);
}

return null;
Expand Down Expand Up @@ -188,12 +188,12 @@ public INodeWallet Wallet()
}
catch (Exception ex)
{
_logger.Here().Error("{@Message}",ex.Message);
_logger.Here().Error("{@Message}", ex.Message);
}

return null;
}

/// <summary>
///
/// </summary>
Expand All @@ -217,7 +217,7 @@ public IBroadcast Broadcast()
}
catch (Exception ex)
{
_logger.Here().Error("{@Message}",ex.Message);
_logger.Here().Error("{@Message}", ex.Message);
}

return null;
Expand All @@ -236,7 +236,7 @@ public ICrypto Crypto()
}
catch (Exception ex)
{
_logger.Here().Error("{@Message}",ex.Message);
_logger.Here().Error("{@Message}", ex.Message);
}

return null;
Expand All @@ -255,7 +255,7 @@ public IP2PDevice P2PDevice()
}
catch (Exception ex)
{
_logger.Here().Error("{@Message}",ex.Message);
_logger.Here().Error("{@Message}", ex.Message);
}

return null;
Expand All @@ -278,11 +278,12 @@ private void Init()
var keyPair = AsyncHelper.RunSync(() => crypto.GetOrUpsertKeyNameAsync(AppOptions.Network.SigningKeyRingName));
KeyPair = new KeyPair
{
PrivateKey = keyPair.PrivateKey.ByteToHex().ToSecureString(), PublicKey = keyPair.PublicKey
PrivateKey = keyPair.PrivateKey.ByteToHex().ToSecureString(),
PublicKey = keyPair.PublicKey
};
keyPair.PrivateKey.Destroy();
}

/// <summary>
///
/// </summary>
Expand All @@ -297,7 +298,7 @@ private IUnitOfWork GetUnitOfWork()
}
catch (Exception ex)
{
_logger.Here().Error("{@Message}",ex.Message);
_logger.Here().Error("{@Message}", ex.Message);
}

return null;
Expand All @@ -322,7 +323,7 @@ private IPeerDiscovery GetPeerDiscovery()

return null;
}

/// <summary>
/// </summary>
/// <returns></returns>
Expand All @@ -336,12 +337,12 @@ private IPPoS GetPPoS()
}
catch (Exception ex)
{
_logger.Here().Error("{@Message}",ex.Message);
_logger.Here().Error("{@Message}", ex.Message);
}

return null;
}

/// <summary>
///
/// </summary>
Expand All @@ -361,7 +362,7 @@ private IGraph GetGraph()

return null;
}

/// <summary>
///
/// </summary>
Expand All @@ -376,12 +377,12 @@ private ISync GetSync()
}
catch (Exception ex)
{
_logger.Here().Error("{@Message}",ex.Message);
_logger.Here().Error("{@Message}", ex.Message);
}

return null;
}

/// <summary>
///
/// </summary>
Expand All @@ -396,12 +397,12 @@ private IMemoryPool GetMemPool()
}
catch (Exception ex)
{
_logger.Here().Error("{@Message}",ex.Message);
_logger.Here().Error("{@Message}", ex.Message);
}

return null;
}

/// <summary>
///
/// </summary>
Expand All @@ -416,7 +417,7 @@ private IWalletSession GetWalletSession()
}
catch (Exception ex)
{
_logger.Here().Error("{@Message}",ex.Message);
_logger.Here().Error("{@Message}", ex.Message);
}

return null;
Expand Down
6 changes: 3 additions & 3 deletions core/Helper/AsyncHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ namespace CypherNetwork.Helper;
/// </summary>
public static class AsyncHelper
{
private static readonly TaskFactory MyTaskFactory = new(CancellationToken.None,
TaskCreationOptions.None,
TaskContinuationOptions.None,
private static readonly TaskFactory MyTaskFactory = new(CancellationToken.None,
TaskCreationOptions.None,
TaskContinuationOptions.None,
TaskScheduler.Default);

/// <summary>
Expand Down

0 comments on commit 5f7bc07

Please sign in to comment.