Skip to content

Commit

Permalink
Additions to shackleton
Browse files Browse the repository at this point in the history
  • Loading branch information
mjay20 committed Mar 19, 2019
1 parent ba162d6 commit e2dde19
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 78 deletions.
2 changes: 1 addition & 1 deletion lib/src/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class Globals

public static final int BLOCK_CHUNK_HEADER_DOWNLOAD_SIZE = 500;

public static final int ADDRESS_HISTORY_MAX_REPLY = 10000;
public static final int ADDRESS_HISTORY_MAX_REPLY = 500000;

public static final long MINE_CHUNK_SIZE = 1024L*1024L*1024L;

Expand Down
87 changes: 87 additions & 0 deletions lib/src/TransactionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -425,4 +425,91 @@ public static void prettyDisplayTx(Transaction tx, PrintStream out, NetworkParam

}

public static void prettyDisplayTxHTML(Transaction tx, PrintStream out, NetworkParams params, LinkedList<Double> inValues)
throws ValidationException
{
out.println("<table class='table' style='max-width: 1400px;'><tr><th colspan=2>");

ChainHash tx_hash = new ChainHash(tx.getTxHash());
out.println("Transaction: " + tx_hash + " size: " + tx.toByteString().size());
TreeSet<String> sign_set=new TreeSet<>();
DecimalFormat df = new DecimalFormat("0.000000");
DecimalFormat df_short = new DecimalFormat("0.00");

for(SignatureEntry se : tx.getSignaturesList())
{
String key = "" + se.getClaimIdx() + ":" + se.getKeyIdx();
sign_set.add(key);
}

TransactionInner inner = getInner(tx);


out.println("</th></tr><tr><th>Inputs</th><th>Outputs</th></tr><tr><td style='width: 50%;'>");

if (inner.getIsCoinbase())
{
CoinbaseExtras extras = inner.getCoinbaseExtras();
out.print(" Coinbase - height: ");
out.print(extras.getBlockHeight());
out.print("<br /> remark: <b>");
out.print(HexUtil.getSafeString(extras.getRemarks()));
out.println("</b>");
if (extras.getMotionsApprovedCount() > 0)
{
out.print("<br /> Motions Approved:" );
for(int i : extras.getMotionsApprovedList())
{
out.print(' ');
out.print(i);
}
out.println("<br />");
}
if (extras.getMotionsRejectedCount() > 0)
{
out.print("<br /> Motions Rejected:" );
for(int i : extras.getMotionsRejectedList())
{
out.print(' ');
out.print(i);
}
out.println("<br />");
}
}

for(TransactionInput in : inner.getInputsList())
{
String address = AddressUtil.getAddressString(params.getAddressPrefix(), new AddressSpecHash( in.getSpecHash()));
ChainHash src_tx = new ChainHash(in.getSrcTxId());
int idx = in.getSrcTxOutIdx();
double amount = inValues.get(0);
inValues.removeFirst();
out.println(String.format("<a href='/?search=%s'>%s</a> <b>%s</b><br />", address, address, df.format(amount)));
}
out.println("</td><td style='width: 50%;'>");
for(TransactionOutput o : inner.getOutputsList())
{
String address = AddressUtil.getAddressString(params.getAddressPrefix(), new AddressSpecHash( o.getRecipientSpecHash()));
double value = o.getValue() / Globals.SNOW_VALUE_D;

out.println(String.format("<a href='/?search=%s'>%s</a> <b>%s</b><br />", address, address, df.format(value)));
}

out.println("</td></tr><td colspan=2>");

double fee_flakes = inner.getFee();
double fee_flakes_per_byte = fee_flakes / tx.toByteString().size();

out.println(String.format(" Fee: %s (%s flakes per byte)",
df.format( inner.getFee() / Globals.SNOW_VALUE_D),
df_short.format( fee_flakes_per_byte )
));
if (inner.getExtra().size() > 0)
{
out.println(" Extra: " + HexUtil.getSafeString(inner.getExtra()));
}
out.println("</td></table>");
}


}
1 change: 1 addition & 0 deletions shackleton/src/AddressPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ protected void loadData()
try
{
bridges = getSpendable(address);

if (want_history)
{
history = getHistory(address);
Expand Down
42 changes: 7 additions & 35 deletions shackleton/src/RichList.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
import snowblossom.client.GetUTXOUtil;

import java.text.DecimalFormat;
import com.google.protobuf.ByteString;
import java.util.List;


public class RichList
{
Expand Down Expand Up @@ -73,24 +70,18 @@ public RichList(Config config)

System.out.println("Highest block: " + node_status.getHeadSummary().getHeader().getBlockHeight());

List<TransactionBridge> bridge_list = GetUTXOUtil.getSpendableValidatedStatic( ByteString.EMPTY, stub, node_status.getHeadSummary().getHeader().getUtxoRootHash());

getAllBlocks(node_status.getHeadSummary().getHeader());
System.out.println("Address count: " + all_addresses.size());

//getAllBlocks(node_status.getHeadSummary().getHeader());
DecimalFormat df = new DecimalFormat("0.000000");

long total_value = getAddressBalances(bridge_list);
System.out.println("Total value: " + df.format(total_value / 1e6));


System.out.println("Address count: " + balance_map.size());
getAddressBalances();

TreeMultimap<Long, String> m = TreeMultimap.create();

for(Map.Entry<String, Long> me : balance_map.entrySet())
{
m.put(-me.getValue(), me.getKey());
}
DecimalFormat df = new DecimalFormat("0.000000");
for(Map.Entry<Long, String> me : m.entries())
{
if (me.getKey() != 0L)
Expand All @@ -106,29 +97,10 @@ public RichList(Config config)

}

//HashSet<AddressSpecHash> all_addresses = new HashSet<>();
HashSet<AddressSpecHash> all_addresses = new HashSet<>();
HashMap<String, Long> balance_map = new HashMap<>();

private long getAddressBalances(List<TransactionBridge> br_lst)
{
long total = 0;
for(TransactionBridge br : br_lst)
{
AddressSpecHash spec = new AddressSpecHash( br.out.getRecipientSpecHash());
String addr = AddressUtil.getAddressString(params.getAddressPrefix(), spec);
long val = 0;
if (balance_map.containsKey(addr)) val = balance_map.get(addr);

val += br.value;
total += br.value;
balance_map.put(addr, val);
}
return total;

}


/*private void getAddressBalances()
private void getAddressBalances()
{
for(AddressSpecHash spec : all_addresses)
{
Expand Down Expand Up @@ -177,7 +149,7 @@ private void processBlock(Block blk)

}

}*/
}


}
9 changes: 3 additions & 6 deletions shackleton/src/VoteTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ private void update(NodeStatus ns, TreeMap<Integer, VoteCount> vote_map, TreeMap
public void getVotingReport(NodeStatus ns, PrintStream out)
{
if (startup)
{
out.println("Reading blocks for votes");
return;
}

TreeMap<Integer, VoteCount> vote_map=new TreeMap<>();
TreeMap<String, Integer> pool_map = new TreeMap<>();
Expand All @@ -132,15 +129,16 @@ public void getVotingReport(NodeStatus ns, PrintStream out)
for(Map.Entry<Integer, VoteCount> me : vote_map.entrySet())
{
out.println(String.format("Issue %d: %s", me.getKey(), me.getValue().toString()));
out.println("<br />");
}

TreeMultimap<Integer, String> pool_map_sort = TreeMultimap.create();
for(Map.Entry<String, Integer> me : pool_map.entrySet())
{
pool_map_sort.put(-me.getValue(), me.getKey());
}
out.println("<H2>Block Remarks in last 1000 blocks</H2>");
out.println("<table border='0' cellspacing='0'>");
out.println("<h2>Block Remarks in last 1000 blocks</h2>");
out.println("<table class='table table-hover' style='max-width: 400px;'>");
out.println("<thead><tr><th>Remarks</th><th>Count</th></tr></thead>");
for(Map.Entry<Integer, String> me : pool_map_sort.entries())
{
Expand Down Expand Up @@ -221,5 +219,4 @@ else if (rej.contains(issue))
}

}

}
Loading

0 comments on commit e2dde19

Please sign in to comment.