use of duckutil.Pair in project snowblossom by snowblossomcoin.
the class HistoryUtil method printHistory.
public static void printHistory(PrintStream out, WalletDatabase db, NetworkParams params, SnowBlossomClient client) {
HashSet<AddressSpecHash> all = new HashSet<>();
all.addAll(WalletUtil.getAddressesByAge(db, params));
TreeSet<Pair<Integer, ChainHash>> transaction_history = new TreeSet<>();
TreeSet<ChainHash> mempool_list = new TreeSet<>();
boolean incomplete_no_history = false;
// If this gets super slow, parallelize this loop
for (AddressSpecHash hash : all) {
HistoryList hl = client.getStub().getAddressHistory(RequestAddress.newBuilder().setAddressSpecHash(hash.getBytes()).build());
if (hl.getNotEnabled()) {
incomplete_no_history = true;
}
for (HistoryEntry e : hl.getEntriesList()) {
int height = e.getBlockHeight();
ChainHash tx_hash = new ChainHash(e.getTxHash());
transaction_history.add(new Pair(height, tx_hash));
}
TransactionHashList tl = client.getStub().getMempoolTransactionList(RequestAddress.newBuilder().setAddressSpecHash(hash.getBytes()).build());
for (ByteString h : tl.getTxHashesList()) {
ChainHash tx_hash = new ChainHash(h);
mempool_list.add(tx_hash);
}
}
if (incomplete_no_history) {
out.println("THIS HISTORY IS MISSING - CONNECTED NODE DOES NOT SUPPORT ADDRESS HISTORY");
}
for (ChainHash tx_hash : mempool_list) {
Transaction tx = getTx(tx_hash, client);
out.println(String.format("pending / %s", getSummaryLine(tx, all, params, client)));
}
for (Pair<Integer, ChainHash> p : transaction_history.descendingSet()) {
int block = p.getA();
ChainHash tx_hash = p.getB();
Transaction tx = getTx(tx_hash, client);
out.println(String.format("block %d / %s", block, getSummaryLine(tx, all, params, client)));
}
}
Aggregations