public static bool OnGetTransactionInfoById(JToken id, string method, JArray parameters, out JToken result) { result = new JObject(); if (parameters == null || parameters.Count != 1) { result = RpcMessage.CreateErrorResult(id, RpcMessage.INVALID_PARAMS, "Invalid parameters"); return(false); } try { SHA256Hash hash = SHA256Hash.Wrap(parameters[0].ToString().HexToBytes()); TransactionInfo transaction = RpcApiService.GetTransactionInfoById(hash); result = JToken.FromObject(transaction.ToByteArray()); } catch (ItemNotFoundException e) { result = RpcMessage.CreateErrorResult(id, RpcMessage.NOT_FOUN_ITEM, e.Message); return(false); } catch (System.Exception e) { result = RpcMessage.CreateErrorResult(id, RpcMessage.UNKNOWN_ERROR, e.Message); return(false); } return(true); }
public static bool OnGetBlockById(JToken id, string method, JArray parameters, out JToken result) { result = new JObject(); if (parameters == null || parameters.Count != 1) { result = RpcMessage.CreateErrorResult(id, RpcMessage.INVALID_PARAMS, "Invalid parameters"); return(false); } try { SHA256Hash hash = SHA256Hash.Wrap(parameters[0].ToString().HexToBytes()); BlockCapsule block = Manager.Instance.DBManager.GetBlockById(hash); BlockExtention block_extention = RpcApiService.CreateBlockExtention(block); result = JToken.FromObject(block_extention.ToByteArray()); } catch (System.Exception e) { result = RpcMessage.CreateErrorResult(id, RpcMessage.UNKNOWN_ERROR, e.Message); return(false); } return(true); }
public BlockId Get(long num) { BytesCapsule value = GetUnchecked(BitConverter.GetBytes(num)); if (value == null || value.Data == null) { throw new ItemNotFoundException("number : " + num + " is no found"); } return(new BlockId(SHA256Hash.Wrap(value.Data), num)); }
private TransactionCapsule GetTransactionFromKhaosDatabase(byte[] key, long high) { List <KhaosBlock> blocks = this.khaos_database.MiniStore.GetBlockByNum(high); foreach (KhaosBlock kblock in blocks) { foreach (TransactionCapsule tx in kblock.Block.Transactions) { if (tx.Id.Equals(SHA256Hash.Wrap(key))) { return(tx); } } } return(null); }
private TransactionCapsule GetTransactionFromBlockStore(byte[] key, long block_num) { List <BlockCapsule> blocks = this.block_store.GetLimitNumber(block_num, 1); if (blocks.Count != 0) { foreach (TransactionCapsule tx in blocks[0].Transactions) { if (tx.Id.Equals(SHA256Hash.Wrap(key))) { return(tx); } } } return(null); }
public List <SHA256Hash> GetHashList() { return(this.inventory.Ids.Select(hash => SHA256Hash.Wrap(hash.ToByteArray())).ToList()); }
public SHA256Hash GetLatestBlockHeaderHash() { return(SHA256Hash.Wrap(GetUnchecked(LATEST_BLOCK_HEADER_HASH).Data)); }