internal static void LoadPlugins(TrustEDUNetwork system) { System = system; string path = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Plugins"); if (!Directory.Exists(path)) { return; } foreach (string filename in Directory.EnumerateFiles(path, "*.dll", SearchOption.TopDirectoryOnly)) { Assembly assembly = Assembly.LoadFile(filename); foreach (Type type in assembly.ExportedTypes) { if (!type.IsSubclassOf(typeof(Plugin))) { continue; } if (type.IsAbstract) { continue; } ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes); if (constructor == null) { continue; } constructor.Invoke(null); } } }
public RemoteNode(TrustEDUNetwork system, object connection, IPEndPoint remote, IPEndPoint local) : base(connection, remote, local) { this.system = system; this.protocol = Context.ActorOf(ProtocolHandler.Props(system)); LocalNode.Singleton.RemoteNodes.TryAdd(Self, this); SendMessage(Message.Create("version", VersionPayload.Create(LocalNode.Singleton.ListenerPort, LocalNode.Nonce, LocalNode.UserAgent, Blockchain.Singleton.Height))); }
public LocalNode(TrustEDUNetwork system) { lock (GetType()) { if (singleton != null) { throw new InvalidOperationException(); } this.system = system; singleton = this; } }
/// <summary> /// TODO: Need to refactor to use CommandLineParser lib /// </summary> /// <param name="args">Arguments.</param> protected internal override void OnStart(string[] args) { bool useRPC = false; for (int i = 0; i < args.Length; i++) { switch (args[i]) { case "/rpc": case "--rpc": case "-r": useRPC = true; break; } } store = new LevelDBStore(Path.GetFullPath(Configs.Default.Paths.Chain)); system = new TrustEDUNetwork(store); system.StartNode(Configs.Default.P2P.Port, Configs.Default.P2P.WsPort); if (Configs.Default.UnlockWallet.IsActive) { try { Program.Wallet = OpenWallet(GetIndexer(), Configs.Default.UnlockWallet.Path, Configs.Default.UnlockWallet.Password); } catch (CryptographicException) { Console.WriteLine($"failed to open file \"{Configs.Default.UnlockWallet.Path}\""); } if (Configs.Default.UnlockWallet.StartConsensus && Program.Wallet != null) { OnStartConsensusCommand(null); } } if (useRPC) { system.StartRpc(IPAddress.Parse("127.0.0.1"), Configs.Default.RPC.Port, wallet: Program.Wallet, sslCert: Configs.Default.RPC.SslCert, password: Configs.Default.RPC.SslCertPassword); } }
public Blockchain(TrustEDUNetwork system, Store store) { this.system = system; this.Store = store; lock (GetType()) { if (singleton != null) { throw new InvalidOperationException(); } header_index.AddRange(store.GetHeaderHashList().Find().OrderBy(p => (uint)p.Key).SelectMany(p => p.Value.Hashes)); stored_header_count += (uint)header_index.Count; if (stored_header_count == 0) { header_index.AddRange(store.GetBlocks().Find().OrderBy(p => p.Value.TrimmedBlock.Index).Select(p => p.Key)); } else { HashIndexState hashIndex = store.GetHeaderHashIndex().Get(); if (hashIndex.Index >= stored_header_count) { CacheItem <UInt256, BlockState> cache = store.GetBlocks(); for (UInt256 hash = hashIndex.Hash; hash != header_index[(int)stored_header_count - 1];) { header_index.Insert((int)stored_header_count, hash); hash = cache[hash].TrimmedBlock.PrevHash; } } } if (header_index.Count == 0) { Persist(GenesisBlock); } else { UpdateCurrentSnapshot(); } singleton = this; } }
public static Props Props(TrustEDUNetwork system) { return(Akka.Actor.Props.Create(() => new ProtocolHandler(system)).WithMailbox("protocol-handler-mailbox")); }
public ProtocolHandler(TrustEDUNetwork system) { this.system = system; }
public RpcServer(TrustEDUNetwork system, Wallet wallet = null) { this.system = system; this.wallet = wallet; }
public static Props Props(TrustEDUNetwork system, Wallet wallet) { return(Akka.Actor.Props.Create(() => new ConsensusService(system, wallet)).WithMailbox("consensus-service-mailbox")); }
public ConsensusService(TrustEDUNetwork system, Wallet wallet) { this._system = system; this._wallet = wallet; }
public EducationAssets(Wallet wallet, TrustEDUNetwork system) { this.currentWallet = wallet; this.system = system; }
internal static Props Props(TrustEDUNetwork system, object connection, IPEndPoint remote, IPEndPoint local) { return(Akka.Actor.Props.Create(() => new RemoteNode(system, connection, remote, local)).WithMailbox("remote-node-mailbox")); }
public static Props Props(TrustEDUNetwork system, Store store) { return(Akka.Actor.Props.Create(() => new Blockchain(system, store)).WithMailbox("blockchain-mailbox")); }
public static Props Props(TrustEDUNetwork system) { return(Akka.Actor.Props.Create(() => new LocalNode(system))); }
public TaskManager(TrustEDUNetwork system) { this.system = system; }
public static Props Props(TrustEDUNetwork system) { return(Akka.Actor.Props.Create(() => new TaskManager(system)).WithMailbox("task-manager-mailbox")); }