feat: update SelfAdaptiveShardingExecutor

update SelfAdaptiveShardingExecutor to add height to the blocks; update cmstop.sh to not print error message when process doesn't exits
This commit is contained in:
Frank.R.Wu 2021-12-03 15:29:50 +08:00
parent 802713a001
commit b975a0227a
4 changed files with 11 additions and 7 deletions

View File

@ -2,7 +2,7 @@
if [ -a "./PID" ]; then
if [ -d '/proc' ]; then
ls /proc/$(cat PID)/cmdline
ls /proc/$(cat PID)/cmdline 1>/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
kill -9 $(cat PID)
echo "shutdown old contract manager"

View File

@ -588,7 +588,7 @@ public class MasterClientRecoverMechAction {
try {
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
String line = "";
String line;
String[] arrs = null;
while ((line = br.readLine()) != null) {
content[count++] = line;

View File

@ -79,9 +79,9 @@ public class ContractRepoConfigurer implements DoipServiceInfoConfigurer {
doipServiceConfig = localConfig;
//异步注册
ContractManager.threadPool.execute(() -> {
GlobalIrpClient.useInternalIrpClient(GlobalCertifications.localKeypair
, GlobalConfigurations.User_Handle
, GlobalConfigurations.LHS_Address);
GlobalIrpClient.useInternalIrpClient(GlobalCertifications.localKeypair,
GlobalConfigurations.User_Handle,
GlobalConfigurations.LHS_Address);
if (doipServiceInfo.id.equals("")) {
try {
doipServiceInfo.id = GlobalIrpClient.getGlobalClient().register(doipServiceInfo.toServiceHandleRecord());

View File

@ -187,7 +187,7 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor {
block.requests.length,
block.hash));
// TODO create check point
this.b = new Block(block.hash);
this.b = new Block(block.hash, this.b.height + 1);
executedBlocks.add(block.hash);
}
@ -228,6 +228,7 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor {
static class Block extends SM2Verifiable {
String prevHash = "0";
String hash;
int height;
String checkPoint;
String body;
String nodePubKey;
@ -235,10 +236,12 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor {
long timestamp;
public Block() {
this.height = 0;
}
public Block(String prev) {
public Block(String prev, int height) {
this.prevHash = prev;
this.height = height;
}
public void fillBlock(ContractRequest[] requests) {
@ -255,6 +258,7 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor {
private String computeHash() {
return HashUtil.sha3(
String.valueOf(this.height),
this.prevHash,
this.checkPoint,
this.body);