Android adjustments
+ stylish string for block data + small fixes
This commit is contained in:
parent
8fcf969533
commit
7757a23147
|
@ -257,6 +257,28 @@ public class Block {
|
|||
toStringBuff.append("]");
|
||||
return toStringBuff.toString();
|
||||
}
|
||||
|
||||
public String toStylishString(){
|
||||
|
||||
if (!parsed) parseRLP();
|
||||
|
||||
toStringBuff.setLength(0);
|
||||
toStringBuff.append("<font color=\"${header_color}\"> BlockData </font> [");
|
||||
toStringBuff.append(" <font color=\"${attribute_color}\"> hash</font>=" +
|
||||
ByteUtil.toHexString(this.getHash())).append("<br/>");
|
||||
toStringBuff.append(header.toStylishString());
|
||||
|
||||
for (TransactionReceipt tx : getTxReceiptList()) {
|
||||
|
||||
toStringBuff.append("<br/>");
|
||||
toStringBuff.append( tx.toStylishString() );
|
||||
toStringBuff.append("<br/>");
|
||||
}
|
||||
|
||||
toStringBuff.append("]");
|
||||
return toStringBuff.toString();
|
||||
|
||||
}
|
||||
|
||||
private void parseTxs(RLPList txReceipts) {
|
||||
|
||||
|
|
|
@ -243,5 +243,24 @@ public class BlockHeader {
|
|||
toStringBuff.append(" nonce=" + ByteUtil.toHexString(nonce)).append("");
|
||||
return toStringBuff.toString();
|
||||
}
|
||||
|
||||
|
||||
public String toStylishString() {
|
||||
|
||||
toStringBuff.setLength(0);
|
||||
toStringBuff.append(", <font color=\"${attribute_color}\"> parentHash</font>=" + ByteUtil.toHexString(parentHash)).append("<br/>");
|
||||
toStringBuff.append(", <font color=\"${attribute_color}\"> unclesHash</font>=" + ByteUtil.toHexString(unclesHash)).append("<br/>");
|
||||
toStringBuff.append(", <font color=\"${attribute_color}\"> coinbase</font>=" + ByteUtil.toHexString(coinbase)).append("<br/>");
|
||||
toStringBuff.append(", <font color=\"${attribute_color}\"> stateRoot</font>=" + ByteUtil.toHexString(stateRoot)).append("<br/>");
|
||||
toStringBuff.append(", <font color=\"${attribute_color}\"> txTrieHash</font>=" + ByteUtil.toHexString(txTrieRoot)).append("<br/>");
|
||||
toStringBuff.append(", <font color=\"${attribute_color}\"> difficulty</font>=" + ByteUtil.toHexString(difficulty)).append("<br/>");
|
||||
toStringBuff.append(", <font color=\"${attribute_color}\"> number</font>=" + number).append("<br/>");
|
||||
toStringBuff.append(", <font color=\"${attribute_color}\"> minGasPrice</font>=" + minGasPrice).append("<br/>");
|
||||
toStringBuff.append(", <font color=\"${attribute_color}\"> gasLimit</font>=" + gasLimit).append("<br/>");
|
||||
toStringBuff.append(", <font color=\"${attribute_color}\"> gasUsed</font>=" + gasUsed).append("<br/>");
|
||||
toStringBuff.append(", <font color=\"${attribute_color}\"> timestamp</font>=" + timestamp + " (" + Utils.longToDateTime(timestamp) + ")").append("<br/>");
|
||||
toStringBuff.append(", <font color=\"${attribute_color}\"> extraData</font>=" + ByteUtil.toHexString(extraData)).append("<br/>");
|
||||
toStringBuff.append(", <font color=\"${attribute_color}\"> nonce</font>=" + ByteUtil.toHexString(nonce)).append("<br/>");
|
||||
return toStringBuff.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -222,6 +222,22 @@ public class Transaction {
|
|||
" ]";
|
||||
}
|
||||
|
||||
public String toStylishString() {
|
||||
if (!parsed) rlpParse();
|
||||
return " <font color=\"${sub_header_color}\"> TransactionData </font>[" + "<font color=\"${attribute_color}\"> hash</font>=" + ByteUtil.toHexString(hash) + "<br/>" +
|
||||
"-> , <font color=\"${attribute_color}\"> nonce</font>=" + ByteUtil.toHexString(nonce) + "<br/>" +
|
||||
"-> , <font color=\"${attribute_color}\"> gasPrice</font>=" + ByteUtil.toHexString(gasPrice) + "<br/>" +
|
||||
"-> , <font color=\"${attribute_color}\"> gas</font>=" + ByteUtil.toHexString(gasLimit) + "<br/>" +
|
||||
"-> , <font color=\"${attribute_color}\"> receiveAddress</font>=" + ByteUtil.toHexString(receiveAddress) + "<br/>" +
|
||||
"-> , <font color=\"${attribute_color}\"> value</font>=" + ByteUtil.toHexString(value) + "<br/>" +
|
||||
"-> , <font color=\"${attribute_color}\"> data</font>=" + ByteUtil.toHexString(data) + "<br/>" +
|
||||
"-> , <font color=\"${attribute_color}\"> signatureV</font>=" + signature.v + "<br/>" +
|
||||
"-> , <font color=\"${attribute_color}\"> signatureR</font>=" + ByteUtil.toHexString(BigIntegers.asUnsignedByteArray(signature.r)) + "<br/>" +
|
||||
"-> , <font color=\"${attribute_color}\"> signatureS</font>=" + ByteUtil.toHexString(BigIntegers.asUnsignedByteArray(signature.s)) + "<br/>" +
|
||||
" ]";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For signatures you have to keep also
|
||||
* RLP of the transaction without any signature data
|
||||
|
|
|
@ -45,4 +45,14 @@ public class TransactionReceipt {
|
|||
"\n , cumulativeGas=" + Hex.toHexString(cumulativeGas) +
|
||||
']';
|
||||
}
|
||||
|
||||
|
||||
public String toStylishString() {
|
||||
return "<font color=\"${sub_header_color}\"> TransactionReceipt</font>[" +
|
||||
"<br/> " + transaction.toStylishString() +
|
||||
"<br/> , <font color=\"${attribute_color}\">postTxState</font>=" + Hex.toHexString(postTxState) +
|
||||
"<br/> , <font color=\"${attribute_color}\">cumulativeGas</font>=" + Hex.toHexString(cumulativeGas) +
|
||||
']';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,10 @@ public class EthereumImpl implements Ethereum {
|
|||
|
||||
private Logger logger = LoggerFactory.getLogger("facade");
|
||||
|
||||
public EthereumImpl() {
|
||||
WorldManager.getInstance().loadBlockchain();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a peer but not this one
|
||||
* @param peerData - peer to exclude
|
||||
|
|
|
@ -42,7 +42,7 @@ public class EthereumProtocolHandler extends ChannelInboundHandlerAdapter {
|
|||
private Logger logger = LoggerFactory.getLogger("wire");
|
||||
|
||||
private Timer chainAskTimer = new Timer();
|
||||
private int secToAskForChain = 7;
|
||||
private int secToAskForChain = 1;
|
||||
|
||||
private final Timer timer = new Timer();
|
||||
|
||||
|
@ -102,7 +102,13 @@ public class EthereumProtocolHandler extends ChannelInboundHandlerAdapter {
|
|||
}
|
||||
}, 2000, 30000);
|
||||
|
||||
sendGetChain();
|
||||
chainAskTimer.scheduleAtFixedRate(new TimerTask() {
|
||||
|
||||
public void run() {
|
||||
sendGetChain();
|
||||
}
|
||||
}, 1000, secToAskForChain * 1000);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -233,7 +239,7 @@ public class EthereumProtocolHandler extends ChannelInboundHandlerAdapter {
|
|||
chainAskTimer.cancel();
|
||||
chainAskTimer.purge();
|
||||
chainAskTimer = new Timer();
|
||||
chainAskTimer.schedule(new TimerTask() {
|
||||
chainAskTimer.scheduleAtFixedRate(new TimerTask() {
|
||||
|
||||
public void run() {
|
||||
sendGetChain();
|
||||
|
@ -251,7 +257,7 @@ public class EthereumProtocolHandler extends ChannelInboundHandlerAdapter {
|
|||
chainAskTimer.cancel();
|
||||
chainAskTimer.purge();
|
||||
chainAskTimer = new Timer();
|
||||
chainAskTimer.schedule(new TimerTask() {
|
||||
chainAskTimer.scheduleAtFixedRate(new TimerTask() {
|
||||
|
||||
public void run() {
|
||||
sendGetChain();
|
||||
|
|
Loading…
Reference in New Issue