using PCC.App.Tpm; using PCC.Common.AssemblyInject.Interfaces; using PCC.DevShared.Configuration; namespace PCC.DevShared; public class DevPeerInfoProviderBase(PccDevConfigManagerBase config) : IPeerInfoProvider, IAssemblyInjectSyncInitStarStop { private ICollection? _peerInfo; public ICollection? PeerInfo { get { if(_peerInfo == null) Start(); return _peerInfo; } private set => _peerInfo = value; } public void Init() { } public void Start() { if (_peerInfo != null) return; var conf = config.Instance; var mPri = conf.MyKeyPrivate; var mPub = conf.MyKeyPublic; var mLisA = conf.ListenAddress; var mLisP = conf.ListenPort; var tPub = conf.TrustPeerKeyPub; var tLisA = conf.TrustPeerHost; var tLisP = conf.TrustPeerPort; if (new object[] { mPri, mPub, mLisA, mLisP, tPub, tLisA, tLisP }.Any(p => p == null)) { PeerInfo = []; return; } var remote = new RemotePeerInfo(Convert.FromBase64String(tPub), tLisA, tLisP.Value); var local = new LocalPeerInfo( Convert.FromBase64String(mPub), Convert.FromBase64String(mPri), mLisA, mLisP.Value, [remote] ); PeerInfo = [local]; } public void Stop() { } }