Exemplo n.º 1
0
 public void Initialize()
 {
     _config      = new DiscoveryConfigurationProvider(new NetworkHelper(NullLogger.Instance));
     _farAddress  = new IPEndPoint(IPAddress.Parse("192.168.1.2"), 1);
     _nearAddress = new IPEndPoint(IPAddress.Parse(_config.MasterExternalIp), _config.MasterPort);
     _messageSerializationService = Build.A.SerializationService().WithDiscovery(_privateKey).TestObject;
 }
        public NodeDistanceCalculator(IDiscoveryConfigurationProvider configurationProvider)
        {
            IDiscoveryConfigurationProvider configurationProvider1 = configurationProvider;

            _maxDistance = configurationProvider1.BucketsCount;
            _bitsPerHoop = configurationProvider1.BitsPerHop;
        }
Exemplo n.º 3
0
 public NodesLocator(INodeTable nodeTable, IDiscoveryManager discoveryManager, IDiscoveryConfigurationProvider configurationProvider, ILogger logger)
 {
     _nodeTable             = nodeTable;
     _discoveryManager      = discoveryManager;
     _configurationProvider = configurationProvider;
     _logger = logger;
 }
Exemplo n.º 4
0
 public DiscoveryStorage(IDiscoveryConfigurationProvider configurationProvider, INodeFactory nodeFactory, ILogger logger, IPerfService perfService)
 {
     _configurationProvider = configurationProvider;
     _nodeFactory           = nodeFactory;
     _logger      = logger;
     _perfService = perfService;
     _db          = new FullDbOnTheRocks(Path.Combine(_configurationProvider.DbBasePath, FullDbOnTheRocks.DiscoveryNodesDbPath));
 }
Exemplo n.º 5
0
 public NodeTable(IDiscoveryConfigurationProvider configurationProvider, INodeFactory nodeFactory, IKeyStore keyStore, ILogger logger, INodeDistanceCalculator nodeDistanceCalculator)
 {
     _configurationProvider = configurationProvider;
     _nodeFactory           = nodeFactory;
     _keyStore = keyStore;
     _logger   = logger;
     _nodeDistanceCalculator = nodeDistanceCalculator;
 }
 public NodeLifecycleManagerFactory(INodeFactory nodeFactory, INodeTable nodeTable, ILogger logger, IDiscoveryConfigurationProvider discoveryConfigurationProvider, IDiscoveryMessageFactory discoveryMessageFactory, IEvictionManager evictionManager, INodeStatsProvider nodeStatsProvider)
 {
     _nodeFactory = nodeFactory;
     _nodeTable   = nodeTable;
     _logger      = logger;
     _discoveryConfigurationProvider = discoveryConfigurationProvider;
     _discoveryMessageFactory        = discoveryMessageFactory;
     _evictionManager   = evictionManager;
     _nodeStatsProvider = nodeStatsProvider;
 }
Exemplo n.º 7
0
 public NodeLifecycleManager(Node node, IDiscoveryManager discoveryManager, INodeTable nodeTable, ILogger logger, IDiscoveryConfigurationProvider discoveryConfigurationProvider, IDiscoveryMessageFactory discoveryMessageFactory, IEvictionManager evictionManager, INodeStats nodeStats)
 {
     _discoveryManager = discoveryManager;
     _nodeTable        = nodeTable;
     _logger           = logger;
     _discoveryConfigurationProvider = discoveryConfigurationProvider;
     _discoveryMessageFactory        = discoveryMessageFactory;
     _evictionManager = evictionManager;
     NodeStats        = nodeStats;
     ManagedNode      = node;
     UpdateState(NodeLifecycleState.New);
 }
Exemplo n.º 8
0
 public DiscoveryApp(IDiscoveryConfigurationProvider configurationProvider, INodesLocator nodesLocator, ILogger logger, IDiscoveryManager discoveryManager, INodeFactory nodeFactory, INodeTable nodeTable, IMessageSerializationService messageSerializationService, ICryptoRandom cryptoRandom, IDiscoveryStorage discoveryStorage)
 {
     _configurationProvider = configurationProvider;
     _nodesLocator          = nodesLocator;
     _logger                      = logger;
     _discoveryManager            = discoveryManager;
     _nodeFactory                 = nodeFactory;
     _nodeTable                   = nodeTable;
     _messageSerializationService = messageSerializationService;
     _cryptoRandom                = cryptoRandom;
     _discoveryStorage            = discoveryStorage;
     _discoveryStorage.StartBatch();
 }
Exemplo n.º 9
0
 public DiscoveryManager(
     ILogger logger,
     IDiscoveryConfigurationProvider configurationProvider,
     INodeLifecycleManagerFactory nodeLifecycleManagerFactory,
     INodeFactory nodeFactory, INodeTable nodeTable, IDiscoveryStorage discoveryStorage)
 {
     _logger = logger;
     _configurationProvider       = configurationProvider;
     _nodeLifecycleManagerFactory = nodeLifecycleManagerFactory;
     _nodeFactory      = nodeFactory;
     _nodeTable        = nodeTable;
     _discoveryStorage = discoveryStorage;
     _nodeLifecycleManagerFactory.DiscoveryManager = this;
 }
Exemplo n.º 10
0
        public void Initialize()
        {
            var logger = new SimpleConsoleLogger();

            _configurationProvider            = new DiscoveryConfigurationProvider(new NetworkHelper(logger));
            _configurationProvider.DbBasePath = Path.Combine(Path.GetTempPath(), "PeerStorageTests");

            var dbPath = Path.Combine(_configurationProvider.DbBasePath, FullDbOnTheRocks.PeersDbPath);

            if (Directory.Exists(dbPath))
            {
                Directory.GetFiles(dbPath).ToList().ForEach(File.Delete);
            }

            _nodeFactory = new NodeFactory();
            _peerStorage = new PeerStorage(_configurationProvider, _nodeFactory, logger, new PerfService(logger));
        }
Exemplo n.º 11
0
        //TODO Timer to periodically check active peers and move new to active based on max size and compatibility - stats and capabilities + update peers in synchronization manager
        //TODO Remove active and synch on disconnect
        //TODO Update Stats on disconnect, other events
        //TODO Move Discover to Network
        //TODO update runner to run discovery

        public PeerManager(IRlpxPeer localPeer, IDiscoveryManager discoveryManager, ILogger logger, IDiscoveryConfigurationProvider configurationProvider, ISynchronizationManager synchronizationManager, INodeStatsProvider nodeStatsProvider, IPeerStorage peerStorage, IPerfService perfService)
        {
            _localPeer              = localPeer;
            _logger                 = logger;
            _configurationProvider  = configurationProvider;
            _synchronizationManager = synchronizationManager;
            _nodeStatsProvider      = nodeStatsProvider;
            _discoveryManager       = discoveryManager;
            _perfService            = perfService;
            _isDiscoveryEnabled     = _discoveryManager != null;

            if (_isDiscoveryEnabled)
            {
                discoveryManager.NodeDiscovered += async(s, e) => await OnNodeDiscovered(s, e);
            }
            localPeer.ConnectionInitialized += OnRemoteConnectionInitialized;
            _peerStorage = peerStorage;
            _peerStorage.StartBatch();
        }
Exemplo n.º 12
0
        public void Initialize()
        {
            _logger = new SimpleConsoleLogger();
            _configurationProvider            = new DiscoveryConfigurationProvider(new NetworkHelper(_logger));
            _configurationProvider.DbBasePath = Path.Combine(Path.GetTempPath(), "PeerManagerTests");
            _nodeFactory = new NodeFactory();
            _localPeer   = new TestRlpxPeer();
            var keyProvider = new PrivateKeyProvider(new CryptoRandom());
            var key         = keyProvider.PrivateKey.PublicKey;

            _synchronizationManager = Substitute.For <ISynchronizationManager>();

            var nodeTable = new NodeTable(_configurationProvider, _nodeFactory, Substitute.For <IKeyStore>(), _logger, new NodeDistanceCalculator(_configurationProvider));

            nodeTable.Initialize(key);

            _discoveryManager = new DiscoveryManager(_logger, _configurationProvider, new NodeLifecycleManagerFactory(_nodeFactory, nodeTable, _logger, _configurationProvider, new DiscoveryMessageFactory(_configurationProvider), Substitute.For <IEvictionManager>(), new NodeStatsProvider(_configurationProvider)), _nodeFactory, nodeTable, new DiscoveryStorage(_configurationProvider, _nodeFactory, _logger, new PerfService(_logger)));
            _discoveryManager.MessageSender = Substitute.For <IMessageSender>();

            _peerManager = new PeerManager(_localPeer, _discoveryManager, _logger, _configurationProvider, _synchronizationManager, new NodeStatsProvider(_configurationProvider), new PeerStorage(_configurationProvider, _nodeFactory, _logger, new PerfService(_logger)), new PerfService(_logger));
        }
Exemplo n.º 13
0
 public NodeStatsProvider(IDiscoveryConfigurationProvider discoveryConfigurationProvider)
 {
     _discoveryConfigurationProvider = discoveryConfigurationProvider;
 }
 public DiscoveryMessageFactory(IDiscoveryConfigurationProvider discoveryConfigurationProvider)
 {
     _discoveryConfigurationProvider = discoveryConfigurationProvider;
 }