1
0
forked from circlecloud/tera

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

@@ -19,35 +19,11 @@ import '../system/smart'
global.DATA_PATH = global.GetNormalPathString(global.DATA_PATH);
global.CODE_PATH = global.GetNormalPathString(global.CODE_PATH);
import "../core/library"
import "./child-process"
global.READ_ONLY_DB = 1;
var LastAlive = Date.now();
setTimeout(function() {
setInterval(CheckAlive, 1000);
}, 20000);
setInterval(function() {
process.send({ cmd: "Alive" });
}, 1000);
process.send({ cmd: "online", message: "OK" });
process.on('message', function(msg) {
LastAlive = Date.now();
switch (msg.cmd) {
case "ALive":
break;
case "Exit":
process.exit(0);
break;
case "call":
var Err = 0;
var Ret;
try {
Ret = global[msg.Name](msg.Params);
} catch (e) {
Err = 1;
Ret = "" + e;
}
if (msg.id)
process.send({ cmd: "retcall", id: msg.id, Err: Err, Params: Ret });
break;
case "GETBLOCKHEADER":
GETBLOCKHEADER(msg);
break;
@@ -69,27 +45,6 @@ process.on('message', function(msg) {
}
});
function CheckAlive() {
if (global.NOALIVE)
return;
var Delta = Date.now() - LastAlive;
if (Delta > global.CHECK_STOP_CHILD_PROCESS) {
global.ToLog("STATIC-DB: ALIVE TIMEOUT Stop and exit: " + Delta + "/" + global.CHECK_STOP_CHILD_PROCESS);
process.exit(0);
return;
}
};
process.on('uncaughtException', function(err) {
global.ToError(err.stack);
global.ToLog(err.stack);
global.TO_ERROR_LOG("STATIC-DB", 777, err);
global.ToLog("-----------------STATIC-DB EXIT------------------");
process.exit();
});
process.on('error' as any, function(err: TeraError) {
global.ToError("STATIC-DB:\n" + err.stack);
global.ToLog(err.stack);
});
import CServerDB from '../core/db/block-db'
import { DB_FORMAT } from '../constant/db-format';
var KeyPair = crypto.createECDH('secp256k1');