Esempio n. 1
0
        public IExpressNode GetExpressNode(bool offlineTrace = false)
        {
            // Check to see if there's a neo-express blockchain currently running by
            // attempting to open a mutex with the multisig account address for a name

            chain.InitalizeProtocolSettings();

            for (int i = 0; i < chain.ConsensusNodes.Count; i++)
            {
                var consensusNode = chain.ConsensusNodes[i];
                if (IsRunning(consensusNode))
                {
                    return(new Node.OnlineNode(chain, consensusNode));
                }
            }

            var node     = chain.ConsensusNodes[0];
            var nodePath = fileSystem.GetNodePath(node);

            if (!fileSystem.Directory.Exists(nodePath))
            {
                fileSystem.Directory.CreateDirectory(nodePath);
            }
            return(new Node.OfflineNode(RocksDbStore.Open(nodePath), node.Wallet, chain, offlineTrace));
        }
Esempio n. 2
0
        public IExpressStore GetNodeStore(ExpressConsensusNode node, bool discard)
        {
            var folder = fileSystem.GetNodePath(node);

            if (discard)
            {
                try
                {
                    var rocksDbStore = RocksDbStore.OpenReadOnly(folder);
                    return(new CheckpointStore(rocksDbStore));
                }
                catch
                {
                    return(new CheckpointStore(NullReadOnlyStore.Instance));
                }
            }
            else
            {
                return(RocksDbStore.Open(folder));
            }
        }