refactor: sync code

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2019-07-13 15:37:38 +08:00
parent 8576359edc
commit 12e835d5f5
18 changed files with 485 additions and 288 deletions

View File

@@ -16,6 +16,16 @@ import * as stun from 'stun'
import * as zip from 'zip'
import './constant'
if (global.USE_PARAM_JS) {
var PathParams = global.GetCodePath("../extern-run.js");
if (fs.existsSync(PathParams))
try {
require(PathParams);
}
catch (e) {
console.log(e);
}
}
import './log'
Number.prototype.toStringZ = function(count) {
@@ -58,6 +68,8 @@ if (global.USE_PARAM_JS) {
console.log(e);
}
}
require('../HTML/JS/terahashlib.js');
require("./crypto-library");
global.BufLib = require("../core/buffer");
require('../HTML/JS/sha3.js');
require('../HTML/JS/coinlib.js');
@@ -93,7 +105,7 @@ global.SliceArr = function(arr, start, end) {
}
return ret;
};
// var nRand = Math.floor(123 + Math.random() * 1000);
var nRand = Math.floor(123 + Math.random() * 1000);
function random(max) {
return Math.floor(Math.random() * max);
@@ -142,8 +154,7 @@ global.LoadParams = function(filename, DefaultValue) {
if (Str.length > 0)
return JSON.parse(Str as any);
}
}
catch (err) {
} catch (err) {
global.TO_ERROR_LOG("MAINLIB", 100, "Error in file:" + filename + "\n" + err);
}
return DefaultValue;
@@ -265,7 +276,7 @@ global.SAVE_CONST = function(bForce) {
};
function CheckGlobalTime() {
global.ntpClient.getNetworkTime("pool.ntp.org", 123, function(err, NetTime) {
global.ntpClient.getNetworkTime("ntp1.aliyun.com", 123, function(err, NetTime) {
if (err) {
global.TO_ERROR_LOG("MAINLIB", 110, err);
return;
@@ -372,7 +383,7 @@ function GetCountMiningCPU() {
}
};
global.GetCountMiningCPU = GetCountMiningCPU;
var AddTrMap = [];
var AddTrMap: any = {};
AddTrMap[- 6] = "Inner node error";
AddTrMap[- 5] = "Bad block num";
AddTrMap[- 4] = "Bad type transaction";