Skip to content

Commit

Permalink
added logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tbssajal committed Oct 18, 2022
1 parent aaa00af commit d3f354b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Lachain.Networking/NetworkManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,18 @@ public void ConnectValidatorChannel(List<ECDSAPublicKey> validators)
_hubConnector.DisconnectValidators(
validatorsToDisconnect.Select(pubKey => pubKey.EncodeCompressed()).Flatten().ToArray()
);
Logger.LogTrace(
$"Disconnected validators: [{string.Join(", ", validatorsToDisconnect.Select(k => k.ToHex()))}] from validator channel"
);

var validatorsToConnect = RemovePublicKeys(validators, _connectedValidators);
_hubConnector.StartValidatorChannel(
validatorsToConnect.Select(pubKey => pubKey.EncodeCompressed()).Flatten().ToArray()
);
Logger.LogTrace(
$"Connected to validator channel with validators: [{string.Join(", ", validatorsToConnect.Select(k => k.ToHex()))}]"
);

foreach (var publicKey in validatorsToConnect)
{
GetClientWorker(publicKey)?.SetValidator(true);
Expand All @@ -117,6 +124,8 @@ public void DisconnectValidatorChannel()
{
if (!_started) return;

Logger.LogTrace("Disconnecting from validator channel");

foreach (var publicKey in _connectedValidators)
{
GetClientWorker(publicKey)?.SetValidator(false);
Expand All @@ -125,6 +134,9 @@ public void DisconnectValidatorChannel()
_connectedValidators.Clear();

_hubConnector.StopValidatorChannel();
Logger.LogTrace(
$"Disconnected validators: [{string.Join(", ", _connectedValidators.Select(k => k.ToHex()))}] from validator channel"
);
}

// both input lists need to be sorted and no duplicate element allowed
Expand Down

0 comments on commit d3f354b

Please sign in to comment.