public async Task RunAsync(IStorageProvider store, ExpressConsensusNode node, bool enableTrace, TextWriter writer, CancellationToken token) { if (IsNodeRunning(node)) { throw new Exception("Node already running"); } var tcs = new TaskCompletionSource <bool>(); _ = Task.Run(() => { try { var linkedToken = CancellationTokenSource.CreateLinkedTokenSource(token); var defaultAccount = node.Wallet.Accounts.Single(a => a.IsDefault); using var mutex = new Mutex(true, GLOBAL_PREFIX + defaultAccount.ScriptHash); var wallet = DevWallet.FromExpressWallet(ProtocolSettings, node.Wallet); var multiSigAccount = wallet.GetMultiSigAccounts().Single(); var logPlugin = new Node.LogPlugin(writer); var storageProviderPlugin = new Node.StorageProviderPlugin(store); var appEngineProvider = enableTrace ? new Node.ApplicationEngineProvider() : null; var dbftPlugin = new Neo.Consensus.DBFTPlugin(GetConsensusSettings(chain)); var persistencePlugin = new Node.PersistencePlugin(store); using var neoSystem = new Neo.NeoSystem(ProtocolSettings, storageProviderPlugin.Name); _ = neoSystem.ActorSystem.ActorOf(EventWrapper <Blockchain.ApplicationExecuted> .Props(OnApplicationExecuted)); var rpcSettings = GetRpcServerSettings(chain, node); var rpcServer = new Neo.Plugins.RpcServer(neoSystem, rpcSettings); var expressRpcMethods = new ExpressRpcMethods(neoSystem, store, multiSigAccount.ScriptHash, linkedToken); rpcServer.RegisterMethods(expressRpcMethods); rpcServer.RegisterMethods(persistencePlugin); rpcServer.StartRpcServer(); neoSystem.StartNode(new Neo.Network.P2P.ChannelsConfig { Tcp = new IPEndPoint(IPAddress.Loopback, node.TcpPort), WebSocket = new IPEndPoint(IPAddress.Loopback, node.WebSocketPort), }); dbftPlugin.Start(wallet); // DevTracker looks for a string that starts with "Neo express is running" to confirm that the instance has started // Do not remove or re-word this console output: writer.WriteLine($"Neo express is running ({store.GetType().Name})"); linkedToken.Token.WaitHandle.WaitOne(); } catch (Exception ex) { tcs.SetException(ex); } finally { tcs.TrySetResult(true); } }); await tcs.Task.ConfigureAwait(false);
public LogReader() { db = DB.Open(GetFullPath(Settings.Default.Path), new Options { CreateIfMissing = true }); RpcServer.RegisterMethods(this); }
protected override void OnSystemLoaded(NeoSystem system) { RpcServerSettings s = settings.Servers.FirstOrDefault(p => p.Network == system.Settings.Magic); if (s is null) { return; } RpcServer server = new RpcServer(system, s); if (handlers.Remove(s.Network, out var list)) { foreach (var handler in list) { server.RegisterMethods(handler); } } server.StartRpcServer(); servers.TryAdd(s.Network, server); }
public RpcNep5Tracker() { RpcServer.RegisterMethods(this); }