public NetworkPacketSwitch(NodeConfig nodeConfig, NodeState nodeState, GlobalConfiguration globalConfiguration) { this.nodeConfig = nodeConfig; this.nodeState = nodeState; this.globalConfiguration = globalConfiguration; network = new SecureNetwork(nodeConfig, nodeState); network.PacketReceived += network_PacketReceived; network.Initialize(); }
public NodeConfig(int NodeID, GlobalConfiguration GlobalConfiguration) { //this.RpcRequestHandler = rpcRequestHandler; WorkDirectory = /*AppDomain.CurrentDomain.BaseDirectory +*/ "NODE_" + NodeID; this.NodeID = NodeID; this.GlobalConfiguration = GlobalConfiguration; if (!Directory.Exists(WorkDirectory)) { Directory.CreateDirectory(WorkDirectory); } iniFile = new INIFile(WorkDirectory + "\\NodeConfig.ini"); masterNodeRandom = GetNodePrivateRandom(iniFile); DisplayUtils.Display(" Node " + NodeID + " | Private Key : " + HexUtil.ToString(masterNodeRandom)); byte[] _PublicKey; Ed25519.KeyPairFromSeed(out _PublicKey, out masterPrivateKeyExpanded, masterNodeRandom); PublicKey = new Hash(_PublicKey); DisplayUtils.Display(" Node " + NodeID + " | Public Key : " + PublicKey); ListenPortProtocol = GetListenPortProtocol(); DisplayUtils.Display(" Node " + NodeID + " | Listen Protocol : " + ListenPortProtocol); ListenPortRPC = GetListenPortRPC(); DisplayUtils.Display(" Node " + NodeID + " | Listen RPC : " + ListenPortRPC); Path_AccountDB = GetAccountDBPath(); DisplayUtils.Display(" Node " + NodeID + " | Acct DB Path : " + Path_AccountDB); Path_TransactionDB = GetTransactionDBPath(); DisplayUtils.Display(" Node " + NodeID + " | Trxn DB Path : " + Path_TransactionDB); // // // // // // // // // Class Initializations // // // // // // // // // // // // NetworkConfig = new NetworkConfig(ListenPortProtocol); // // // // // // // // // // // // // // // // // // // // // // // // // // // //TODO: MAKE THESE LOCAL INI VARIABLES UpdateFrequencyMS = Constants.Node_UpdateFrequencyMS; UpdateFrequencyConsensusMS = Constants.Node_UpdateFrequencyConsensusMS; UpdateFrequencyPacketProcessMS = Constants.Node_UpdateFrequencyPacketProcessMS; UpdateFrequencyLedgerSyncMS = Constants.Node_UpdateFrequencyLedgerSyncMS; UpdateFrequencyLedgerSyncMS_Root = Constants.Node_UpdateFrequencyLedgerSyncMS_Root; Path_BannedNamesDB = GetInitString("PersistentDatabase", "BannedNamesDB", WorkDirectory + "\\BannedNames.sqlite3"); DisplayUtils.Display(" Node " + NodeID + " | Banned Names DB Path : " + Path_BannedNamesDB); Path_CloseHistoryDB = GetInitString("PersistentDatabase", "CloseHistoryDB", WorkDirectory + "\\CloseHistory.sqlite3"); DisplayUtils.Display(" Node " + NodeID + " | Close History DB Path : " + Path_CloseHistoryDB); // ///////////////////// Organisation = GetInitString("Info", "Organisation", "_unspecified_"); Email = GetInitString("Info", "Email", "_unspecified_"); Platform = GetInitString("Info", "Platform", "_unspecified_"); byte[] RAND_PART = new byte[8]; Common.rngCsp.GetBytes(RAND_PART); // TODO: FIX THIS, TAKE THIS FROM, DB Name = GetInitString("Info", "Name", "name" + HexUtil.ToString(RAND_PART).ToLowerInvariant()); }