public static ConvertStringFormatToByteFormat ( ChainHeadDataStringFormat chainStringFormat ) : ChainHeadData | ||
chainStringFormat | ChainHeadDataStringFormat | |
Результат | ChainHeadData |
/// <summary> /// Returns the data of an entry. /// </summary> /// <param name="entryHash">Entryhash of entry</param> /// <returns>The entry data</returns> public static DataStructs.EntryData GetEntryData(byte[] entryHash) { var req = new RestRequest("/entry-by-hash/{hash}", Method.GET); req.AddUrlSegment("hash", Arrays.ByteArrayToHex(entryHash)); var resp = StaticValues.clientWallet.Execute(req); var entryType = JsonConvert.DeserializeObject <DataStructs.EntryDataStringFormat>(resp.Content); return(DataStructs.ConvertStringFormatToByteFormat(entryType)); }
/// <summary> /// Returns an EntryBlock /// </summary> /// <param name="hash">String of KeyMr</param> /// <returns>EntryBlockData</returns> public static DataStructs.EntryBlockData GetEntryBlockByKeyMR(byte[] keyMR) { var req = new RestRequest("/entry-block-by-keymr/{hash}", Method.GET); var keyMRString = Arrays.ByteArrayToHex(keyMR); req.AddUrlSegment("hash", keyMRString); var resp = StaticValues.clientWallet.Execute(req); if (resp.Content == "EBlock not found") { throw new FactomEntryException("EBlock not Found, Zerohash looked up"); } var entryBlock = JsonConvert.DeserializeObject <DataStructs.EntryBlockDataStringFormat>(resp.Content); return(DataStructs.ConvertStringFormatToByteFormat(entryBlock)); }
/// <summary> /// Takes in an entry chain hash and returns Key MR of the first entry. Can be used to /// get all the entries /// </summary> /// <param name="hash">ChainID of chain</param> /// <returns>KeyMR of first entry (last in list)</returns> public static DataStructs.ChainHeadData GetChainHead(byte[] hash) { var hashString = Arrays.ByteArrayToHex(hash); var req = new RestRequest("/chain-head/{hash}", Method.GET); // var x = Arrays.ByteArrayToHex(hash); req.AddUrlSegment("hash", hashString); var resp = StaticValues.clientWallet.Execute(req); if (resp.Content.Contains("Chain not found")) { throw new FactomChainException("Chain not found"); } try { var chainHead = JsonConvert.DeserializeObject <DataStructs.ChainHeadDataStringFormat>(resp.Content); return(DataStructs.ConvertStringFormatToByteFormat(chainHead)); } catch (Exception) { throw new FactomEntryException("Error when serializing the chainhead. In GetChainHead: " + resp.Content); } }