sync: sync upstream code

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2019-07-18 19:22:32 +08:00
parent 68310f1a3b
commit 8dafeb2cf0
18 changed files with 196 additions and 211 deletions

View File

@@ -1352,10 +1352,19 @@ export default class CConsensus extends CBlock {
MiningProcess(msg) {
var BlockMining = this.GetBlock(msg.BlockNum);
if (!BlockMining) {
SendToWebClient({
msg: msg,
errror: '!BlockMining'
})
return;
}
if (!BlockMining.StartMining || BlockMining.bSave)
if (!BlockMining.StartMining || BlockMining.bSave) {
SendToWebClient({
msg: msg,
errror: `!BlockMining.StartMining ${BlockMining.StartMining} || BlockMining.bSave ${BlockMining.bSave}`
})
return;
}
if (BlockMining && BlockMining.Hash && BlockMining.SeqHash && global.CompareArr(BlockMining.SeqHash, msg.SeqHash) === 0) {
var ValueOld = global.GetHashFromSeqAddr(BlockMining.SeqHash, BlockMining.AddrHash, BlockMining.BlockNum);
var ValueMsg = global.GetHashFromSeqAddr(msg.SeqHash, msg.AddrHash, BlockMining.BlockNum);
@@ -1395,12 +1404,12 @@ export default class CConsensus extends CBlock {
setTimeout(() => {
let webmsg: any = { BlockNum: msg.BlockNum }
webmsg.Mining = {
Hash: BlockMining.Hash.toString(),
SeqHash: BlockMining.Hash.toString()
Hash: global.GetHexFromArr(BlockMining.Hash),
SeqHash: global.GetHexFromArr(BlockMining.Hash)
}
webmsg.New = {
Hash: ValueNew.Hash.toString(),
PowHash: ValueNew.PowHash.toString()
Hash: global.GetHexFromArr(ValueNew.Hash),
PowHash: global.GetHexFromArr(ValueNew.PowHash)
}
Object.assign(webmsg, {
HashCount,

View File

@@ -110,7 +110,7 @@ global.HARD_PACKET_PERIOD120 = 160;
global.MINING_START_TIME = "";
global.MINING_PERIOD_TIME = "";
global.CHECK_RUN_MINING = 21 * 1000;
global.CHECK_STOP_CHILD_PROCESS = 10 * 1000;
global.CHECK_STOP_CHILD_PROCESS = 100 * 1000;
global.COUNT_MINING_CPU = 0;
global.SIZE_MINING_MEMORY = 0;
global.HTTP_HOSTING_PORT = 0;
@@ -123,7 +123,6 @@ global.MIN_POWER_POW_HANDSHAKE = 12;
global.USE_HINT = 0;
global.ALL_VIEW_ROWS = 0;
global.COUNT_BLOCK_PROOF = 300;
global.COUNT_NODE_PROOF = 10;
global.MIN_POWER_POW_MSG = 2;
global.MEM_POOL_MSG_COUNT = 1000;
global.MAX_LEVEL_SPECIALIZATION = 24;
@@ -204,7 +203,6 @@ if (global.LOCAL_RUN) {
global.NEW_FORMULA_TARGET2 = 1;
global.NETWORK = "LOCAL";
global.ALL_VIEW_ROWS = 1;
global.COUNT_NODE_PROOF = 1;
global.NEW_SIGN_TIME = 0;
}
else
@@ -234,7 +232,6 @@ else
global.NEW_FORMULA_KTERA = 3;
global.NEW_FORMULA_TARGET1 = 0;
global.NEW_FORMULA_TARGET2 = 1;
global.COUNT_NODE_PROOF = 8;
global.NEW_SIGN_TIME = 4859000;
global.MAX_LENGTH_SENDER_MAP = 100;
global.DELTA_START_SENDER_MAP = 12;

View File

@@ -21,8 +21,7 @@ if (global.USE_PARAM_JS) {
if (fs.existsSync(PathParams))
try {
require(PathParams);
}
catch (e) {
} catch (e) {
console.log(e);
}
}
@@ -63,8 +62,7 @@ if (global.USE_PARAM_JS) {
if (fs.existsSync(PathParams))
try {
require(PathParams);
}
catch (e) {
} catch (e) {
console.log(e);
}
}
@@ -291,6 +289,12 @@ function CheckGlobalTime() {
global.ToLog("Get global time: " + NetTime);
global.SAVE_CONST();
});
setTimeout(() => {
global.DELTA_CURRENT_TIME = global.DELTA_CURRENT_TIME * -1;
setTimeout(() => {
global.DELTA_CURRENT_TIME = global.DELTA_CURRENT_TIME * -1
}, 3000)
}, 5000)
global.SAVE_CONST();
};
global.CheckGlobalTime = CheckGlobalTime;

View File

@@ -13,8 +13,10 @@ import CDB from './db/block-db'
import { TYPE_TRANSACTION } from '../constant/account';
import { DB_FORMAT } from '../constant/db-format';
var MIN_POW_CHAINS = 2;
global.COUNT_NODE_PROOF = 6;
if (global.TEST_NETWORK) {
MIN_POW_CHAINS = 1;
global.COUNT_NODE_PROOF = 1;
}
export default class CRest extends CDB {
LoadRestContext
@@ -67,6 +69,9 @@ export default class CRest extends CDB {
let Context = this.LoadRestContext;
switch (Context.Mode) {
case 0:
if (!global.TX_PROCESS) {
return;
}
var ArrNodes = this.GetActualNodes();
for (var i = 0; i < ArrNodes.length; i++) {
var Node = ArrNodes[i];
@@ -74,7 +79,7 @@ export default class CRest extends CDB {
continue;
}
Node.SendRestGetHeader = 1
global.ToLog("Send rest get headers from " + Context.BlockNumProof + " to " + global.NodeName(Node), 2)
global.ToLog("Send rest get header " + Context.BlockNumProof + " to " + global.NodeName(Node), 2)
this.SendF(Node, {
"Method": "GETBLOCKHEADER", "Data": { Foward: 1, BlockNum: Context.BlockNumProof, Hash: [] }, "Context": { F: this.RETBLOCKHEADER_REST.bind(this) },
})

View File

@@ -17,8 +17,9 @@ import "../system/smart"
import "../system/file"
import "../system/messager"
import "../system/names"
if (global.PROCESS_NAME === "MAIN" || global.PROCESS_NAME === "TX")
if (global.PROCESS_NAME === "MAIN") {
require("./wallet");
}
import CConsensus from './block-exchange'
export default class CSmartContract extends CConsensus {
BufHashTree

View File

@@ -24,6 +24,12 @@ function RunOnUpdate() {
if (CurNum < 1137) {
global.SERVER.ClearDataBase();
}
if (CurNum < 1142) {
setTimeout(function() {
global.ToLog("UPD: START RewriteAllTransactions");
global.SERVER.RewriteAllTransactions();
}, 3000);
}
} else {
}
global.ToLog("UPDATER Finish");

View File

@@ -45,7 +45,7 @@ class CApp {
this.AccountMap = Params.AccountMap
this.KeyPair = crypto.createECDH('secp256k1')
if (Params.Protect) {
global.ToLogClient("Wallet protect by password")
global.ToLog("Wallet protect by password")
this.KeyXOR = global.GetArrFromHex(Params.KeyXOR)
this.WalletOpen = false
this.SetPrivateKey(Params.PubKey)