コード例 #1
0
 /// <summary>Constructor used by dependency injection.</summary>
 public PeerAddressManager(DataFolder peerFilePath, ILoggerFactory loggerFactory)
 {
     this.loggerFactory = loggerFactory;
     this.logger        = loggerFactory.CreateLogger(this.GetType().FullName);
     this.Peers         = new ConcurrentDictionary <IPEndPoint, PeerAddress>();
     this.PeerFilePath  = peerFilePath;
     this.PeerSelector  = new PeerSelector(this.loggerFactory, this.Peers);
 }
コード例 #2
0
 /// <summary>Constructor used by dependency injection.</summary>
 public PeerAddressManager(IDateTimeProvider dateTimeProvider, DataFolder peerFilePath, ILoggerFactory loggerFactory, ISelfEndpointTracker selfEndpointTracker)
 {
     this.dateTimeProvider      = dateTimeProvider;
     this.logger                = loggerFactory.CreateLogger(this.GetType().FullName);
     this.peerInfoByPeerAddress = new ConcurrentDictionary <IPEndPoint, PeerAddress>();
     this.PeerFilePath          = peerFilePath;
     this.PeerSelector          = new PeerSelector(this.dateTimeProvider, loggerFactory, this.peerInfoByPeerAddress, selfEndpointTracker);
     this.fileStorage           = new FileStorage <List <PeerAddress> >(this.PeerFilePath.AddressManagerFilePath);
 }
コード例 #3
0
        public Node(Config conf, int id, CngKey key, Peer[] participants, IStore store, ITransport trans, IAppProxy proxy, ILogger loggerIn)

        {
            logger = loggerIn.AddNamedContext("Node", id.ToString());

            LocalAddr = trans.LocalAddr;

            var(pmap, _) = store.Participants();

            commitCh        = new AsyncProducerConsumerQueue <Block>(400);
            commitChMonitor = new AsyncMonitor();

            Controller   = new Controller(id, key, pmap, store, commitCh, logger);
            coreLock     = new AsyncLock();
            PeerSelector = new RandomPeerSelector(participants, LocalAddr);

            selectorLock = new AsyncLock();
            Id           = id;
            Store        = store;
            Conf         = conf;



            Trans = trans;

            netCh        = trans.Consumer;
            netChMonitor = new AsyncMonitor();

            Proxy = proxy;

            this.participants = participants;

            submitCh        = proxy.SubmitCh();
            submitChMonitor = new AsyncMonitor();

            controlTimer = ControlTimer.NewRandomControlTimer(conf.HeartbeatTimeout);

            nodeState = new NodeState();

            //Initialize as Babbling
            nodeState.SetStarting(true);
            nodeState.SetState(NodeStateEnum.Babbling);
        }