Skip to content

Instantly share code, notes, and snippets.

@davassi
Created December 20, 2016 13:21
Show Gist options
  • Save davassi/71b121ab6f82629adf057388edebd011 to your computer and use it in GitHub Desktop.
Save davassi/71b121ab6f82629adf057388edebd011 to your computer and use it in GitHub Desktop.
private void findAllUnconfirmedTransactions() {
synchronized (StorageScratchpad.instance().getAnalyzedTransactionsFlags()) {
// get the hash of the last milestone.
final Hash milestone = Milestone.getHashOfLastMilestoneIndex();
if (milestone != null) {
// get the trunk transaction hash
long pointer = StorageTransactions.instance().transactionPointer(milestone.bytes());
final Transaction transaction = StorageTransactions.instance().loadTransaction(pointer);
log.info("Trunk Transaction hash of last milestone: {}", transaction.trunkTransaction);
final List<Transaction> trx = findAllTransactionsChainedTo(pointer, transaction.trunkTransaction);
log.info("Found {} txs", trx.size());
}
}
}
private List<Transaction> findAllTransactionsChainedTo(long pointer, byte[] trunkTransaction) {
List<Transaction> trx = new ArrayList<>();
while (pointer < ofWhat???) { // how do I get the ending pointer of the tangle?
Transaction t = (loadTransaction(pointer));
if (t.trunkTransaction.equals(trunkTransaction)) {
trx.add(t);
}
pointer += CELL_SIZE;
}
return trx;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment