mirror of
https://github.com/jwinterm/LightWallet2.git
synced 2026-10-17 05:21:26 +02:00
Got timestamp and reward working on daemon interface.
This commit is contained in:
@@ -11,8 +11,8 @@ public class BlockHeader {
|
||||
int nonce;
|
||||
boolean orphan_status;
|
||||
String prev_hash;
|
||||
int reward;
|
||||
int timestamp;
|
||||
long reward;
|
||||
long timestamp;
|
||||
|
||||
|
||||
public int getDepth() {
|
||||
@@ -69,16 +69,16 @@ public class BlockHeader {
|
||||
public void setPrev_hash(String prev_hash) {
|
||||
this.prev_hash = prev_hash;
|
||||
}
|
||||
public int getReward() {
|
||||
public long getReward() {
|
||||
return reward;
|
||||
}
|
||||
public void setReward(int reward) {
|
||||
public void setReward(long reward) {
|
||||
this.reward = reward;
|
||||
}
|
||||
public int getTimestamp() {
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
public void setTimestamp(int timestamp) {
|
||||
public void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.jw.lightwallet.utils.Constants;
|
||||
import com.jw.lightwallet.utils.DaemonValues;
|
||||
import java.util.Date;
|
||||
|
||||
public class DaemonView {
|
||||
|
||||
@@ -21,50 +22,60 @@ public class DaemonView {
|
||||
Label heightvalue;
|
||||
Label hashratelabel;
|
||||
Label hashratevalue;
|
||||
Label timelabel;
|
||||
Label timevalue;
|
||||
Label rewardlabel;
|
||||
Label rewardvalue;
|
||||
|
||||
|
||||
int padvalue;
|
||||
|
||||
|
||||
public DaemonView () {
|
||||
|
||||
Skin uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
|
||||
daemonlayout = new Table();
|
||||
|
||||
padvalue = 15;
|
||||
|
||||
|
||||
nodelabel = new Label("Node address: ", uiSkin);
|
||||
nodevalue = new Label(null, uiSkin);
|
||||
daemonlayout.add(nodelabel).pad(20);
|
||||
daemonlayout.add(nodevalue).pad(20).row();
|
||||
daemonlayout.add(nodelabel).pad(padvalue);
|
||||
daemonlayout.add(nodevalue).pad(padvalue).row();
|
||||
|
||||
statuslabel = new Label("Node status: ", uiSkin);
|
||||
statusvalue = new Label(null, uiSkin);
|
||||
daemonlayout.add(statuslabel).pad(20);
|
||||
daemonlayout.add(statusvalue).pad(20).row();
|
||||
daemonlayout.add(statuslabel).pad(padvalue);
|
||||
daemonlayout.add(statusvalue).pad(padvalue).row();
|
||||
|
||||
heightlabel = new Label("Block height: ", uiSkin);
|
||||
heightvalue = new Label(null, uiSkin);
|
||||
daemonlayout.add(heightlabel).pad(20);
|
||||
daemonlayout.add(heightvalue).pad(20).row();
|
||||
daemonlayout.add(heightlabel).pad(padvalue);
|
||||
daemonlayout.add(heightvalue).pad(padvalue).row();
|
||||
|
||||
hashratelabel = new Label("Network hashrate: ", uiSkin);
|
||||
hashratevalue = new Label(null, uiSkin);
|
||||
daemonlayout.add(hashratelabel).pad(20);
|
||||
daemonlayout.add(hashratevalue).pad(20).row();
|
||||
daemonlayout.add(hashratelabel).pad(padvalue);
|
||||
daemonlayout.add(hashratevalue).pad(padvalue).row();
|
||||
|
||||
timelabel = new Label("Last block time: ", uiSkin);
|
||||
timevalue = new Label(null, uiSkin);
|
||||
daemonlayout.add(timelabel).pad(padvalue);
|
||||
daemonlayout.add(timevalue).pad(padvalue).row();
|
||||
|
||||
rewardlabel = new Label("Last reward: ", uiSkin);
|
||||
rewardvalue = new Label(null, uiSkin);
|
||||
daemonlayout.add(rewardlabel).pad(20);
|
||||
daemonlayout.add(rewardvalue).pad(20).row();
|
||||
daemonlayout.add(rewardlabel).pad(padvalue);
|
||||
daemonlayout.add(rewardvalue).pad(padvalue).row();
|
||||
}
|
||||
|
||||
public void Update(DaemonValues daemonvalues) {
|
||||
nodevalue.setText(Constants.moneroclub);
|
||||
statusvalue.setText(daemonvalues.getStatus());
|
||||
heightvalue.setText(String.valueOf(daemonvalues.getBlockheight()));
|
||||
hashratevalue.setText(String.valueOf(daemonvalues.getHashrate()));
|
||||
rewardvalue.setText(String.valueOf(daemonvalues.getLastblockreward()));
|
||||
hashratevalue.setText(String.valueOf(daemonvalues.getHashrate() + " Mh/s"));
|
||||
timevalue.setText(String.valueOf(new java.util.Date(daemonvalues.getLastblocktime()*1000)));
|
||||
rewardvalue.setText(String.valueOf(daemonvalues.getLastblockreward()/1e12 + " XMR"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class MainScreen extends AbstractScreen {
|
||||
buttonrow.add(txhistorybutton).width(Constants.WORLD_WIDTH/4);
|
||||
screenlayout.add(buttonrow).row();
|
||||
|
||||
screenlayout.add(logo).center().row();
|
||||
screenlayout.add(logo).pad(10).center().row();
|
||||
|
||||
daemonview = new DaemonView();
|
||||
viewcontainer.add(daemonview.daemonlayout).expand().bottom();
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.jw.lightwallet.utils;
|
||||
|
||||
public class DaemonValues {
|
||||
|
||||
int blockheight;
|
||||
int diff;
|
||||
int hashrate;
|
||||
int lastblocktime;
|
||||
int lastblockreward;
|
||||
int blockheight;
|
||||
int diff;
|
||||
int hashrate;
|
||||
long lastblocktime;
|
||||
long lastblockreward;
|
||||
String status;
|
||||
|
||||
|
||||
@@ -24,21 +24,21 @@ public class DaemonValues {
|
||||
this.diff = diff;
|
||||
this.hashrate = diff/60;
|
||||
}
|
||||
public int getHashrate() {
|
||||
return hashrate;
|
||||
public float getHashrate() {
|
||||
return hashrate/1e6f;
|
||||
}
|
||||
|
||||
public int getLastblocktime() {
|
||||
public long getLastblocktime() {
|
||||
return lastblocktime;
|
||||
}
|
||||
public void setLastblocktime(int lastblocktime) {
|
||||
public void setLastblocktime(long lastblocktime) {
|
||||
this.lastblocktime = lastblocktime;
|
||||
}
|
||||
|
||||
public float getLastblockreward() {
|
||||
return lastblockreward/1e12f;
|
||||
public long getLastblockreward() {
|
||||
return lastblockreward;
|
||||
}
|
||||
public void setLastblockreward(int lastblockreward) {
|
||||
public void setLastblockreward(long lastblockreward) {
|
||||
this.lastblockreward = lastblockreward;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user