Ejemplo n.º 1
0
        private void InitMainNode(int _port = 7077)
        {
            string wif = nexusWif;

            int port = _port;

            var node_keys = PhantasmaKeys.FromWIF(wif);

            var nexus = new Nexus("simnet", null, null);

            nexus.SetOracleReader(new OracleSimulator(nexus));
            var simulator = new NexusSimulator(nexus, node_keys, 1234);

            // mempool setup
            mempool = new Mempool(nexus, Mempool.MinimumBlockTime, 1, System.Text.Encoding.UTF8.GetBytes("TEST"));
            mempool.SetKeys(node_keys);
            mempool.StartInThread();

            // node setup
            node = new Node("test node", nexus, mempool, node_keys, "localhost", port, PeerCaps.Mempool, Enumerable.Empty <String>(), new DebugLogger());
            node.StartInThread();
        }
Ejemplo n.º 2
0
        private Mempool SetupMempool()
        {
            var mempool = new Mempool(_nexus
                                      , Settings.Node.BlockTime
                                      , Settings.Node.MinimumFee
                                      , System.Text.Encoding.UTF8.GetBytes(TxIdentifier)
                                      , 0
                                      , Logger
                                      , Settings.Node.ProfilerPath
                                      );

            if (Settings.Node.MempoolLog)
            {
                mempool.OnTransactionFailed    += Mempool_OnTransactionFailed;
                mempool.OnTransactionAdded     += (hash) => Logger.Message($"Received transaction {hash}");
                mempool.OnTransactionCommitted += (hash) => Logger.Message($"Commited transaction {hash}");
                mempool.OnTransactionDiscarded += (hash) => Logger.Message($"Discarded transaction {hash}");
            }
            if (Settings.App.NodeStart)
            {
                mempool.StartInThread(ThreadPriority.AboveNormal);
            }
            return(mempool);
        }