@@ -44,7 +44,7 @@ ContenTypeMap[".js"] = "application/javascript";
|
||||
ContenTypeMap["html"] = "text/html";
|
||||
ContenTypeMap["psd"] = "application/octet-stream";
|
||||
global.HTTPCaller = {};
|
||||
let HTTPCaller = global.HTTPCaller
|
||||
|
||||
function DoCommand(response, Type, Path, params, remoteAddress) {
|
||||
var F = global.HTTPCaller[params[0]];
|
||||
if (F) {
|
||||
@@ -238,7 +238,7 @@ function SendToResponce404(response) {
|
||||
response.writeHead(404, { 'Content-Type': 'text/html' });
|
||||
response.end();
|
||||
};
|
||||
HTTPCaller.DappBlockFile = function(Params, response) {
|
||||
global.HTTPCaller.DappBlockFile = function(Params, response) {
|
||||
Params.BlockNum = global.ParseNum(Params.BlockNum);
|
||||
Params.TrNum = global.ParseNum(Params.TrNum);
|
||||
if (!Params.TrNum)
|
||||
@@ -289,7 +289,7 @@ function SendToResponceResult0(response) {
|
||||
response.end("{\"result\":0}");
|
||||
};
|
||||
var glBlock0;
|
||||
HTTPCaller.DappStaticCall = function(Params, response) {
|
||||
global.HTTPCaller.DappStaticCall = function(Params, response) {
|
||||
global.DApps.Accounts.BeginBlock();
|
||||
global.DApps.Accounts.BeginTransaction();
|
||||
global.TickCounter = 100000;
|
||||
@@ -312,7 +312,7 @@ HTTPCaller.DappStaticCall = function(Params, response) {
|
||||
response.end(Str);
|
||||
return null;
|
||||
};
|
||||
HTTPCaller.DappInfo = function(Params, responce, ObjectOnly) {
|
||||
global.HTTPCaller.DappInfo = function(Params, responce, ObjectOnly) {
|
||||
var SmartNum = global.ParseNum(Params.Smart);
|
||||
if (global.TX_PROCESS && global.TX_PROCESS.Worker)
|
||||
global.TX_PROCESS.Worker.send({ cmd: "SetSmartEvent", Smart: SmartNum });
|
||||
@@ -336,7 +336,7 @@ HTTPCaller.DappInfo = function(Params, responce, ObjectOnly) {
|
||||
DeleteOldEvents(SmartNum);
|
||||
var Context = GetUserContext(Params);
|
||||
var EArr = GetEventArray(SmartNum, Context);
|
||||
var WLData = HTTPCaller.DappWalletList(Params);
|
||||
var WLData = global.HTTPCaller.DappWalletList(Params);
|
||||
var ArrLog = [];
|
||||
for (var i = 0; i < global.ArrLogClient.length; i++) {
|
||||
var Item = global.ArrLogClient[i];
|
||||
@@ -363,7 +363,7 @@ HTTPCaller.DappInfo = function(Params, responce, ObjectOnly) {
|
||||
}
|
||||
return Ret;
|
||||
};
|
||||
HTTPCaller.DappWalletList = function(Params) {
|
||||
global.HTTPCaller.DappWalletList = function(Params) {
|
||||
var arr0 = global.DApps.Accounts.GetWalletAccountsByMap(global.WALLET.AccountMap);
|
||||
var arr = [];
|
||||
for (var i = 0; i < arr0.length; i++) {
|
||||
@@ -374,54 +374,54 @@ HTTPCaller.DappWalletList = function(Params) {
|
||||
var Ret: any = { result: 1, arr: arr, };
|
||||
return Ret;
|
||||
};
|
||||
HTTPCaller.DappAccountList = function(Params) {
|
||||
global.HTTPCaller.DappAccountList = function(Params) {
|
||||
var arr = global.DApps.Accounts.GetRowsAccounts(Params.StartNum, Params.CountNum, undefined, 1);
|
||||
return { arr: arr, result: 1 };
|
||||
};
|
||||
HTTPCaller.DappSmartList = function(Params) {
|
||||
global.HTTPCaller.DappSmartList = function(Params) {
|
||||
var arr = global.DApps.Smart.GetRows(Params.StartNum, Params.CountNum, undefined, undefined, Params.GetAllData, Params.TokenGenerate);
|
||||
return { arr: arr, result: 1 };
|
||||
};
|
||||
HTTPCaller.DappBlockList = function(Params, response) {
|
||||
global.HTTPCaller.DappBlockList = function(Params, response) {
|
||||
Params.Filter = undefined;
|
||||
return HTTPCaller.GetBlockList(Params, response, 1);
|
||||
return global.HTTPCaller.GetBlockList(Params, response, 1);
|
||||
};
|
||||
HTTPCaller.DappTransactionList = function(Params, response) {
|
||||
global.HTTPCaller.DappTransactionList = function(Params, response) {
|
||||
Params.Filter = undefined;
|
||||
Params.Param3 = Params.BlockNum;
|
||||
return HTTPCaller.GetTransactionAll(Params, response);
|
||||
return global.HTTPCaller.GetTransactionAll(Params, response);
|
||||
};
|
||||
var sessionid = global.GetHexFromAddres(crypto.randomBytes(20));
|
||||
HTTPCaller.RestartNode = function(Params) {
|
||||
global.HTTPCaller.RestartNode = function(Params) {
|
||||
global.RestartNode();
|
||||
return { result: 1 };
|
||||
};
|
||||
HTTPCaller.ToLogServer = function(Str) {
|
||||
global.HTTPCaller.ToLogServer = function(Str) {
|
||||
global.ToLogClient(Str);
|
||||
return { result: 1 };
|
||||
};
|
||||
HTTPCaller.FindMyAccounts = function(Params) {
|
||||
global.HTTPCaller.FindMyAccounts = function(Params) {
|
||||
global.WALLET.FindMyAccounts(1);
|
||||
return { result: 1 };
|
||||
};
|
||||
HTTPCaller.GetAccount = function(id) {
|
||||
global.HTTPCaller.GetAccount = function(id) {
|
||||
id = parseInt(id);
|
||||
var arr = global.DApps.Accounts.GetRowsAccounts(id, 1);
|
||||
return { Item: arr[0], result: 1 };
|
||||
};
|
||||
HTTPCaller.GetAccountList = function(Params) {
|
||||
global.HTTPCaller.GetAccountList = function(Params) {
|
||||
if (!Params.CountNum)
|
||||
Params.CountNum = 1;
|
||||
var arr = global.DApps.Accounts.GetRowsAccounts(Params.StartNum, Params.CountNum, Params.Filter);
|
||||
return { arr: arr, result: 1 };
|
||||
};
|
||||
HTTPCaller.GetDappList = function(Params) {
|
||||
global.HTTPCaller.GetDappList = function(Params) {
|
||||
if (!Params.CountNum)
|
||||
Params.CountNum = 1;
|
||||
var arr = global.DApps.Smart.GetRows(Params.StartNum, Params.CountNum, Params.Filter, Params.Filter2, 1);
|
||||
return { arr: arr, result: 1 };
|
||||
};
|
||||
HTTPCaller.GetBlockList = function(Params, response, bOnlyNum) {
|
||||
global.HTTPCaller.GetBlockList = function(Params, response, bOnlyNum) {
|
||||
if (!Params.CountNum)
|
||||
Params.CountNum = 1;
|
||||
if (Params.StartNum < global.SERVER.BlockNumDBMin) {
|
||||
@@ -448,7 +448,7 @@ HTTPCaller.GetBlockList = function(Params, response, bOnlyNum) {
|
||||
var arr = global.SERVER.GetRows(Params.StartNum, Params.CountNum, Params.Filter, !bOnlyNum);
|
||||
return { arr: arr, result: 1 };
|
||||
};
|
||||
HTTPCaller.GetTransactionAll = function(Params, response) {
|
||||
global.HTTPCaller.GetTransactionAll = function(Params, response) {
|
||||
if (!Params.CountNum)
|
||||
Params.CountNum = 1;
|
||||
var BlockNum = Params.Param3;
|
||||
@@ -473,11 +473,11 @@ HTTPCaller.GetTransactionAll = function(Params, response) {
|
||||
var arr = global.SERVER.GetTrRows(BlockNum, Params.StartNum, Params.CountNum, Params.Filter);
|
||||
return { arr: arr, result: 1 };
|
||||
};
|
||||
HTTPCaller.GetActList = function(Params) {
|
||||
global.HTTPCaller.GetActList = function(Params) {
|
||||
var arr = global.DApps.Accounts.GetActList(Params.StartNum, Params.CountNum, Params.Filter);
|
||||
return { arr: arr, result: 1 };
|
||||
};
|
||||
HTTPCaller.GetHashList = function(Params) {
|
||||
global.HTTPCaller.GetHashList = function(Params) {
|
||||
var arr = global.DApps.Accounts.DBAccountsHash.GetRows(Params.StartNum, Params.CountNum, Params.Filter);
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
var item = arr[i];
|
||||
@@ -491,14 +491,14 @@ HTTPCaller.GetHashList = function(Params) {
|
||||
}
|
||||
return { arr: arr, result: 1 };
|
||||
};
|
||||
HTTPCaller.GetHistoryAct = function(Params) {
|
||||
global.HTTPCaller.GetHistoryAct = function(Params) {
|
||||
var arr = global.WALLET.GetHistory(Params.StartNum, Params.CountNum, Params.Filter);
|
||||
return { arr: arr, result: 1 };
|
||||
};
|
||||
var LastTimeGetHashRate = 0;
|
||||
var LastHashRate = 0;
|
||||
var HashRateOneSec = 0;
|
||||
HTTPCaller.GetWalletInfo = function(Params) {
|
||||
global.HTTPCaller.GetWalletInfo = function(Params) {
|
||||
var Constants = {};
|
||||
for (var i = 0; i < global.CONST_NAME_ARR.length; i++) {
|
||||
var key = global.CONST_NAME_ARR[i];
|
||||
@@ -571,37 +571,37 @@ HTTPCaller.GetWalletInfo = function(Params) {
|
||||
Ret.PublicKey = global.WALLET.KeyPair.PubKeyStr;
|
||||
return Ret;
|
||||
};
|
||||
HTTPCaller.GetCurrentInfo = HTTPCaller.GetWalletInfo;
|
||||
HTTPCaller.TestSignLib = function() {
|
||||
global.HTTPCaller.GetCurrentInfo = global.HTTPCaller.GetWalletInfo;
|
||||
global.HTTPCaller.TestSignLib = function() {
|
||||
global.TestSignLib();
|
||||
};
|
||||
HTTPCaller.GetWalletAccounts = function() {
|
||||
global.HTTPCaller.GetWalletAccounts = function() {
|
||||
var Ret: any = { result: 1, arr: global.DApps.Accounts.GetWalletAccountsByMap(global.WALLET.AccountMap), };
|
||||
Ret.PrivateKey = global.WALLET.KeyPair.PrivKeyStr;
|
||||
Ret.PublicKey = global.WALLET.KeyPair.PubKeyStr;
|
||||
return Ret;
|
||||
};
|
||||
HTTPCaller.SetWalletKey = function(PrivateKeyStr) {
|
||||
global.HTTPCaller.SetWalletKey = function(PrivateKeyStr) {
|
||||
global.WALLET.SetPrivateKey(PrivateKeyStr, true);
|
||||
return { result: 1 };
|
||||
};
|
||||
HTTPCaller.SetWalletPasswordNew = function(Password) {
|
||||
global.HTTPCaller.SetWalletPasswordNew = function(Password) {
|
||||
global.WALLET.SetPasswordNew(Password);
|
||||
return { result: 1 };
|
||||
};
|
||||
HTTPCaller.OpenWallet = function(Password) {
|
||||
global.HTTPCaller.OpenWallet = function(Password) {
|
||||
var res = global.WALLET.OpenWallet(Password);
|
||||
return { result: res };
|
||||
};
|
||||
HTTPCaller.CloseWallet = function() {
|
||||
global.HTTPCaller.CloseWallet = function() {
|
||||
var res = global.WALLET.CloseWallet();
|
||||
return { result: res };
|
||||
};
|
||||
HTTPCaller.GetSignTransaction = function(TR) {
|
||||
global.HTTPCaller.GetSignTransaction = function(TR) {
|
||||
var Sign = global.WALLET.GetSignTransaction(TR);
|
||||
return { Sign: Sign, result: 1 };
|
||||
};
|
||||
HTTPCaller.GetSignFromHEX = function(Params) {
|
||||
global.HTTPCaller.GetSignFromHEX = function(Params) {
|
||||
var Arr = global.GetArrFromHex(Params.Hex);
|
||||
var Sign;
|
||||
if (Params.Account)
|
||||
@@ -610,7 +610,7 @@ HTTPCaller.GetSignFromHEX = function(Params) {
|
||||
Sign = global.WALLET.GetSignFromArr(Arr);
|
||||
return { Sign: Sign, result: 1 };
|
||||
};
|
||||
HTTPCaller.SendTransactionHex = function(Params) {
|
||||
global.HTTPCaller.SendTransactionHex = function(Params) {
|
||||
var body = global.GetArrFromHex(Params.Hex);
|
||||
var Result: any = { result: 1 };
|
||||
var Res = global.SERVER.AddTransactionOwn({ body: body, ToAll: 1 });
|
||||
@@ -622,11 +622,16 @@ HTTPCaller.SendTransactionHex = function(Params) {
|
||||
global.ToLogClient("Send: " + Result.text, global.GetHexFromArr(global.sha3(body)), final);
|
||||
return Result;
|
||||
};
|
||||
HTTPCaller.SendDirectCode = function(Params, response) {
|
||||
global.HTTPCaller.SendDirectCode = function(Params, response) {
|
||||
var Result;
|
||||
if (Params.TX) {
|
||||
if (global.TX_PROCESS && global.TX_PROCESS.RunRPC) {
|
||||
global.TX_PROCESS.RunRPC("EvalCode", Params.Code, function(Err, Ret) {
|
||||
if (Params.TX || Params.WEB) {
|
||||
var RunProcess;
|
||||
if (Params.TX)
|
||||
RunProcess = global.TX_PROCESS;
|
||||
if (Params.WEB)
|
||||
RunProcess = global.WEB_PROCESS;
|
||||
if (RunProcess && RunProcess.RunRPC) {
|
||||
RunProcess.RunRPC("EvalCode", Params.Code, function(Err, Ret) {
|
||||
Result = { result: !Err, sessionid: sessionid, text: Ret, };
|
||||
var Str = JSON.stringify(Result);
|
||||
response.end(Str);
|
||||
@@ -634,7 +639,7 @@ HTTPCaller.SendDirectCode = function(Params, response) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
Result = "No send to TX";
|
||||
Result = "No process for send call";
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -649,7 +654,7 @@ HTTPCaller.SendDirectCode = function(Params, response) {
|
||||
var Struct = { result: 1, sessionid: sessionid, text: Result };
|
||||
return Struct;
|
||||
};
|
||||
HTTPCaller.SetMining = function(MiningAccount) {
|
||||
global.HTTPCaller.SetMining = function(MiningAccount) {
|
||||
global.WALLET.SetMiningAccount(parseInt(MiningAccount));
|
||||
return { result: 1 };
|
||||
};
|
||||
@@ -667,7 +672,7 @@ function CheckCorrectDevKey() {
|
||||
}
|
||||
return true;
|
||||
};
|
||||
HTTPCaller.SendECode = function(Param) {
|
||||
global.HTTPCaller.SendECode = function(Param) {
|
||||
var Ret = CheckCorrectDevKey();
|
||||
if (Ret !== true)
|
||||
return Ret;
|
||||
@@ -688,7 +693,7 @@ HTTPCaller.SendECode = function(Param) {
|
||||
global.SERVER.SendECode(Param, Node);
|
||||
return { result: 1, text: "Send" };
|
||||
};
|
||||
HTTPCaller.SetCheckPoint = function(BlockNum) {
|
||||
global.HTTPCaller.SetCheckPoint = function(BlockNum) {
|
||||
var Ret = CheckCorrectDevKey();
|
||||
if (Ret !== true)
|
||||
return Ret;
|
||||
@@ -716,7 +721,7 @@ function SetCheckPointOnBlock(BlockNum) {
|
||||
};
|
||||
global.SetCheckPointOnBlock = SetCheckPointOnBlock;
|
||||
var idSetTimeSetCheckPoint;
|
||||
HTTPCaller.SetAutoCheckPoint = function(Param) {
|
||||
global.HTTPCaller.SetAutoCheckPoint = function(Param) {
|
||||
var Ret = CheckCorrectDevKey();
|
||||
if (Ret !== true)
|
||||
return Ret;
|
||||
@@ -759,7 +764,7 @@ function RunSetCheckPoint() {
|
||||
global.ToLog("SET CHECK POINT Power=" + Power + "/" + AvgPow + " BlockNum=" + BlockNum);
|
||||
}
|
||||
};
|
||||
HTTPCaller.SetNewCodeVersion = function(Data) {
|
||||
global.HTTPCaller.SetNewCodeVersion = function(Data) {
|
||||
var Ret: any = CheckCorrectDevKey();
|
||||
if (Ret !== true)
|
||||
return Ret;
|
||||
@@ -767,7 +772,7 @@ HTTPCaller.SetNewCodeVersion = function(Data) {
|
||||
global.SERVER.ResetNextPingAllNode();
|
||||
return { result: 1, text: Ret };
|
||||
};
|
||||
HTTPCaller.SetCheckNetConstant = function(Data) {
|
||||
global.HTTPCaller.SetCheckNetConstant = function(Data) {
|
||||
var Ret: any = CheckCorrectDevKey();
|
||||
if (Ret !== true)
|
||||
return Ret;
|
||||
@@ -783,7 +788,7 @@ HTTPCaller.SetCheckNetConstant = function(Data) {
|
||||
global.SERVER.ResetNextPingAllNode();
|
||||
return { result: 1, text: "Set NET_CONSTANT BlockNum=" + Data.BlockNum };
|
||||
};
|
||||
HTTPCaller.SetCheckDeltaTime = function(Data) {
|
||||
global.HTTPCaller.SetCheckDeltaTime = function(Data) {
|
||||
var Ret = CheckCorrectDevKey();
|
||||
if (Ret !== true)
|
||||
return Ret;
|
||||
@@ -798,7 +803,7 @@ HTTPCaller.SetCheckDeltaTime = function(Data) {
|
||||
return { result: 1, text: "Set check time Num=" + Data.Num };
|
||||
};
|
||||
var idAutoCorrTime;
|
||||
HTTPCaller.SetAutoCorrTime = function(bSet) {
|
||||
global.HTTPCaller.SetAutoCorrTime = function(bSet) {
|
||||
var Ret = CheckCorrectDevKey();
|
||||
if (Ret !== true)
|
||||
return Ret;
|
||||
@@ -832,7 +837,7 @@ function RunAutoCorrTime() {
|
||||
global.ToLog("Auto corr time Num:" + Data.Num + " AutoDelta=" + AutoDelta);
|
||||
}
|
||||
};
|
||||
HTTPCaller.SaveConstant = function(SetObj) {
|
||||
global.HTTPCaller.SaveConstant = function(SetObj) {
|
||||
var WasUpdate = global.USE_AUTO_UPDATE;
|
||||
for (var key in SetObj) {
|
||||
global[key] = SetObj[key];
|
||||
@@ -850,7 +855,7 @@ HTTPCaller.SaveConstant = function(SetObj) {
|
||||
}
|
||||
return { result: 1 };
|
||||
};
|
||||
HTTPCaller.SetHTTPParams = function(SetObj) {
|
||||
global.HTTPCaller.SetHTTPParams = function(SetObj) {
|
||||
global.HTTP_PORT_NUMBER = SetObj.HTTPPort;
|
||||
global.HTTP_PORT_PASSWORD = SetObj.HTTPPassword;
|
||||
global.SAVE_CONST(true);
|
||||
@@ -858,7 +863,7 @@ HTTPCaller.SetHTTPParams = function(SetObj) {
|
||||
global.RestartNode();
|
||||
return { result: 1 };
|
||||
};
|
||||
HTTPCaller.SetNetMode = function(SetObj) {
|
||||
global.HTTPCaller.SetNetMode = function(SetObj) {
|
||||
if (!global.NET_WORK_MODE)
|
||||
global.NET_WORK_MODE = {};
|
||||
for (var key in SetObj) {
|
||||
@@ -873,7 +878,7 @@ HTTPCaller.SetNetMode = function(SetObj) {
|
||||
global.RestartNode();
|
||||
return { result: 1 };
|
||||
};
|
||||
HTTPCaller.GetAccountKey = function(Num) {
|
||||
global.HTTPCaller.GetAccountKey = function(Num) {
|
||||
var Result: any = {};
|
||||
Result.result = 0;
|
||||
var KeyPair = global.WALLET.GetAccountKey(Num);
|
||||
@@ -883,7 +888,7 @@ HTTPCaller.GetAccountKey = function(Num) {
|
||||
}
|
||||
return Result;
|
||||
};
|
||||
HTTPCaller.GetHotArray = function(Param) {
|
||||
global.HTTPCaller.GetHotArray = function(Param) {
|
||||
var ArrTree = global.SERVER.GetTransferTree();
|
||||
if (!ArrTree)
|
||||
return { result: 0 };
|
||||
@@ -945,23 +950,50 @@ function GetCopyNode(Node, BlockCounts) {
|
||||
if (BlockCounts !== 0)
|
||||
GetTiming = Math.trunc(Node.GetTiming / BlockCounts) / 1000;
|
||||
var Item = {
|
||||
VersionNum: Node.VersionNum, NoSendTx: Node.NoSendTx, GetNoSendTx: Node.GetNoSendTx, DirectMAccount: Node.DirectMAccount,
|
||||
id: Node.id, ip: Node.ip, portweb: Node.portweb, port: Node.port, TransferCount: Node.TransferCount, GetTiming: GetTiming, ErrCountAll: Node.ErrCountAll,
|
||||
LevelCount: Node.LevelCount, LevelEnum: Node.LevelEnum, TimeTransfer: global.GetStrOnlyTimeUTC(new Date(Node.LastTimeTransfer)), BlockProcessCount: Node.BlockProcessCount,
|
||||
DeltaTime: Node.DeltaTime, DeltaTimeM: Node.DeltaTimeM, DeltaGlobTime: Node.DeltaGlobTime, PingNumber: Node.PingNumber, NextConnectDelta: Node.NextConnectDelta,
|
||||
NextGetNodesDelta: Node.NextGetNodesDelta, NextHotDelta: Node.NextHotDelta, Name: Node.Name, addrStr: Node.addrStr, CanHot: Node.CanHot,
|
||||
Active: Node.Active, Hot: Node.Hot, Info: Node.PrevInfo + Node.Info, InConnectArr: Node.WasAddToConnect, Level: Node.Level, TransferBlockNum: Node.TransferBlockNum,
|
||||
TransferSize: Node.TransferSize, TransferBlockNumFix: Node.TransferBlockNumFix, CurBlockNum: Node.CurBlockNum,
|
||||
VersionNum: Node.VersionNum,
|
||||
NoSendTx: Node.NoSendTx,
|
||||
GetNoSendTx: Node.GetNoSendTx,
|
||||
DirectMAccount: Node.DirectMAccount,
|
||||
id: Node.id,
|
||||
ip: Node.ip,
|
||||
portweb: Node.portweb,
|
||||
port: Node.port,
|
||||
TransferCount: Node.TransferCount,
|
||||
GetTiming: GetTiming,
|
||||
ErrCountAll: Node.ErrCountAll,
|
||||
LevelCount: Node.LevelCount,
|
||||
LevelEnum: Node.LevelEnum,
|
||||
TimeTransfer: global.GetStrOnlyTimeUTC(new Date(Node.LastTimeTransfer)),
|
||||
BlockProcessCount: Node.BlockProcessCount,
|
||||
DeltaTime: Node.DeltaTime,
|
||||
DeltaTimeM: Node.DeltaTimeM,
|
||||
DeltaGlobTime: Node.DeltaGlobTime,
|
||||
PingNumber: Node.PingNumber,
|
||||
NextConnectDelta: Node.NextConnectDelta,
|
||||
NextGetNodesDelta: Node.NextGetNodesDelta,
|
||||
NextHotDelta: Node.NextHotDelta,
|
||||
Name: Node.Name,
|
||||
addrStr: Node.addrStr,
|
||||
CanHot: Node.CanHot,
|
||||
Active: Node.Active,
|
||||
Hot: Node.Hot,
|
||||
Info: Node.PrevInfo + Node.Info,
|
||||
InConnectArr: Node.WasAddToConnect,
|
||||
Level: Node.Level,
|
||||
TransferBlockNum: Node.TransferBlockNum,
|
||||
TransferSize: Node.TransferSize,
|
||||
TransferBlockNumFix: Node.TransferBlockNumFix,
|
||||
CurBlockNum: Node.CurBlockNum,
|
||||
};
|
||||
return Item;
|
||||
};
|
||||
HTTPCaller.GetBlockchainStat = function(Param) {
|
||||
global.HTTPCaller.GetBlockchainStat = function(Param) {
|
||||
var Result = global.SERVER.GetStatBlockchainPeriod(Param);
|
||||
Result.result = 1;
|
||||
Result.sessionid = sessionid;
|
||||
return Result;
|
||||
};
|
||||
HTTPCaller.GetAllCounters = function(Params, response) {
|
||||
global.HTTPCaller.GetAllCounters = function(Params, response) {
|
||||
let Result = global.GET_STATS();
|
||||
Result.result = 1;
|
||||
Result.sessionid = sessionid;
|
||||
@@ -997,7 +1029,7 @@ function AddStatData(Params, Result, Prefix) {
|
||||
}
|
||||
}
|
||||
};
|
||||
HTTPCaller.SetStatMode = function(flag) {
|
||||
global.HTTPCaller.SetStatMode = function(flag) {
|
||||
if (flag)
|
||||
global.StartCommonStat();
|
||||
global.STAT_MODE = flag;
|
||||
@@ -1005,7 +1037,7 @@ HTTPCaller.SetStatMode = function(flag) {
|
||||
global.TX_PROCESS.RunRPC("LOAD_CONST");
|
||||
return { result: 1, sessionid: sessionid, STAT_MODE: global.STAT_MODE };
|
||||
};
|
||||
HTTPCaller.ClearStat = function() {
|
||||
global.HTTPCaller.ClearStat = function() {
|
||||
global.ClearCommonStat();
|
||||
if (global.TX_PROCESS && global.TX_PROCESS.RunRPC) {
|
||||
global.TX_PROCESS.RunRPC("ClearCommonStat", "", function(Err, Params) {
|
||||
@@ -1017,15 +1049,15 @@ HTTPCaller.ClearStat = function() {
|
||||
}
|
||||
return { result: 1, sessionid: sessionid, STAT_MODE: global.STAT_MODE };
|
||||
};
|
||||
HTTPCaller.RewriteAllTransactions = function(Param) {
|
||||
global.HTTPCaller.RewriteAllTransactions = function(Param) {
|
||||
global.RewriteAllTransactions();
|
||||
return { result: 1, sessionid: sessionid };
|
||||
};
|
||||
HTTPCaller.RewriteTransactions = function(Param) {
|
||||
global.HTTPCaller.RewriteTransactions = function(Param) {
|
||||
var Ret = global.SERVER.ReWriteDAppTransactions(Param.BlockCount);
|
||||
return { result: Ret, sessionid: sessionid };
|
||||
};
|
||||
HTTPCaller.TruncateBlockChain = function(Param) {
|
||||
global.HTTPCaller.TruncateBlockChain = function(Param) {
|
||||
var StartNum = global.SERVER.BlockNumDB - Param.BlockCount;
|
||||
var MinBlock = global.DApps.Accounts.GetMinBlockAct();
|
||||
if (MinBlock > StartNum) {
|
||||
@@ -1035,12 +1067,12 @@ HTTPCaller.TruncateBlockChain = function(Param) {
|
||||
global.SERVER.TruncateBlockDB(StartNum);
|
||||
return { result: 1, sessionid: sessionid };
|
||||
};
|
||||
HTTPCaller.ClearDataBase = function(Param) {
|
||||
global.HTTPCaller.ClearDataBase = function(Param) {
|
||||
BlockTree.Clear();
|
||||
global.SERVER.ClearDataBase();
|
||||
return { result: 1, sessionid: sessionid };
|
||||
};
|
||||
HTTPCaller.CleanChain = function(Param) {
|
||||
global.HTTPCaller.CleanChain = function(Param) {
|
||||
if (global.CleanChain) {
|
||||
var StartNum = global.SERVER.BlockNumDB - Param.BlockCount;
|
||||
global.CleanChain(StartNum);
|
||||
@@ -1048,7 +1080,7 @@ HTTPCaller.CleanChain = function(Param) {
|
||||
}
|
||||
return { result: 0, sessionid: sessionid };
|
||||
};
|
||||
HTTPCaller.GetArrStats = function(Keys, response) {
|
||||
global.HTTPCaller.GetArrStats = function(Keys, response) {
|
||||
var arr = global.GET_STATDIAGRAMS(Keys);
|
||||
let Result: any = { result: 1, sessionid: sessionid, arr: arr, STAT_MODE: global.STAT_MODE };
|
||||
if (!global.TX_PROCESS || !global.TX_PROCESS.RunRPC)
|
||||
@@ -1073,7 +1105,7 @@ HTTPCaller.GetArrStats = function(Keys, response) {
|
||||
});
|
||||
return null;
|
||||
};
|
||||
HTTPCaller.GetBlockChain = function(type) {
|
||||
global.HTTPCaller.GetBlockChain = function(type) {
|
||||
if (!global.SERVER || !global.SERVER.LoadedChainList) {
|
||||
return { result: 0 };
|
||||
}
|
||||
@@ -1110,14 +1142,14 @@ HTTPCaller.GetBlockChain = function(type) {
|
||||
IsDevelopAccount: global.IsDeveloperAccount(global.WALLET.PubKeyArr), LoadedChainCount: global.SERVER.LoadedChainList.length, StartLoadBlockTime: global.SERVER.StartLoadBlockTime,
|
||||
sessionid: sessionid, result: 1
|
||||
};
|
||||
var obj2: any = HTTPCaller.GetHotArray();
|
||||
var obj2: any = global.HTTPCaller.GetHotArray();
|
||||
obj.ArrTree = obj2.ArrTree;
|
||||
arrBlocks = [];
|
||||
arrLoadedChainList = [];
|
||||
arrLoadedBlocks = [];
|
||||
return obj;
|
||||
};
|
||||
HTTPCaller.GetHistoryTransactions = function(Params) {
|
||||
global.HTTPCaller.GetHistoryTransactions = function(Params) {
|
||||
if (typeof Params === "object" && Params.AccountID) {
|
||||
var Account = global.DApps.Accounts.ReadState(Params.AccountID);
|
||||
if (!Account)
|
||||
@@ -1140,35 +1172,43 @@ HTTPCaller.GetHistoryTransactions = function(Params) {
|
||||
}
|
||||
}
|
||||
var Result: any = {
|
||||
Value: { SumCOIN: Account.Value.SumCOIN, SumCENT: Account.Value.SumCENT }, Name: Account.Name, Currency: Account.Currency,
|
||||
MaxBlockNum: global.GetCurrentBlockNumByTime(), FIRST_TIME_BLOCK: global.FIRST_TIME_BLOCK, result: arr.length > 0 ? 1 : 0, History: arr
|
||||
Value: {
|
||||
SumCOIN: Account.Value.SumCOIN,
|
||||
SumCENT: Account.Value.SumCENT
|
||||
},
|
||||
Name: Account.Name,
|
||||
Currency: Account.Currency,
|
||||
MaxBlockNum: global.GetCurrentBlockNumByTime(),
|
||||
FIRST_TIME_BLOCK: global.FIRST_TIME_BLOCK,
|
||||
result: arr.length > 0 ? 1 : 0,
|
||||
History: arr
|
||||
};
|
||||
return Result;
|
||||
}
|
||||
return { result: 0 };
|
||||
};
|
||||
|
||||
// function GetCopyBlock(Block) {
|
||||
// var Result: any = {
|
||||
// BlockNum: Block.BlockNum, bSave: Block.bSave, TreeHash: global.GetHexFromAddres(Block.TreeHash), AddrHash: global.GetHexFromAddres(Block.AddrHash),
|
||||
// PrevHash: global.GetHexFromAddres(Block.PrevHash), SumHash: global.GetHexFromAddres(Block.SumHash), SumPow: Block.SumPow, TrDataPos: Block.TrDataPos,
|
||||
// TrDataLen: Block.TrDataLen, SeqHash: global.GetHexFromAddres(Block.SeqHash), Hash: global.GetHexFromAddres(Block.Hash), Power: global.GetPowPower(Block.PowHash),
|
||||
// TrCount: Block.TrCount, arrContent: Block.arrContent,
|
||||
// };
|
||||
// return Result;
|
||||
// };
|
||||
function GetCopyBlock(Block) {
|
||||
var Result: any = {
|
||||
BlockNum: Block.BlockNum, bSave: Block.bSave, TreeHash: global.GetHexFromAddres(Block.TreeHash), AddrHash: global.GetHexFromAddres(Block.AddrHash),
|
||||
PrevHash: global.GetHexFromAddres(Block.PrevHash), SumHash: global.GetHexFromAddres(Block.SumHash), SumPow: Block.SumPow, TrDataPos: Block.TrDataPos,
|
||||
TrDataLen: Block.TrDataLen, SeqHash: global.GetHexFromAddres(Block.SeqHash), Hash: global.GetHexFromAddres(Block.Hash), Power: global.GetPowPower(Block.PowHash),
|
||||
TrCount: Block.TrCount, arrContent: Block.arrContent,
|
||||
};
|
||||
return Result;
|
||||
};
|
||||
var AddrLength = 16;
|
||||
|
||||
function GetHexFromAddresShort(Hash) {
|
||||
return global.GetHexFromAddres(Hash).substr(0, AddrLength);
|
||||
};
|
||||
|
||||
// function GetHexFromStrShort(Str) {
|
||||
// if (Str === undefined)
|
||||
// return Str;
|
||||
// else
|
||||
// return Str.substr(0, AddrLength);
|
||||
// };
|
||||
function GetHexFromStrShort(Str) {
|
||||
if (Str === undefined)
|
||||
return Str;
|
||||
else
|
||||
return Str.substr(0, AddrLength);
|
||||
};
|
||||
var glid = 0;
|
||||
|
||||
function GetGUID(Block) {
|
||||
@@ -1201,12 +1241,34 @@ function CopyBlockDraw(Block, MainChains) {
|
||||
Mining = 0;
|
||||
GetGUID(Block);
|
||||
Item = {
|
||||
guid: Block.guid, Active: Block.Active, bSave: Block.bSave, Prepared: Block.Prepared, BlockNum: Block.BlockNum, Hash: GetHexFromAddresShort(Block.Hash),
|
||||
SumHash: GetHexFromAddresShort(Block.SumHash), SeqHash: GetHexFromAddresShort(Block.SeqHash), TreeHash: GetHexFromAddresShort(Block.TreeHash),
|
||||
AddrHash: GetHexFromAddresShort(Block.AddrHash), MinerID: MinerID, MinerName: MinerName, Comment1: Block.Comment1, Comment2: Block.Comment2,
|
||||
SumPow: Block.SumPow, Info: Block.Info, TreeLoaded: Block.TreeEq, AddToLoad: Block.AddToLoad, LoadDB: Block.LoadDB, FindBlockDB: Block.FindBlockDB,
|
||||
TrCount: Block.TrCount, ArrLength: 0, TrDataLen: Block.TrDataLen, Power: global.GetPowPower(Block.PowHash), CheckPoint: CheckPoint, Mining: Mining,
|
||||
TransferSize: Block.TransferSize, HasErr: Block.HasErr,
|
||||
guid: Block.guid,
|
||||
Active: Block.Active,
|
||||
bSave: Block.bSave,
|
||||
Prepared: Block.Prepared,
|
||||
BlockNum: Block.BlockNum,
|
||||
Hash: GetHexFromAddresShort(Block.Hash),
|
||||
SumHash: GetHexFromAddresShort(Block.SumHash),
|
||||
SeqHash: GetHexFromAddresShort(Block.SeqHash),
|
||||
TreeHash: GetHexFromAddresShort(Block.TreeHash),
|
||||
AddrHash: GetHexFromAddresShort(Block.AddrHash),
|
||||
MinerID: MinerID,
|
||||
MinerName: MinerName,
|
||||
Comment1: Block.Comment1,
|
||||
Comment2: Block.Comment2,
|
||||
SumPow: Block.SumPow,
|
||||
Info: Block.Info,
|
||||
TreeLoaded: Block.TreeEq,
|
||||
AddToLoad: Block.AddToLoad,
|
||||
LoadDB: Block.LoadDB,
|
||||
FindBlockDB: Block.FindBlockDB,
|
||||
TrCount: Block.TrCount,
|
||||
ArrLength: 0,
|
||||
TrDataLen: Block.TrDataLen,
|
||||
Power: global.GetPowPower(Block.PowHash),
|
||||
CheckPoint: CheckPoint,
|
||||
Mining: Mining,
|
||||
TransferSize: Block.TransferSize,
|
||||
HasErr: Block.HasErr,
|
||||
};
|
||||
if (Block.chain)
|
||||
Item.chainid = Block.chain.id;
|
||||
@@ -1278,7 +1340,7 @@ function AddMapList(arrLoadedBlocks, type, MapMapLoaded, MainChains?) {
|
||||
}
|
||||
}
|
||||
};
|
||||
// var MapFileHTML5 = {};
|
||||
var MapFileHTML5 = {};
|
||||
|
||||
function SendWebFile(response, name?, StrCookie?, bParsing?) {
|
||||
var type = name.substr(name.length - 4, 4);
|
||||
@@ -1416,28 +1478,28 @@ global.GetFileHTMLFromMarkdown = GetFileHTMLFromMarkdown;
|
||||
global.GetFileSimple = GetFileSimple;
|
||||
global.SaveFileSimple = SaveFileSimple;
|
||||
|
||||
// function GetStrTime(now) {
|
||||
// if (!now)
|
||||
// now = global.GetCurrentTime(0);
|
||||
// var Str = "" + now.getHours().toStringZ(2);
|
||||
// Str = Str + ":" + now.getMinutes().toStringZ(2);
|
||||
// Str = Str + ":" + now.getSeconds().toStringZ(2);
|
||||
// return Str;
|
||||
// };
|
||||
function GetStrTime(now) {
|
||||
if (!now)
|
||||
now = global.GetCurrentTime(0);
|
||||
var Str = "" + now.getHours().toStringZ(2);
|
||||
Str = Str + ":" + now.getMinutes().toStringZ(2);
|
||||
Str = Str + ":" + now.getSeconds().toStringZ(2);
|
||||
return Str;
|
||||
};
|
||||
|
||||
function OnGetData(arg) {
|
||||
// var response = {
|
||||
// end: function() {
|
||||
// }, writeHead: function() {
|
||||
// },
|
||||
// };
|
||||
var response = {
|
||||
end: function() {
|
||||
}, writeHead: function() {
|
||||
},
|
||||
};
|
||||
var Path = arg.path;
|
||||
var obj = arg.obj;
|
||||
if (Path.substr(0, 1) === "/")
|
||||
Path = Path.substr(1);
|
||||
var params = Path.split('/', 5);
|
||||
var Ret;
|
||||
var F = HTTPCaller[params[0]];
|
||||
var F = global.HTTPCaller[params[0]];
|
||||
if (F) {
|
||||
if (obj)
|
||||
Ret = F(obj);
|
||||
@@ -1677,7 +1739,7 @@ function GetEventArray(SmartNum, Context) {
|
||||
}
|
||||
return ArrRet;
|
||||
};
|
||||
HTTPCaller.GetHashRate = function(ArrParams) {
|
||||
global.HTTPCaller.GetHashRate = function(ArrParams) {
|
||||
var CurBlockNum = global.GetCurrentBlockNumByTime();
|
||||
var ResArr = [];
|
||||
for (var i = 0; i < ArrParams.length; i++) {
|
||||
@@ -1703,6 +1765,9 @@ HTTPCaller.GetHashRate = function(ArrParams) {
|
||||
var CountAvg = 10;
|
||||
if (i === ArrParams.length - 1)
|
||||
CountAvg = 3;
|
||||
var StepDeltaAvg = Math.floor(StepDelta / CountAvg);
|
||||
if (StepDeltaAvg < 1)
|
||||
StepDeltaAvg = 1;
|
||||
var ItervalArr = [];
|
||||
for (var Num = Item.BlockNum1; Num < Item.BlockNum2; Num += StepDelta) {
|
||||
var Power;
|
||||
|
||||
Reference in New Issue
Block a user