Merge branch 'master' of https://github.com/nicksavers/ethereumj
Conflicts: src/main/java/org/ethereum/manager/MainData.java
This commit is contained in:
commit
7262f13181
|
@ -125,11 +125,11 @@ public class Block {
|
|||
byte[] guBytes = ((RLPItem) header.get(9)).getRLPData();
|
||||
byte[] tsBytes = ((RLPItem) header.get(10)).getRLPData();
|
||||
|
||||
this.number = nrBytes == null ? 0 : (new BigInteger(nrBytes)).longValue();
|
||||
this.minGasPrice = gpBytes == null ? 0 : (new BigInteger(gpBytes)).longValue();
|
||||
this.gasLimit = glBytes == null ? 0 : (new BigInteger(glBytes)).longValue();
|
||||
this.gasUsed = guBytes == null ? 0 : (new BigInteger(guBytes)).longValue();
|
||||
this.timestamp = tsBytes == null ? 0 : (new BigInteger(tsBytes)).longValue();
|
||||
this.number = nrBytes == null ? 0 : (new BigInteger(1, nrBytes)).longValue();
|
||||
this.minGasPrice = gpBytes == null ? 0 : (new BigInteger(1, gpBytes)).longValue();
|
||||
this.gasLimit = glBytes == null ? 0 : (new BigInteger(1, glBytes)).longValue();
|
||||
this.gasUsed = guBytes == null ? 0 : (new BigInteger(1, guBytes)).longValue();
|
||||
this.timestamp = tsBytes == null ? 0 : (new BigInteger(1, tsBytes)).longValue();
|
||||
|
||||
this.extraData = ((RLPItem) header.get(11)).getRLPData();
|
||||
this.nonce = ((RLPItem) header.get(12)).getRLPData();
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.awt.datatransfer.Clipboard;
|
|||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
/**
|
||||
* www.ethereumJ.com
|
||||
|
@ -26,7 +25,6 @@ public class BlockChainTable extends JFrame {
|
|||
|
||||
private int lastFindIndex = 0;
|
||||
|
||||
|
||||
public BlockChainTable() {
|
||||
|
||||
final BlockChainTable blockChainTable = this;
|
||||
|
@ -110,15 +108,12 @@ public class BlockChainTable extends JFrame {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Add the table to a scrolling pane
|
||||
scrollPane = new JScrollPane(table);
|
||||
topPanel.add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String args[]){
|
||||
|
||||
BlockChainTable mainFrame = new BlockChainTable();
|
||||
mainFrame.setVisible(true);
|
||||
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.math.BigInteger;
|
|||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
* www.ethereumJ.com
|
||||
* User: Roman Mandeleil
|
||||
|
@ -30,15 +29,11 @@ import java.util.Collection;
|
|||
*/
|
||||
class ContractCallDialog extends JDialog implements MessageAwareDialog{
|
||||
|
||||
|
||||
ContractCallDialog dialog;
|
||||
JComboBox<AddressStateWraper> creatorAddressCombo;
|
||||
final JTextField gasInput;
|
||||
final JTextField contractAddrInput;
|
||||
JTextArea msgDataTA;
|
||||
|
||||
|
||||
|
||||
JLabel statusMsg = null;
|
||||
|
||||
public ContractCallDialog(Frame parent) {
|
||||
|
@ -87,14 +82,12 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog{
|
|||
rejectLabel.setBounds(260, 325, 45, 45);
|
||||
this.getContentPane().add(rejectLabel);
|
||||
rejectLabel.setVisible(true);
|
||||
rejectLabel.addMouseListener(
|
||||
new MouseAdapter() {
|
||||
rejectLabel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
|
||||
dialog.dispose();
|
||||
}}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
URL approveIconURL = ClassLoader.getSystemResource("buttons/approve.png");
|
||||
ImageIcon approveIcon = new ImageIcon(approveIconURL);
|
||||
|
@ -120,9 +113,7 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog{
|
|||
JComboBox<AddressStateWraper> creatorAddressCombo = new JComboBox<AddressStateWraper>() {
|
||||
@Override
|
||||
public ComboBoxUI getUI() {
|
||||
|
||||
BasicComboBoxUI ui = (BasicComboBoxUI) super.getUI();
|
||||
|
||||
return super.getUI();
|
||||
}
|
||||
};
|
||||
|
@ -142,12 +133,10 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog{
|
|||
MainData.instance.getWallet().getAddressStateCollection();
|
||||
|
||||
for (AddressState addressState : addressStates){
|
||||
|
||||
creatorAddressCombo.addItem(new AddressStateWraper(addressState));
|
||||
}
|
||||
|
||||
creatorAddressCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
setBackground(Color.WHITE);
|
||||
|
@ -156,7 +145,6 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog{
|
|||
setBorder(BorderFactory.createEmptyBorder());
|
||||
super.paint(g);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
creatorAddressCombo.setPopupVisible(false);
|
||||
|
@ -168,13 +156,10 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog{
|
|||
list.setSelectionBackground(Color.cyan);
|
||||
list.setBorder(null);
|
||||
|
||||
for (int i = 0; i < creatorAddressCombo.getComponentCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < creatorAddressCombo.getComponentCount(); i++) {
|
||||
if (creatorAddressCombo.getComponent(i) instanceof CellRendererPane) {
|
||||
|
||||
CellRendererPane crp = ((CellRendererPane) (creatorAddressCombo.getComponent(i)));
|
||||
}
|
||||
|
||||
if (creatorAddressCombo.getComponent(i) instanceof AbstractButton) {
|
||||
((AbstractButton) creatorAddressCombo.getComponent(i)).setBorder(line);
|
||||
}
|
||||
|
@ -182,7 +167,6 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog{
|
|||
creatorAddressCombo.setBounds(73, 267, 230, 36);
|
||||
this.getContentPane().add(creatorAddressCombo);
|
||||
|
||||
|
||||
this.getContentPane().revalidate();
|
||||
this.getContentPane().repaint();
|
||||
this.setResizable(false);
|
||||
|
@ -212,7 +196,6 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog{
|
|||
this.setSize(500, 430);
|
||||
this.setVisible(true);
|
||||
|
||||
|
||||
return rootPane;
|
||||
}
|
||||
|
||||
|
@ -226,7 +209,6 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog{
|
|||
this.statusMsg.setText(text);
|
||||
}
|
||||
|
||||
|
||||
public void submitContract(){
|
||||
|
||||
ClientPeer peer = MainData.instance.getActivePeer();
|
||||
|
@ -241,7 +223,6 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog{
|
|||
|
||||
byte[] contractAddress = Hex.decode( contractAddrInput.getText());
|
||||
|
||||
|
||||
AddressState addressState = ((AddressStateWraper)creatorAddressCombo.getSelectedItem()).getAddressState();
|
||||
|
||||
byte[] senderPrivKey = addressState.getEcKey().getPrivKeyBytes();
|
||||
|
@ -252,7 +233,6 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog{
|
|||
byte[] gasValue = BigIntegers.asUnsignedByteArray(gasBI);
|
||||
byte[] endowment = BigIntegers.asUnsignedByteArray(new BigInteger("1000"));
|
||||
|
||||
|
||||
Transaction tx = new Transaction(nonce, gasPrice, gasValue,
|
||||
contractAddress, endowment, data);
|
||||
|
||||
|
@ -264,16 +244,11 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog{
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
// SwingWorker
|
||||
DialogWorker worker = new DialogWorker(tx, this);
|
||||
worker.execute();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public class AddressStateWraper {
|
||||
|
||||
private AddressState addressState;
|
||||
|
@ -290,11 +265,8 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog{
|
|||
public String toString() {
|
||||
String addressShort = Utils.getAddressShortString(addressState.getEcKey().getAddress());
|
||||
String valueShort = Utils.getValueShortString(addressState.getBalance());
|
||||
|
||||
String result =
|
||||
String.format(" By: [%s] %s",
|
||||
addressShort, valueShort);
|
||||
|
||||
String result = String.format(" By: [%s] %s", addressShort,
|
||||
valueShort);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
package org.ethereum.manager;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.*;
|
||||
|
||||
import com.maxmind.geoip.Location;
|
||||
import org.ethereum.config.SystemProperties;
|
||||
import org.ethereum.core.Block;
|
||||
import org.ethereum.core.Genesis;
|
||||
import org.ethereum.core.Transaction;
|
||||
import org.ethereum.core.Wallet;
|
||||
import org.ethereum.crypto.ECKey;
|
||||
|
@ -60,8 +57,12 @@ public class MainData {
|
|||
System.exit(-1);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
PeerData peer = new PeerData(
|
||||
ip.getAddress(), port, new byte[]{00});
|
||||
=======
|
||||
PeerData peer = new PeerData(ip.getAddress(), (short) 30303, new byte[] { 00 });
|
||||
>>>>>>> d52f5868c293bff76394d6e014833a7dd17b5722
|
||||
peers.add(peer);
|
||||
|
||||
byte[] cowAddr = HashUtil.sha3("cow".getBytes());
|
||||
|
@ -75,7 +76,6 @@ public class MainData {
|
|||
peerDiscovery = new PeerDiscovery(peers);
|
||||
}
|
||||
|
||||
|
||||
public void addBlocks(List<Block> blocks) {
|
||||
|
||||
// TODO: redesign this part when the state part and the genesis block is ready
|
||||
|
@ -109,7 +109,6 @@ public class MainData {
|
|||
// Remove all pending transactions as they already approved by the net
|
||||
for (Block block : blocks){
|
||||
for (Transaction tx : block.getTransactionsList()){
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("pending cleanup: tx.hash: [{}]", Hex.toHexString( tx.getHash()));
|
||||
pendingTransactions.remove(tx.getHash());
|
||||
|
@ -141,7 +140,6 @@ public class MainData {
|
|||
return activePeer;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 1) the dialog put a pending transaction on the list
|
||||
* 2) the dialog send the transaction to a net
|
||||
|
@ -158,11 +156,9 @@ public class MainData {
|
|||
if (pendingTransaction != null)
|
||||
pendingTransaction.incApproved();
|
||||
else {
|
||||
|
||||
pendingTransaction = new PendingTransaction(transaction);
|
||||
pendingTransactions.put(hash, pendingTransaction);
|
||||
}
|
||||
|
||||
return pendingTransaction;
|
||||
}
|
||||
|
||||
|
@ -171,11 +167,8 @@ public class MainData {
|
|||
}
|
||||
|
||||
public void updatePeerIsDead(String ip, short port){
|
||||
|
||||
for (PeerData peer : peers) {
|
||||
|
||||
if (peer.getInetAddress().getHostAddress().equals(ip) && (peer.getPort() == port)){
|
||||
|
||||
System.out.println("update peer is dead: " + ip + ":" + port);
|
||||
peer.setOnline(false);
|
||||
break;
|
||||
|
@ -184,24 +177,19 @@ public class MainData {
|
|||
}
|
||||
|
||||
public void addPeers(List<PeerData> newPeers){
|
||||
|
||||
for (PeerData peer : newPeers){
|
||||
if (this.peers.indexOf(peer) == -1){
|
||||
|
||||
Location location = IpGeoDB.getLocationForIp(peer.getInetAddress());
|
||||
if (location != null){
|
||||
this.peers.add(peer);
|
||||
|
||||
if (peerDiscovery.isStarted())
|
||||
peerDiscovery.addNewPeerData(peer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void startPeerDiscovery(){
|
||||
peerDiscovery.start();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue