Пример #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="config">Network configuration</param>
        /// <param name="aclLoader">ACL loader to define access</param>
        /// <param name="peerFactory">Factory to create peers from endpoints</param>
        /// <param name="peerListener">Listener to accept peer connections</param>
        /// <param name="peerMessageListener">PeerMessageListener</param>
        /// <param name="logger">Logger</param>
        public Server(
            NetworkConfig config,
            INetworkAclLoader aclLoader,
            IPeerFactory peerFactory,
            IPeerListener peerListener,
            IPeerMessageListener peerMessageListener,
            ILogger <Server> logger)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            _peerFactory  = peerFactory ?? throw new ArgumentNullException(nameof(peerFactory));
            _peerListener = peerListener ?? throw new ArgumentNullException(nameof(peerListener));

            if (aclLoader == null)
            {
                throw new ArgumentNullException(nameof(aclLoader));
            }
            _acl = aclLoader.Load(config.AclConfig) ?? NetworkAcl.Default;

            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
            _peerMessageListener = peerMessageListener ?? throw new ArgumentNullException(nameof(peerMessageListener));

            _peerListener.OnPeerConnected += PeerConnected;

            _connectedPeers = new ConcurrentBag <IPeer>();
            _failedPeers    = new List <IPEndPoint>();

            // TODO: Change after port forwarding implementation
            _peerEndPoints = config.PeerEndPoints;
        }
Пример #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="config">Network configuration</param>
        /// <param name="aclLoader">ACL loader to define access</param>
        /// <param name="peerFactory">Factory to create peers from endpoints</param>
        /// <param name="peerListener">Listener to accept peer connections</param>
        /// <param name="peerMessageListener">PeerMessageListener</param>
        /// <param name="serverContext">Server context</param>
        /// <param name="serverProcesses">Server processes</param>
        /// <param name="logger">Logger</param>
        public Server(
            NetworkConfig config,
            INetworkAclLoader aclLoader,
            IPeerFactory peerFactory,
            IPeerListener peerListener,
            IPeerMessageListener peerMessageListener,
            IServerContext serverContext,
            IEnumerable <IServerProcess> serverProcesses,
            ILogger <Server> logger)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            _peerFactory  = peerFactory ?? throw new ArgumentNullException(nameof(peerFactory));
            _peerListener = peerListener ?? throw new ArgumentNullException(nameof(peerListener));

            if (aclLoader == null)
            {
                throw new ArgumentNullException(nameof(aclLoader));
            }
            _acl = aclLoader.Load(config.AclConfig) ?? NetworkAcl.Default;

            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
            _peerMessageListener = peerMessageListener ?? throw new ArgumentNullException(nameof(peerMessageListener));
            _serverContext       = serverContext ?? throw new ArgumentNullException(nameof(serverContext));
            _serverProcesses     = serverProcesses ?? throw new ArgumentNullException(nameof(serverProcesses));

            _peerListener.OnPeerConnected += PeerConnected;

            // TODO #364: Change after port forwarding implementation
            _peerEndPoints = config.PeerEndPoints;
        }
Пример #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="config">Config</param>
        /// <param name="blockchain">Blockchain</param>
        /// <param name="logger">Logger</param>
        /// <param name="aclLoader">ACL Loader</param>
        public RpcServer(
            RpcConfig config,
            ILogger <RpcServer> logger,
            INetworkAclLoader aclLoader)
        {
            _config = config ?? throw new ArgumentNullException(nameof(config));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            if (aclLoader == null)
            {
                throw new ArgumentNullException(nameof(aclLoader));
            }
            _acl = aclLoader.Load(config.AclConfig) ?? NetworkAcl.Default;

            InjectSpecialParameter(ctx => ctx);
        }