|
@@ -16,7 +16,7 @@ namespace PCC.App.Tpm;
|
|
|
|
|
|
// ACK: SHA256(incoming payload)
|
|
|
|
|
|
-public abstract class TrustedPeerManager(IPeerInfoProvider peerInfoProvider, IEventBus eventBus, ILogger<TrustedPeerManager> logger, ILogger<KestrelTcpServer> ktsLogger) : IAssemblyInjectSyncInitStarStop<TrustedPeerManager>
|
|
|
+public abstract class TrustedPeerManager(IEventBus eventBus, ILogger<TrustedPeerManager> logger, ILogger<KestrelTcpServer> ktsLogger) : IAssemblyInjectSyncInitStarStop<TrustedPeerManager>
|
|
|
{
|
|
|
private const int NONCE_LENGTH_BYTES = 16;
|
|
|
private const int NONCE_EXPIRE_SECOND = 60;
|
|
@@ -30,18 +30,11 @@ public abstract class TrustedPeerManager(IPeerInfoProvider peerInfoProvider, IEv
|
|
|
|
|
|
public void Init()
|
|
|
{
|
|
|
+ _nonceManager = new(NONCE_LENGTH_BYTES - TimestampNonceManager.TimestampLength, TimeSpan.FromMicroseconds(NONCE_EXPIRE_SECOND), TimeSpan.FromSeconds(NONCE_SKEW_SECOND));
|
|
|
}
|
|
|
|
|
|
public void Start()
|
|
|
{
|
|
|
- _nonceManager = new(NONCE_LENGTH_BYTES - TimestampNonceManager.TimestampLength, TimeSpan.FromMicroseconds(NONCE_EXPIRE_SECOND), TimeSpan.FromSeconds(NONCE_SKEW_SECOND));
|
|
|
-
|
|
|
- foreach (var item in peerInfoProvider.PeerInfo)
|
|
|
- {
|
|
|
- _localPeers[item.PeerId] = new LocalPeerManager(_connectionContextFactory, _nonceManager, item, eventBus, logger, ktsLogger);
|
|
|
- }
|
|
|
-
|
|
|
- foreach (var item in _localPeers.Values) item.Start();
|
|
|
}
|
|
|
|
|
|
public void Stop()
|
|
@@ -56,7 +49,7 @@ public abstract class TrustedPeerManager(IPeerInfoProvider peerInfoProvider, IEv
|
|
|
public void AddOrReplaceLocalPeer(ILocalPeerInfo localPeerInfo)
|
|
|
{
|
|
|
RemoveLocalPeer(localPeerInfo.PeerId);
|
|
|
- var newLocal = _localPeers[localPeerInfo.PeerId] = new LocalPeerManager(_connectionContextFactory, _nonceManager, localPeerInfo, eventBus, logger, ktsLogger);
|
|
|
+ var newLocal = _localPeers[localPeerInfo.PeerId] = new LocalPeerManager(_connectionContextFactory, _nonceManager!, localPeerInfo, eventBus, logger, ktsLogger);
|
|
|
Task.Run(newLocal.Start);
|
|
|
}
|
|
|
|