/// <inheritdoc /> public virtual async Task <List <TransactionTrytes> > GetTrytesAsync(List <Hash> hashes) { var result = new GetTrytesResponse { Trytes = new List <string>() }; if (hashes.Count > MaxGetTrytesHashCount) { for (var i = 0; i < (hashes.Count / MaxGetTrytesHashCount) + 1; i++) { var requestHashes = hashes.Skip(i * MaxGetTrytesHashCount).Take(MaxGetTrytesHashCount); var interimResult = await this.Client.ExecuteParameterizedCommandAsync <GetTrytesResponse>( new Dictionary <string, object> { { "command", CommandType.GetTrytes }, { "hashes", requestHashes.Select(h => h.Value).ToList() } }); result.Trytes.AddRange(interimResult.Trytes); } } else { result = await this.Client.ExecuteParameterizedCommandAsync <GetTrytesResponse>( new Dictionary <string, object> { { "command", CommandType.GetTrytes }, { "hashes", hashes.Select(h => h.Value).ToList() } }); } return(result.Trytes.Select(tryte => new TransactionTrytes(tryte)).ToList()); }
public void ShouldGetTrytes() { GetTrytesResponse trytes = _iotaApi.IotaClient.GetTrytes(TEST_HASH); Assert.IsNotNull(trytes); Assert.AreEqual(1, trytes.Trytes.Count, "getTrytes should send back 1 transaction trytes"); }
private Bundle TraverseBundle(string trunkTransaction, string bundleHash, Bundle bundle) { GetTrytesResponse gtr = GetTrytes(trunkTransaction); if (gtr.Trytes.Count == 0) { throw new InvisibleBundleTransactionException(); } string trytes = gtr.Trytes[0]; Transaction transaction = new Transaction(trytes, curl); // If first transaction to search is not a tail, return error if (bundleHash == null && transaction.Index != 0) { throw new InvalidTailTransactionException(); } // If no bundle hash, define it if (bundleHash == null) { bundleHash = transaction.Bundle; } // If different bundle hash, return with bundle if (bundleHash != transaction.Bundle) { return(bundle); } // If only one bundle element, return if (long.Parse(transaction.LastIndex) == 0 && long.Parse(transaction.CurrentIndex) == 0) { return(new Bundle(new List <Transaction>() { transaction }, 1)); } // Define new trunkTransaction for search var trunkTx = transaction.TrunkTransaction; // Add transaction object to bundle bundle.Transactions.Add(transaction); // Continue traversing with new trunkTx return(TraverseBundle(trunkTx, bundleHash, bundle)); }
/// <summary> /// Gets the transactions objects. /// </summary> /// <param name="hashes">The hashes in trytes</param> /// <returns>a list of transactions</returns> public List <Transaction> GetTransactionsObjects(string[] hashes) { if (!InputValidator.IsArrayOfHashes(hashes)) { throw new IllegalStateException("Not an Array of Hashes: " + hashes.ToString()); } GetTrytesResponse trytesResponse = GetTrytes(hashes); List <Transaction> trxs = new List <Transaction>(); foreach (string tryte in trytesResponse.Trytes) { trxs.Add(new Transaction(tryte, curl)); } return(trxs); }
public void shouldGetTrytes() { GetTrytesResponse res = iotaApi.GetTrytes(TEST_HASH); Assert.IsNotNull(res.Trytes); }