Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
0dd09c4d4c
|
@ -9,9 +9,12 @@ import org.ethereum.net.BlockQueue;
|
||||||
import org.ethereum.net.server.ChannelManager;
|
import org.ethereum.net.server.ChannelManager;
|
||||||
import org.ethereum.util.AdvancedDeviceUtils;
|
import org.ethereum.util.AdvancedDeviceUtils;
|
||||||
import org.ethereum.vm.ProgramInvokeFactory;
|
import org.ethereum.vm.ProgramInvokeFactory;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.FileSystemUtils;
|
import org.springframework.util.FileSystemUtils;
|
||||||
|
@ -20,7 +23,9 @@ import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -166,10 +171,11 @@ public class BlockchainImpl implements Blockchain {
|
||||||
channelManager.ethSync();
|
channelManager.ethSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!hasParentOnTheChain(block) && block.getNumber() > bestBlock.getNumber()) {
|
if (!hasParentOnTheChain(block) && block.getNumber() > bestBlock.getNumber()) {
|
||||||
|
|
||||||
if (1==1)return; // todo: temporary cancel the rollback
|
if (1 == 1)
|
||||||
|
return; // todo: temporary cancel the rollback
|
||||||
|
|
||||||
logger.info("*** Blockchain will rollback and resynchronise now ");
|
logger.info("*** Blockchain will rollback and resynchronise now ");
|
||||||
|
|
||||||
long rollbackIdx = bestBlock.getNumber() - 30;
|
long rollbackIdx = bestBlock.getNumber() - 30;
|
||||||
|
@ -233,7 +239,6 @@ public class BlockchainImpl implements Blockchain {
|
||||||
|
|
||||||
logger.info("Sync done");
|
logger.info("Sync done");
|
||||||
syncDoneCalled = true;
|
syncDoneCalled = true;
|
||||||
|
|
||||||
listener.onSyncDone();
|
listener.onSyncDone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -417,7 +422,6 @@ public class BlockchainImpl implements Blockchain {
|
||||||
logger.debug("block added to the blockChain: index: [{}]", block.getNumber());
|
logger.debug("block added to the blockChain: index: [{}]", block.getNumber());
|
||||||
if (block.getNumber() % 100 == 0)
|
if (block.getNumber() % 100 == 0)
|
||||||
logger.info("*** Last block added [ #{} ]", block.getNumber());
|
logger.info("*** Last block added [ #{} ]", block.getNumber());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,9 @@ import java.math.BigInteger;
|
||||||
public enum Denomination {
|
public enum Denomination {
|
||||||
|
|
||||||
WEI(newBigInt(0)),
|
WEI(newBigInt(0)),
|
||||||
ADA(newBigInt(3)),
|
|
||||||
BABBAGE(newBigInt(6)),
|
|
||||||
SHANNON(newBigInt(9)),
|
|
||||||
SZABO(newBigInt(12)),
|
SZABO(newBigInt(12)),
|
||||||
FINNY(newBigInt(15)),
|
FINNEY(newBigInt(15)),
|
||||||
ETHER(newBigInt(18)),
|
ETHER(newBigInt(18));
|
||||||
EINSTEIN(newBigInt(21)),
|
|
||||||
DOUGLAS(newBigInt(42));
|
|
||||||
|
|
||||||
private BigInteger amount;
|
private BigInteger amount;
|
||||||
|
|
||||||
|
@ -33,30 +28,15 @@ public enum Denomination {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toFriendlyString(BigInteger value) {
|
public static String toFriendlyString(BigInteger value) {
|
||||||
if(value.compareTo(DOUGLAS.value()) == 1 || value.compareTo(DOUGLAS.value()) == 0) {
|
if (value.compareTo(ETHER.value()) == 1 || value.compareTo(ETHER.value()) == 0) {
|
||||||
return Float.toString(value.divide(DOUGLAS.value()).floatValue()) + " DOUGLAS";
|
|
||||||
}
|
|
||||||
else if(value.compareTo(EINSTEIN.value()) == 1 || value.compareTo(EINSTEIN.value()) == 0) {
|
|
||||||
return Float.toString(value.divide(EINSTEIN.value()).floatValue()) + " EINSTEIN";
|
|
||||||
}
|
|
||||||
else if(value.compareTo(ETHER.value()) == 1 || value.compareTo(ETHER.value()) == 0) {
|
|
||||||
return Float.toString(value.divide(ETHER.value()).floatValue()) + " ETHER";
|
return Float.toString(value.divide(ETHER.value()).floatValue()) + " ETHER";
|
||||||
}
|
}
|
||||||
else if(value.compareTo(FINNY.value()) == 1 || value.compareTo(FINNY.value()) == 0) {
|
else if(value.compareTo(FINNEY.value()) == 1 || value.compareTo(FINNEY.value()) == 0) {
|
||||||
return Float.toString(value.divide(FINNY.value()).floatValue()) + " FINNY";
|
return Float.toString(value.divide(FINNEY.value()).floatValue()) + " FINNEY";
|
||||||
}
|
}
|
||||||
else if(value.compareTo(SZABO.value()) == 1 || value.compareTo(SZABO.value()) == 0) {
|
else if(value.compareTo(SZABO.value()) == 1 || value.compareTo(SZABO.value()) == 0) {
|
||||||
return Float.toString(value.divide(SZABO.value()).floatValue()) + " SZABO";
|
return Float.toString(value.divide(SZABO.value()).floatValue()) + " SZABO";
|
||||||
}
|
}
|
||||||
else if(value.compareTo(SHANNON.value()) == 1 || value.compareTo(SHANNON.value()) == 0) {
|
|
||||||
return Float.toString(value.divide(SHANNON.value()).floatValue()) + " SHANNON";
|
|
||||||
}
|
|
||||||
else if(value.compareTo(BABBAGE.value()) == 1 || value.compareTo(BABBAGE.value()) == 0) {
|
|
||||||
return Float.toString(value.divide(BABBAGE.value()).floatValue()) + " BABBAGE";
|
|
||||||
}
|
|
||||||
else if(value.compareTo(ADA.value()) == 1 || value.compareTo(ADA.value()) == 0) {
|
|
||||||
return Float.toString(value.divide(ADA.value()).floatValue()) + " ADA";
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
return Float.toString(value.divide(WEI.value()).floatValue()) + " WEI";
|
return Float.toString(value.divide(WEI.value()).floatValue()) + " WEI";
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,8 +164,6 @@ public class EthHandler extends SimpleChannelInboundHandler<EthMessage> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void processTransactions(TransactionsMessage msg) {
|
private void processTransactions(TransactionsMessage msg) {
|
||||||
|
|
||||||
Set<Transaction> txSet = msg.getTransactions();
|
Set<Transaction> txSet = msg.getTransactions();
|
||||||
|
@ -249,9 +247,6 @@ public class EthHandler extends SimpleChannelInboundHandler<EthMessage> {
|
||||||
private void processBlockHashes(BlockHashesMessage blockHashesMessage) {
|
private void processBlockHashes(BlockHashesMessage blockHashesMessage) {
|
||||||
|
|
||||||
List<byte[]> receivedHashes = blockHashesMessage.getBlockHashes();
|
List<byte[]> receivedHashes = blockHashesMessage.getBlockHashes();
|
||||||
|
|
||||||
// receivedHashes.forEach(hash -> System.out.println(Hex.toHexString(hash)));
|
|
||||||
|
|
||||||
BlockQueue chainQueue = blockchain.getQueue();
|
BlockQueue chainQueue = blockchain.getQueue();
|
||||||
|
|
||||||
// result is empty, peer has no more hashes
|
// result is empty, peer has no more hashes
|
||||||
|
|
|
@ -5,7 +5,12 @@ import org.ethereum.crypto.HashUtil;
|
||||||
import org.ethereum.net.client.Capability;
|
import org.ethereum.net.client.Capability;
|
||||||
import org.ethereum.net.eth.EthHandler;
|
import org.ethereum.net.eth.EthHandler;
|
||||||
import org.ethereum.net.eth.GetTransactionsMessage;
|
import org.ethereum.net.eth.GetTransactionsMessage;
|
||||||
import org.ethereum.net.p2p.*;
|
import org.ethereum.net.p2p.DisconnectMessage;
|
||||||
|
import org.ethereum.net.p2p.GetPeersMessage;
|
||||||
|
import org.ethereum.net.p2p.HelloMessage;
|
||||||
|
import org.ethereum.net.p2p.P2pHandler;
|
||||||
|
import org.ethereum.net.p2p.PingMessage;
|
||||||
|
import org.ethereum.net.p2p.PongMessage;
|
||||||
import org.ethereum.net.shh.ShhHandler;
|
import org.ethereum.net.shh.ShhHandler;
|
||||||
|
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.ethereum.net.p2p;
|
package org.ethereum.net.p2p;
|
||||||
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
|
||||||
import org.ethereum.core.Block;
|
import org.ethereum.core.Block;
|
||||||
import org.ethereum.core.Transaction;
|
import org.ethereum.core.Transaction;
|
||||||
import org.ethereum.manager.WorldManager;
|
import org.ethereum.manager.WorldManager;
|
||||||
|
@ -16,19 +14,30 @@ import org.ethereum.net.message.StaticMessages;
|
||||||
import org.ethereum.net.peerdiscovery.PeerInfo;
|
import org.ethereum.net.peerdiscovery.PeerInfo;
|
||||||
import org.ethereum.net.shh.ShhHandler;
|
import org.ethereum.net.shh.ShhHandler;
|
||||||
import org.ethereum.net.shh.ShhMessageCodes;
|
import org.ethereum.net.shh.ShhMessageCodes;
|
||||||
|
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.*;
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import static org.ethereum.net.message.StaticMessages.*;
|
import static org.ethereum.net.message.StaticMessages.*;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the basic protocol messages between every peer on the network.
|
* Process the basic protocol messages between every peer on the network.
|
||||||
*
|
*
|
||||||
|
@ -277,8 +286,6 @@ public class P2pHandler extends SimpleChannelInboundHandler<P2pMessage> {
|
||||||
return handshakeHelloMessage;
|
return handshakeHelloMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void startTimers() {
|
private void startTimers() {
|
||||||
// sample for pinging in background
|
// sample for pinging in background
|
||||||
|
|
||||||
|
|
|
@ -108,9 +108,7 @@ public class ChannelManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reconnect(){
|
public void reconnect(){
|
||||||
for (Channel channel : channels){
|
channels.forEach(c -> c.p2pHandler.sendDisconnect());
|
||||||
channel.p2pHandler.sendDisconnect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ethSync() {
|
public void ethSync() {
|
||||||
|
|
Loading…
Reference in New Issue