/// <summary> /// Initializes the object with default values. /// </summary> public CoreNodeManager( IServerInternal server, ApplicationConfiguration configuration, ushort dynamicNamespaceIndex) { if (server == null) throw new ArgumentNullException("server"); if (configuration == null) throw new ArgumentNullException("configuration"); m_server = server; m_nodes = new NodeTable(server.NamespaceUris, server.ServerUris, server.TypeTree); m_monitoredItems = new Dictionary<uint,MonitoredItem>(); m_defaultMinimumSamplingInterval = 1000; m_namespaceUris = new List<string>(); m_dynamicNamespaceIndex = dynamicNamespaceIndex; #if LEGACY_CORENODEMANAGER m_eventSources = new Dictionary<object,IEventSource>(); #endif // use namespace 1 if out of range. if (m_dynamicNamespaceIndex == 0 || m_dynamicNamespaceIndex >= server.NamespaceUris.Count) { m_dynamicNamespaceIndex = 1; } m_samplingGroupManager = new SamplingGroupManager( server, this, (uint)configuration.ServerConfiguration.MaxNotificationQueueSize, configuration.ServerConfiguration.AvailableSamplingRates); }
/// <summary> /// Initializes the object with default values. /// </summary> public NodeCache(Session session) { if (session == null) throw new ArgumentNullException("session"); m_session = session; m_typeTree = new TypeTable(m_session.NamespaceUris); m_nodes = new NodeTable(m_session.NamespaceUris, m_session.ServerUris, m_typeTree); }
/// <summary> /// Initializes the object with default values. /// </summary> public NodeCache(Session session) { if (session == null) { throw new ArgumentNullException(nameof(session)); } m_session = session; m_typeTree = new TypeTable(m_session.NamespaceUris); m_nodes = new NodeTable(m_session.NamespaceUris, m_session.ServerUris, m_typeTree); }
private static void UpsertIntoNodeTable(Node node) { if (NodeTable.ContainsKey(node.NodeId)) { NodeTable[node.NodeId] = node; } else { NodeTable.Add(node.NodeId, node); } }
/* Non-Terminals Procedures */ private NodeTable ParseTable() { tempTable = new List <List <Token> >(); Match(TokenType.TableBegin); NodeTable tbl = new NodeTable { RowList = ParseRowList() }; Match(TokenType.TableEnd); return(tbl); }
public Astar(ISuccGenerator <ANode> successorNodesGenerator, IHCalculator <ANode> hValueCalculator) { comparer = new FComparer(this); succGen = successorNodesGenerator; hCalc = hValueCalculator; Name = "A*"; timeAvaliable = 5000; openList = new NodeTable <ANode>(Comparer); closedList = new NodeTable <ANode>(Comparer); }
/// <summary> /// Populates the Circuit, Node and Pin tables /// </summary> /// <param name="circuit"></param> public static void RegisterCircuit(Circuit circuit) { CircuitTable.Add(circuit.CircuitId, circuit); foreach (Node node in circuit.Nodes) { NodeTable.Add(node.NodeId, node); foreach (Pin pin in node.Pins) { PinTable.Add(pin.PinId, pin); } } }
public void Initialize() { NetworkNodeDecoder.Init(); _timestamp = new Timestamp(); _logManager = new OneLoggerLogManager(new SimpleConsoleLogger()); _configurationProvider = new ConfigProvider(); INetworkConfig networkConfig = _configurationProvider.GetConfig <INetworkConfig>(); networkConfig.DbBasePath = Path.Combine(Path.GetTempPath(), "PeerManagerTests"); networkConfig.IsActivePeerTimerEnabled = false; networkConfig.IsDiscoveryNodesPersistenceOn = false; networkConfig.IsPeersPersistenceOn = false; if (!Directory.Exists(networkConfig.DbBasePath)) { Directory.CreateDirectory(networkConfig.DbBasePath); } var syncManager = Substitute.For <ISynchronizationManager>(); Block genesisBlock = Build.A.Block.Genesis.TestObject; syncManager.Head.Returns(genesisBlock.Header); syncManager.Genesis.Returns(genesisBlock.Header); _nodeFactory = new NodeFactory(LimboLogs.Instance); _localPeer = new TestRlpxPeer(); var keyProvider = new PrivateKeyGenerator(new CryptoRandom()); var key = keyProvider.Generate().PublicKey; _synchronizationManager = Substitute.For <ISynchronizationManager>(); IStatsConfig statsConfig = _configurationProvider.GetConfig <IStatsConfig>(); var nodeTable = new NodeTable(_nodeFactory, Substitute.For <IKeyStore>(), new NodeDistanceCalculator(networkConfig), networkConfig, _logManager); nodeTable.Initialize(new NodeId(key)); _discoveryManager = new DiscoveryManager(new NodeLifecycleManagerFactory(_nodeFactory, nodeTable, new DiscoveryMessageFactory(networkConfig, _timestamp), Substitute.For <IEvictionManager>(), new NodeStatsProvider(_configurationProvider.GetConfig <IStatsConfig>(), _nodeFactory, _logManager, true), networkConfig, _logManager), _nodeFactory, nodeTable, new NetworkStorage("test", networkConfig, _logManager, new PerfService(_logManager)), networkConfig, _logManager); _discoveryManager.MessageSender = Substitute.For <IMessageSender>(); _transactionPool = NullTransactionPool.Instance; _blockTree = Substitute.For <IBlockTree>(); var app = new DiscoveryApp(new NodesLocator(nodeTable, _discoveryManager, _configurationProvider, _logManager), _discoveryManager, _nodeFactory, nodeTable, Substitute.For <IMessageSerializationService>(), new CryptoRandom(), Substitute.For <INetworkStorage>(), networkConfig, _logManager, new PerfService(_logManager)); app.Initialize(key); var sessionLogger = new PeerSessionLogger(_logManager, _configurationProvider, new PerfService(_logManager)); sessionLogger.Init(Path.GetTempPath()); var networkStorage = new NetworkStorage("test", networkConfig, _logManager, new PerfService(_logManager)); _peerManager = new PeerManager(_localPeer, app, _synchronizationManager, new NodeStatsProvider(statsConfig, _nodeFactory, _logManager, true), networkStorage, _nodeFactory, _configurationProvider, new PerfService(_logManager), _transactionPool, _logManager, sessionLogger); _peerManager.Init(true); }
public AWA(ISuccGenerator <ANode> successorNodesGenerator, IHCalculator <ANode> hValueCalculator, int W) { succGen = successorNodesGenerator; hCalc = hValueCalculator; w = W; Name = "AWA*"; timeAvaliable = 5000; comparer = new FComparer(this); openList = new NodeTable <ANode>(Comparer); closedList = new NodeTable <ANode>(Comparer); }
public AWinA(ISuccGenerator <ANode> successorNodesGenerator, IHCalculator <ANode> hValueCalculator) { comparer = new FComparer(this); suspendList = new NodeTable <ANode>(comparer); succGen = successorNodesGenerator; hCalc = hValueCalculator; currentLvl = -1; winSize = 0; Name = "AWinA*"; timeAvaliable = 5000; openList = new NodeTable <ANode>(Comparer); closedList = new NodeTable <ANode>(Comparer); }
public static List <Item> ImportFromFile(string filePath, Device d3ddevice, EditorCamera camera, out bool errorFlag, out string errorMsg, EditorItemSelection selectionManager) { List <Item> createdItems = new List <Item>(); if (!File.Exists(filePath)) { errorFlag = true; errorMsg = "File does not exist!"; return(null); } DirectoryInfo filePathInfo = new DirectoryInfo(filePath); bool importError = false; string importErrorMsg = ""; switch (filePathInfo.Extension) { case ".obj": case ".objf": Vector3 pos = camera.Position + (-20 * camera.Look); LevelItem item = new LevelItem(d3ddevice, filePath, new Vertex(pos.X, pos.Y, pos.Z), new Rotation(), LevelItems.Count, selectionManager) { Visible = true }; createdItems.Add(item); break; case ".txt": NodeTable.ImportFromFile(d3ddevice, filePath, out importError, out importErrorMsg, selectionManager); break; default: errorFlag = true; errorMsg = "Invalid file format!"; return(null); } StateChanged(); errorFlag = importError; errorMsg = importErrorMsg; return(createdItems); }
public NodeManager() { this.is_enable_discovery = Args.Instance.Node.Discovery.Enable ?? false; this.home_node = new Node(RefreshTask.GetNodeId(), Args.Instance.Node.Discovery.ExternalIP, Args.Instance.Node.ListenPort); foreach (string boot in Args.Instance.Seed.IpList) { this.boot_nodes.Add(Node.InstanceOf(boot)); } Logger.Info(string.Format("home_node : {0}", this.home_node)); Logger.Info(string.Format("boot_nodes : size= {0}", this.boot_nodes.Count)); this.table = new NodeTable(this.home_node); }
public void TestNodeTraversal() { Circuit testCircuit = createTestCircuit01(); RegisterCircuit(testCircuit); StepThroughCircuit(testCircuit.StartingNodeId); // Make sure every pin has been turned on by the NodeTraversal logic foreach (Node node in testCircuit.Nodes) { Assert.IsTrue(NodeTable.ContainsKey(node.NodeId)); foreach (Pin pin in node.Pins) { Assert.IsTrue(PinTable.ContainsKey(pin.PinId)); Assert.AreEqual(pin.State, StateEnum.ON); } } ClearAllTables(); }
public Table Parse <T>(string fixtureHTML) where T : Fixture { this.Index = -1; this.Tokens = (new Lexer()).Tokenize(fixtureHTML); NodeTable parseTree = ParseTable(); PrintTree(parseTree); if (typeof(T) == typeof(ColumnFixture)) { return(GenerateExampleTable()); } else if (typeof(T) == typeof(ActionFixture)) { return(GenerateActionTable()); } else { throw new Exception("Invalid fixture Type"); } }
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)); }
public async Task Initialize() { _logManager = new OneLoggerLogManager(new SimpleConsoleLogger()); _configurationProvider = new JsonConfigProvider(); ((NetworkConfig)_configurationProvider.GetConfig <INetworkConfig>()).DbBasePath = Path.Combine(Path.GetTempPath(), "PeerManagerTests"); if (!Directory.Exists(_configurationProvider.GetConfig <INetworkConfig>().DbBasePath)) { Directory.CreateDirectory(_configurationProvider.GetConfig <INetworkConfig>().DbBasePath); } var serializationService = Build.A.SerializationService().WithEncryptionHandshake().WithP2P().WithEth().TestObject; var syncManager = Substitute.For <ISynchronizationManager>(); Block genesisBlock = Build.A.Block.Genesis.TestObject; syncManager.Head.Returns(genesisBlock.Header); syncManager.Genesis.Returns(genesisBlock.Header); _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(_nodeFactory, Substitute.For <IKeyStore>(), new NodeDistanceCalculator(_configurationProvider), _configurationProvider, _logManager); nodeTable.Initialize(new NodeId(key)); INetworkConfig networkConfig = _configurationProvider.GetConfig <INetworkConfig>(); IStatsConfig statsConfig = _configurationProvider.GetConfig <IStatsConfig>(); _discoveryManager = new DiscoveryManager(new NodeLifecycleManagerFactory(_nodeFactory, nodeTable, new DiscoveryMessageFactory(_configurationProvider), Substitute.For <IEvictionManager>(), new NodeStatsProvider(_configurationProvider.GetConfig <IStatsConfig>(), _nodeFactory, _logManager), _configurationProvider, _logManager), _nodeFactory, nodeTable, new NetworkStorage("test", networkConfig, _logManager, new PerfService(_logManager)), _configurationProvider, _logManager); _discoveryManager.MessageSender = Substitute.For <IMessageSender>(); var networkStorage = new NetworkStorage("test", networkConfig, _logManager, new PerfService(_logManager)); _peerManager = new PeerManager(_localPeer, _discoveryManager, _synchronizationManager, new NodeStatsProvider(statsConfig, _nodeFactory, _logManager), networkStorage, _nodeFactory, _configurationProvider, new PerfService(_logManager), _logManager); _peerManager.Init(true); }
public void Setup() { NetworkConfig networkConfig = new NetworkConfig(); networkConfig.ExternalIp = IPAddress.Broadcast.ToString(); _masterNode = new Node(TestItem.PublicKeyA, IPAddress.Broadcast.ToString(), 30000, false); DiscoveryConfig config = new DiscoveryConfig() { DiscoveryNewCycleWaitTime = 1 }; NodeDistanceCalculator distanceCalculator = new NodeDistanceCalculator(config); _nodeTable = new NodeTable( distanceCalculator, config, networkConfig, LimboLogs.Instance); DiscoveryMessageFactory messageFactory = new DiscoveryMessageFactory(Timestamper.Default); EvictionManager evictionManager = new EvictionManager(_nodeTable, LimboLogs.Instance); ITimerFactory timerFactory = Substitute.For <ITimerFactory>(); NodeStatsManager nodeStatsManager = new NodeStatsManager(timerFactory, LimboLogs.Instance); NodeLifecycleManagerFactory managerFactory = new NodeLifecycleManagerFactory( _nodeTable, messageFactory, evictionManager, nodeStatsManager, config, LimboLogs.Instance); DiscoveryManager manager = new DiscoveryManager( managerFactory, _nodeTable, new NetworkStorage(new MemDb(), LimboLogs.Instance), config, LimboLogs.Instance, new IPResolver(networkConfig, LimboLogs.Instance)); _nodesLocator = new NodesLocator(_nodeTable, manager, config, LimboLogs.Instance); }
public override void Execute() { stopwatch.Restart(); while (stopwatch.Elapsed.TotalMilliseconds < timeAvaliable && !stopped) { winA(timeAvaliable); if (suspendList.Count == 0 || stopwatch.Elapsed.TotalMilliseconds >= timeAvaliable) { if (suspendList.Count == 0) { isOptimalFound = true; } stopwatch.Stop(); return; } closedList.AddValues(openList); openList.Clear(); openList = suspendList; suspendList = new NodeTable <ANode>(comparer); winSize += 1; } stopwatch.Stop(); }
private Task InitDiscovery(InitParams initParams) { _logger.Info("Initializing Discovery"); if (initParams.DiscoveryPort.HasValue) { _configProvider.GetConfig <NetworkConfig>().MasterPort = initParams.DiscoveryPort.Value; } var privateKeyProvider = new PrivateKeyProvider(_privateKey); var discoveryMessageFactory = new DiscoveryMessageFactory(_configProvider); var nodeIdResolver = new NodeIdResolver(_signer); var msgSerializersProvider = new DiscoveryMsgSerializersProvider(_messageSerializationService, _signer, privateKeyProvider, discoveryMessageFactory, nodeIdResolver, _nodeFactory); msgSerializersProvider.RegisterDiscoverySerializers(); var nodeDistanceCalculator = new NodeDistanceCalculator(_configProvider); var nodeTable = new NodeTable(_nodeFactory, _keyStore, nodeDistanceCalculator, _configProvider, _logManager); var evictionManager = new EvictionManager(nodeTable, _logManager); var nodeLifeCycleFactory = new NodeLifecycleManagerFactory(_nodeFactory, nodeTable, discoveryMessageFactory, evictionManager, _nodeStatsProvider, _configProvider, _logManager); var discoveryStorage = new DiscoveryStorage(_configProvider, _nodeFactory, _logManager, _perfService); _discoveryManager = new DiscoveryManager(nodeLifeCycleFactory, _nodeFactory, nodeTable, discoveryStorage, _configProvider, _logManager); var nodesLocator = new NodesLocator(nodeTable, _discoveryManager, _configProvider, _logManager); _discoveryApp = new DiscoveryApp(nodesLocator, _discoveryManager, _nodeFactory, nodeTable, _messageSerializationService, _cryptoRandom, discoveryStorage, _configProvider, _logManager); _discoveryApp.Start(_privateKey.PublicKey); _logger.Info("Discovery initialization completed"); return(Task.CompletedTask); }
public void A_node_table() { NodeTable = new NodeTable <T>(); }
public SparseGraph() { nodeTable = new NodeTable(); edgeListTable = new EdgeListTable(); nodeIdCounter = 0; }
private void InitDiscovery() { if (!_initConfig.DiscoveryEnabled) { _discoveryApp = new NullDiscoveryApp(); return; } INetworkConfig networkConfig = _configProvider.GetConfig <INetworkConfig>(); networkConfig.MasterPort = _initConfig.DiscoveryPort; var privateKeyProvider = new SameKeyGenerator(_nodeKey); var discoveryMessageFactory = new DiscoveryMessageFactory(networkConfig, _timestamp); var nodeIdResolver = new NodeIdResolver(_ecdsa); IDiscoveryMsgSerializersProvider msgSerializersProvider = new DiscoveryMsgSerializersProvider( _messageSerializationService, _ecdsa, privateKeyProvider, discoveryMessageFactory, nodeIdResolver); msgSerializersProvider.RegisterDiscoverySerializers(); var nodeDistanceCalculator = new NodeDistanceCalculator(networkConfig); var nodeTable = new NodeTable( _keyStore, nodeDistanceCalculator, networkConfig, _logManager); var evictionManager = new EvictionManager( nodeTable, _logManager); var nodeLifeCycleFactory = new NodeLifecycleManagerFactory( nodeTable, discoveryMessageFactory, evictionManager, _nodeStatsManager, networkConfig, _logManager); var discoveryStorage = new NetworkStorage( DiscoveryNodesDbPath, networkConfig, _logManager, _perfService); var discoveryManager = new DiscoveryManager( nodeLifeCycleFactory, nodeTable, discoveryStorage, networkConfig, _logManager); var nodesLocator = new NodesLocator( nodeTable, discoveryManager, _configProvider, _logManager); _discoveryApp = new DiscoveryApp( nodesLocator, discoveryManager, nodeTable, _messageSerializationService, _cryptoRandom, discoveryStorage, networkConfig, _logManager, _perfService); _discoveryApp.Initialize(_nodeKey.PublicKey); }
public static List <Item> ImportFromFile(string filePath, EditorCamera camera, out bool errorFlag, out string errorMsg, EditorItemSelection selectionManager, OnScreenDisplay osd, bool multiple = false) { List <Item> createdItems = new List <Item>(); if (!File.Exists(filePath)) { errorFlag = true; errorMsg = "File does not exist!"; return(null); } DirectoryInfo filePathInfo = new DirectoryInfo(filePath); bool importError = false; string importErrorMsg = ""; Vector3 pos = camera.Position + (-20 * camera.Look); switch (filePathInfo.Extension) { case ".sa1mdl": ModelFile mf = new ModelFile(filePath); NJS_OBJECT objm = mf.Model; osd.ClearMessageList(); osd.AddMessage("Importing models, please wait...", 3000); osd.ClearMessageList(); createdItems.AddRange(ImportFromHierarchy(objm, selectionManager, osd, multiple)); osd.AddMessage("Stage import complete!", 100); break; case ".obj": case ".objf": LevelItem item = new LevelItem(filePath, new Vertex(pos.X, pos.Y, pos.Z), new Rotation(), levelItems.Count, selectionManager) { Visible = true }; createdItems.Add(item); break; case ".txt": NodeTable.ImportFromFile(filePath, out importError, out importErrorMsg, selectionManager); break; case ".dae": case ".fbx": Assimp.AssimpContext context = new Assimp.AssimpContext(); Assimp.Configs.FBXPreservePivotsConfig conf = new Assimp.Configs.FBXPreservePivotsConfig(false); context.SetConfig(conf); Assimp.Scene scene = context.ImportFile(filePath, Assimp.PostProcessSteps.Triangulate); for (int i = 0; i < scene.RootNode.ChildCount; i++) { osd.ClearMessageList(); osd.AddMessage("Importing model " + i.ToString() + " of " + scene.RootNode.ChildCount.ToString() + "...", 3000); Assimp.Node child = scene.RootNode.Children[i]; List <Assimp.Mesh> meshes = new List <Assimp.Mesh>(); foreach (int j in child.MeshIndices) { meshes.Add(scene.Meshes[j]); } bool isVisible = true; for (int j = 0; j < child.MeshCount; j++) { if (scene.Materials[meshes[j].MaterialIndex].Name.Contains("Collision")) { isVisible = false; break; } } ModelFormat mfmt = ModelFormat.Basic; if (isVisible) { switch (geo.Format) { case LandTableFormat.SA2: mfmt = ModelFormat.Chunk; break; case LandTableFormat.SA2B: mfmt = ModelFormat.GC; break; } } NJS_OBJECT obj = AssimpStuff.AssimpImport(scene, child, mfmt, TextureBitmaps[leveltexs].Select(a => a.Name).ToArray(), !multiple); { //sa2 collision patch if (obj.Attach.GetType() == typeof(BasicAttach)) { BasicAttach ba = obj.Attach as BasicAttach; foreach (NJS_MATERIAL mats in ba.Material) { mats.DoubleSided = true; } } //cant check for transparent texture so i gotta force alpha for now, temporary else if (obj.Attach.GetType() == typeof(ChunkAttach)) { ChunkAttach ca = obj.Attach as ChunkAttach; foreach (PolyChunk polys in ca.Poly) { if (polys.GetType() == typeof(PolyChunkMaterial)) { PolyChunkMaterial mat = polys as PolyChunkMaterial; mat.SourceAlpha = AlphaInstruction.SourceAlpha; mat.DestinationAlpha = AlphaInstruction.InverseSourceAlpha; } else if (polys.GetType() == typeof(PolyChunkStrip)) { PolyChunkStrip str = polys as PolyChunkStrip; //str.UseAlpha = true; } } } } obj.Attach.ProcessVertexData(); LevelItem newLevelItem = new LevelItem(obj.Attach, new Vertex(obj.Position.X + pos.X, obj.Position.Y + pos.Y, obj.Position.Z + pos.Z), obj.Rotation, levelItems.Count, selectionManager) { Visible = isVisible }; createdItems.Add(newLevelItem); } osd.ClearMessageList(); osd.AddMessage("Stage import complete!", 100); break; default: errorFlag = true; errorMsg = "Invalid file format!"; return(null); } StateChanged(); errorFlag = importError; errorMsg = importErrorMsg; return(createdItems); }
/// <summary> /// Imports the nodes from a dictionary of NodeState objects. /// </summary> internal void ImportNodes(ISystemContext context, IEnumerable<NodeState> predefinedNodes, bool isInternal) { NodeTable nodesToExport = new NodeTable(Server.NamespaceUris, Server.ServerUris, Server.TypeTree); foreach (NodeState node in predefinedNodes) { node.Export(context, nodesToExport); } lock (Server.CoreNodeManager.DataLock) { foreach (ILocalNode nodeToExport in nodesToExport) { Server.CoreNodeManager.AttachNode(nodeToExport, isInternal); } } }
private void InitDiscovery() { if (_ctx.NodeStatsManager == null) { throw new StepDependencyException(nameof(_ctx.NodeStatsManager)); } if (_ctx.Timestamper == null) { throw new StepDependencyException(nameof(_ctx.Timestamper)); } if (_ctx.NodeKey == null) { throw new StepDependencyException(nameof(_ctx.NodeKey)); } if (_ctx.CryptoRandom == null) { throw new StepDependencyException(nameof(_ctx.CryptoRandom)); } if (!_ctx.Config <IInitConfig>().DiscoveryEnabled) { _ctx.DiscoveryApp = new NullDiscoveryApp(); return; } IDiscoveryConfig discoveryConfig = _ctx.Config <IDiscoveryConfig>(); SameKeyGenerator privateKeyProvider = new SameKeyGenerator(_ctx.NodeKey.Unprotect()); DiscoveryMessageFactory discoveryMessageFactory = new DiscoveryMessageFactory(_ctx.Timestamper); NodeIdResolver nodeIdResolver = new NodeIdResolver(_ctx.EthereumEcdsa); IPResolver ipResolver = new IPResolver(_networkConfig, _ctx.LogManager); IDiscoveryMsgSerializersProvider msgSerializersProvider = new DiscoveryMsgSerializersProvider( _ctx._messageSerializationService, _ctx.EthereumEcdsa, privateKeyProvider, discoveryMessageFactory, nodeIdResolver); msgSerializersProvider.RegisterDiscoverySerializers(); NodeDistanceCalculator nodeDistanceCalculator = new NodeDistanceCalculator(discoveryConfig); NodeTable nodeTable = new NodeTable(nodeDistanceCalculator, discoveryConfig, _networkConfig, _ctx.LogManager); EvictionManager evictionManager = new EvictionManager(nodeTable, _ctx.LogManager); NodeLifecycleManagerFactory nodeLifeCycleFactory = new NodeLifecycleManagerFactory( nodeTable, discoveryMessageFactory, evictionManager, _ctx.NodeStatsManager, discoveryConfig, _ctx.LogManager); SimpleFilePublicKeyDb discoveryDb = new SimpleFilePublicKeyDb("DiscoveryDB", DiscoveryNodesDbPath.GetApplicationResourcePath(_ctx.Config <IInitConfig>().BaseDbPath), _ctx.LogManager); NetworkStorage discoveryStorage = new NetworkStorage( discoveryDb, _ctx.LogManager); DiscoveryManager discoveryManager = new DiscoveryManager( nodeLifeCycleFactory, nodeTable, discoveryStorage, discoveryConfig, _ctx.LogManager, ipResolver ); NodesLocator nodesLocator = new NodesLocator( nodeTable, discoveryManager, discoveryConfig, _ctx.LogManager); _ctx.DiscoveryApp = new DiscoveryApp( nodesLocator, discoveryManager, nodeTable, _ctx._messageSerializationService, _ctx.CryptoRandom, discoveryStorage, _networkConfig, discoveryConfig, _ctx.Timestamper, _ctx.LogManager); _ctx.DiscoveryApp.Initialize(_ctx.NodeKey.PublicKey); }
private void InitDiscovery() { if (!_initConfig.DiscoveryEnabled) { _discoveryApp = new NullDiscoveryApp(); return; } IDiscoveryConfig discoveryConfig = _configProvider.GetConfig <IDiscoveryConfig>(); var privateKeyProvider = new SameKeyGenerator(_nodeKey); var discoveryMessageFactory = new DiscoveryMessageFactory(_timestamper); var nodeIdResolver = new NodeIdResolver(_ethereumEcdsa); IDiscoveryMsgSerializersProvider msgSerializersProvider = new DiscoveryMsgSerializersProvider( _messageSerializationService, _ethereumEcdsa, privateKeyProvider, discoveryMessageFactory, nodeIdResolver); msgSerializersProvider.RegisterDiscoverySerializers(); var nodeDistanceCalculator = new NodeDistanceCalculator(discoveryConfig); var nodeTable = new NodeTable(nodeDistanceCalculator, discoveryConfig, _networkConfig, _logManager); var evictionManager = new EvictionManager(nodeTable, _logManager); var nodeLifeCycleFactory = new NodeLifecycleManagerFactory( nodeTable, discoveryMessageFactory, evictionManager, _nodeStatsManager, discoveryConfig, _logManager); var discoveryDb = new SimpleFilePublicKeyDb("DiscoveryDB", Path.Combine(_initConfig.BaseDbPath, DiscoveryNodesDbPath), _logManager); var discoveryStorage = new NetworkStorage( discoveryDb, _logManager); var discoveryManager = new DiscoveryManager( nodeLifeCycleFactory, nodeTable, discoveryStorage, discoveryConfig, _logManager); var nodesLocator = new NodesLocator( nodeTable, discoveryManager, discoveryConfig, _logManager); _discoveryApp = new DiscoveryApp( nodesLocator, discoveryManager, nodeTable, _messageSerializationService, _cryptoRandom, discoveryStorage, _networkConfig, discoveryConfig, _timestamper, _logManager, _perfService); _discoveryApp.Initialize(_nodeKey.PublicKey); }
private void InitDiscovery() { _configProvider.GetConfig <INetworkConfig>().MasterPort = _initConfig.DiscoveryPort; var privateKeyProvider = new PrivateKeyProvider(_privateKey); var discoveryMessageFactory = new DiscoveryMessageFactory(_configProvider); var nodeIdResolver = new NodeIdResolver(_signer); IDiscoveryMsgSerializersProvider msgSerializersProvider = new DiscoveryMsgSerializersProvider( _messageSerializationService, _signer, privateKeyProvider, discoveryMessageFactory, nodeIdResolver, _nodeFactory); msgSerializersProvider.RegisterDiscoverySerializers(); var nodeDistanceCalculator = new NodeDistanceCalculator(_configProvider); var nodeTable = new NodeTable( _nodeFactory, _keyStore, nodeDistanceCalculator, _configProvider, _logManager); var evictionManager = new EvictionManager( nodeTable, _logManager); var nodeLifeCycleFactory = new NodeLifecycleManagerFactory( _nodeFactory, nodeTable, discoveryMessageFactory, evictionManager, _nodeStatsProvider, _configProvider, _logManager); var discoveryStorage = new NetworkStorage( DiscoveryNodesDbPath, _configProvider.GetConfig <INetworkConfig>(), _logManager, _perfService); _discoveryManager = new DiscoveryManager( nodeLifeCycleFactory, _nodeFactory, nodeTable, discoveryStorage, _configProvider, _logManager); var nodesLocator = new NodesLocator( nodeTable, _discoveryManager, _configProvider, _logManager); _discoveryApp = new DiscoveryApp( nodesLocator, _discoveryManager, _nodeFactory, nodeTable, _messageSerializationService, _cryptoRandom, discoveryStorage, _configProvider, _logManager, _perfService); _discoveryApp.Initialize(_privateKey.PublicKey); }