|
@@ -1,12 +1,14 @@ |
|
|
package com.jd.blockchain.consensus.bftsmart.service; |
|
|
package com.jd.blockchain.consensus.bftsmart.service; |
|
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
|
|
import java.net.InetSocketAddress; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.concurrent.CopyOnWriteArrayList; |
|
|
import java.util.concurrent.CopyOnWriteArrayList; |
|
|
import java.util.concurrent.ExecutorService; |
|
|
import java.util.concurrent.ExecutorService; |
|
|
import java.util.concurrent.Executors; |
|
|
import java.util.concurrent.Executors; |
|
|
|
|
|
|
|
|
import bftsmart.consensus.app.BatchAppResultImpl; |
|
|
import bftsmart.consensus.app.BatchAppResultImpl; |
|
|
|
|
|
import bftsmart.reconfiguration.views.View; |
|
|
import bftsmart.tom.*; |
|
|
import bftsmart.tom.*; |
|
|
import com.jd.blockchain.binaryproto.BinaryProtocol; |
|
|
import com.jd.blockchain.binaryproto.BinaryProtocol; |
|
|
import com.jd.blockchain.consensus.service.*; |
|
|
import com.jd.blockchain.consensus.service.*; |
|
@@ -55,9 +57,10 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer |
|
|
|
|
|
|
|
|
private BftsmartConsensusManageService manageService; |
|
|
private BftsmartConsensusManageService manageService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private volatile BftsmartTopology topology; |
|
|
private volatile BftsmartTopology topology; |
|
|
|
|
|
|
|
|
|
|
|
private volatile BftsmartTopology outerTopology; |
|
|
|
|
|
|
|
|
private volatile BftsmartConsensusSettings setting; |
|
|
private volatile BftsmartConsensusSettings setting; |
|
|
|
|
|
|
|
|
private TOMConfiguration tomConfig; |
|
|
private TOMConfiguration tomConfig; |
|
@@ -190,6 +193,9 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public BftsmartTopology getTopology() { |
|
|
public BftsmartTopology getTopology() { |
|
|
|
|
|
if (outerTopology != null) { |
|
|
|
|
|
return outerTopology; |
|
|
|
|
|
} |
|
|
return topology; |
|
|
return topology; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -512,6 +518,7 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer |
|
|
LOGGER.debug("Start replica...[ID=" + getId() + "]"); |
|
|
LOGGER.debug("Start replica...[ID=" + getId() + "]"); |
|
|
this.replica = new ServiceReplica(tomConfig, this, this); |
|
|
this.replica = new ServiceReplica(tomConfig, this, this); |
|
|
this.topology = new BftsmartTopology(replica.getReplicaContext().getCurrentView()); |
|
|
this.topology = new BftsmartTopology(replica.getReplicaContext().getCurrentView()); |
|
|
|
|
|
initOutTopology(); |
|
|
status = Status.RUNNING; |
|
|
status = Status.RUNNING; |
|
|
// createProxyClient(); |
|
|
// createProxyClient(); |
|
|
LOGGER.debug( |
|
|
LOGGER.debug( |
|
@@ -551,6 +558,24 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initOutTopology() { |
|
|
|
|
|
View currView = this.topology.getView(); |
|
|
|
|
|
int id = currView.getId(); |
|
|
|
|
|
int f = currView.getF(); |
|
|
|
|
|
int[] processes = currView.getProcesses(); |
|
|
|
|
|
InetSocketAddress[] addresses = new InetSocketAddress[processes.length]; |
|
|
|
|
|
for (int i = 0; i < processes.length; i++) { |
|
|
|
|
|
int pid = processes[i]; |
|
|
|
|
|
if (id == pid) { |
|
|
|
|
|
addresses[i] = new InetSocketAddress(this.outerTomConfig.getHost(id), this.outerTomConfig.getPort(id)); |
|
|
|
|
|
} else { |
|
|
|
|
|
addresses[i] = currView.getAddress(pid); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
View returnView = new View(id, processes, f, addresses); |
|
|
|
|
|
this.outerTopology = new BftsmartTopology(returnView); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
enum Status { |
|
|
enum Status { |
|
|
|
|
|
|
|
|
STARTING, |
|
|
STARTING, |
|
|