public JObject NetworkStatus(NetworkRequest request)
        {
            if (request.NetworkIdentifier?.Blockchain?.ToLower() != "neo n3")
            {
                return(Error.NETWORK_IDENTIFIER_INVALID.ToJson());
            }
            if (request.NetworkIdentifier?.Network?.ToLower() != network)
            {
                return(Error.NETWORK_IDENTIFIER_INVALID.ToJson());
            }

            var      snapshot      = system.StoreView;
            uint     currentHeight = NativeContract.Ledger.CurrentIndex(snapshot);
            NeoBlock currentBlock  = NativeContract.Ledger.GetBlock(snapshot, currentHeight);

            if (currentBlock == null)
            {
                return(Error.BLOCK_NOT_FOUND.ToJson());
            }

            string currentBlockHash      = currentBlock.Hash.ToString();
            long   currentBlockTimestamp = (long)currentBlock.Timestamp;

            BlockIdentifier currentBlockIdentifier = new BlockIdentifier(currentHeight, currentBlockHash);
            BlockIdentifier genesisBlockIdentifier = new BlockIdentifier(system.GenesisBlock.Index, system.GenesisBlock.Hash.ToString());

            var localNode = system.LocalNode.Ask <LocalNode>(new LocalNode.GetInstance()).Result;

            var connected = localNode.GetRemoteNodes().Select(p => new Peer(p.GetHashCode().IntToHash160String(),
                                                                            new Metadata(new Dictionary <string, JObject>
            {
                { "connected", true.ToString().ToLower() },
                { "address", p.Listener.ToString() },
                { "height", p.LastBlockIndex }
            })
                                                                            ));

            var unconnected = localNode.GetUnconnectedPeers().Select(p => new Peer(p.GetHashCode().IntToHash160String(),
                                                                                   new Metadata(new Dictionary <string, JObject>
            {
                { "unconnected", false.ToString().ToLower() },
                { "address", p.ToString() }
            })
                                                                                   ));

            Peer[] peers = connected.Concat(unconnected).ToArray();
            NetworkStatusResponse response = new NetworkStatusResponse(currentBlockIdentifier, currentBlockTimestamp, genesisBlockIdentifier, peers);

            return(response.ToJson());
        }
        public JObject NetworkStatus(NetworkRequest request)
        {
            long     currentHeight = Blockchain.Singleton.Height;
            NeoBlock currentBlock  = Blockchain.Singleton.GetBlock(Blockchain.Singleton.CurrentBlockHash);

            if (currentBlock == null)
            {
                return(Error.BLOCK_NOT_FOUND.ToJson());
            }

            string currentBlockHash      = currentBlock.Hash.ToString();
            long   currentBlockTimestamp = currentBlock.Timestamp * 1000;

            BlockIdentifier currentBlockIdentifier = new BlockIdentifier(currentHeight, currentBlockHash);
            BlockIdentifier genesisBlockIdentifier = new BlockIdentifier(Blockchain.GenesisBlock.Index, Blockchain.GenesisBlock.Hash.ToString());

            var connected = LocalNode.Singleton.GetRemoteNodes().Select(p => new Peer(p.GetHashCode().IntToHash160String(),
                                                                                      new Metadata(new Dictionary <string, JObject>
            {
                { "connected", true.ToString().ToLower() },
                { "address", p.Listener.ToString() },
                { "height", p.LastBlockIndex.ToString() }
            })
                                                                                      ));

            var unconnected = LocalNode.Singleton.GetUnconnectedPeers().Select(p => new Peer(p.GetHashCode().IntToHash160String(),
                                                                                             new Metadata(new Dictionary <string, JObject>
            {
                { "connected", false.ToString().ToLower() },
                { "address", p.ToString() }
            })
                                                                                             ));

            Peer[] peers = connected.Concat(unconnected).ToArray();
            NetworkStatusResponse response = new NetworkStatusResponse(currentBlockIdentifier, currentBlockTimestamp, genesisBlockIdentifier, peers);

            return(response.ToJson());
        }