public JObject NetworkOptions(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()); } Version version = new Version(Settings.Default.RosettaVersion, LocalNode.UserAgent); Allow allow = new Allow(OperationStatus.AllowedStatuses, OperationType.AllowedOperationTypes, Error.AllowedErrors, false, Array.Empty <string>(), Array.Empty <BalanceExemption>(), false, 1468595301000); NetworkOptionsResponse networkOptionsResponse = new NetworkOptionsResponse(version, allow); return(networkOptionsResponse.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()); }