Fri Jul 19 12:26:00 CST 2019 Source Update...
This commit is contained in:
parent
9e5466dfdd
commit
6d7e4474f7
@ -2753,3 +2753,12 @@ iframe
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.btn--float
|
||||
{
|
||||
float: left;
|
||||
width: 230px;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,17 @@ function $(id)
|
||||
{
|
||||
return document.getElementById(id);
|
||||
};
|
||||
window.Storage = {};
|
||||
window.Storage.setItem = function (Key,Value)
|
||||
{
|
||||
if(window.localStorage)
|
||||
localStorage.setItem(Key, Value);
|
||||
};
|
||||
window.Storage.getItem = function (Key)
|
||||
{
|
||||
if(window.localStorage)
|
||||
return localStorage.getItem(Key);
|
||||
};
|
||||
var WALLET_KEY_NAME = "WALLET_KEY";
|
||||
var WALLET_PUB_KEY_NAME = "WALLET_PUB_KEY";
|
||||
if(!Math.log2)
|
||||
@ -49,17 +60,6 @@ if(!String.prototype.padStart)
|
||||
}
|
||||
};
|
||||
}
|
||||
window.Storage = {};
|
||||
window.Storage.setItem = function (Key,Value)
|
||||
{
|
||||
if(window.localStorage)
|
||||
localStorage.setItem(Key, Value);
|
||||
};
|
||||
window.Storage.getItem = function (Key)
|
||||
{
|
||||
if(window.localStorage)
|
||||
return localStorage.getItem(Key);
|
||||
};
|
||||
window.IsLocalClient = function ()
|
||||
{
|
||||
return (window.location.protocol.substr(0, 4) !== "http");
|
||||
@ -937,7 +937,7 @@ function RetIconPath(Item,bCurrency)
|
||||
return StrPath + '/file/' + Item.IconBlockNum + '/' + Item.IconTrNum;
|
||||
}
|
||||
else
|
||||
return StrPath + "./PIC/blank.svg";
|
||||
return StrPath + "/PIC/blank.svg";
|
||||
};
|
||||
|
||||
function RetIconDapp(Item)
|
||||
@ -1437,9 +1437,9 @@ function AddToInvoiceList(Item)
|
||||
Storage.setItem("InvoiceList", JSON.stringify(arr));
|
||||
};
|
||||
|
||||
function OpenDapps(Num,AccountNum)
|
||||
function OpenDapps(Num,AccountNum,HTMLLength)
|
||||
{
|
||||
if(!Num)
|
||||
if(!Num || !HTMLLength)
|
||||
return ;
|
||||
var StrPath = '/dapp/' + Num;
|
||||
if(IsLocalClient())
|
||||
@ -1801,8 +1801,8 @@ function ToLog(Str)
|
||||
|
||||
function InitMainServer()
|
||||
{
|
||||
var Str = localStorage["MainServer"];
|
||||
if(Str && !localStorage["BIGWALLET"] && Str.substr(0, 1) === "{")
|
||||
var Str = Storage.getItem("MainServer");
|
||||
if(Str && !Storage.getItem("BIGWALLET") && Str.substr(0, 1) === "{")
|
||||
{
|
||||
MainServer = JSON.parse(Str);
|
||||
}
|
||||
@ -1823,13 +1823,13 @@ var KeyPasswordMap = {};
|
||||
|
||||
function InitWalletKeyName()
|
||||
{
|
||||
if(!localStorage["WALLET_KEY"])
|
||||
if(!Storage.getItem("WALLET_KEY"))
|
||||
{
|
||||
localStorage["WALLET_KEY"] = localStorage["idPrivKey"];
|
||||
Storage.setItem("WALLET_KEY", Storage.getItem("idPrivKey"));
|
||||
}
|
||||
if(!localStorage["WALLET_PUB_KEY"])
|
||||
if(!Storage.getItem("WALLET_PUB_KEY"))
|
||||
{
|
||||
localStorage["WALLET_PUB_KEY"] = localStorage["idPubKey"];
|
||||
Storage.setItem("WALLET_PUB_KEY", Storage.getItem("idPubKey"));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1862,8 +1862,11 @@ function OpenWalletKey()
|
||||
{
|
||||
PubKeyStr = "";
|
||||
}
|
||||
sessionStorage[WALLET_KEY_NAME] = RetKey;
|
||||
sessionStorage[WALLET_PUB_KEY_NAME] = PubKeyStr;
|
||||
if(window.sessionStorage)
|
||||
{
|
||||
sessionStorage[WALLET_KEY_NAME] = RetKey;
|
||||
sessionStorage[WALLET_PUB_KEY_NAME] = PubKeyStr;
|
||||
}
|
||||
if(!WALLET_PASSWORD)
|
||||
Storage.setItem(WALLET_PUB_KEY_NAME, PubKeyStr);
|
||||
return RetKey;
|
||||
@ -1880,18 +1883,28 @@ function IsLockedWallet()
|
||||
|
||||
function GetPrivKey()
|
||||
{
|
||||
var Key = sessionStorage[WALLET_KEY_NAME];
|
||||
var Key;
|
||||
if(window.sessionStorage)
|
||||
Key = sessionStorage[WALLET_KEY_NAME];
|
||||
if(!Key)
|
||||
Key = Storage.getItem(WALLET_KEY_NAME);
|
||||
return Key;
|
||||
if(Key && typeof Key === "string" && Key.length >= 64)
|
||||
return Key;
|
||||
else
|
||||
return "";
|
||||
};
|
||||
|
||||
function GetPubKey()
|
||||
{
|
||||
var Key = sessionStorage[WALLET_PUB_KEY_NAME];
|
||||
var Key;
|
||||
if(window.sessionStorage)
|
||||
Key = sessionStorage[WALLET_PUB_KEY_NAME];
|
||||
if(!Key)
|
||||
Key = Storage.getItem(WALLET_PUB_KEY_NAME);
|
||||
return Key;
|
||||
if(Key && typeof Key === "string" && Key.length >= 66)
|
||||
return Key;
|
||||
else
|
||||
return "";
|
||||
};
|
||||
|
||||
function SetPrivKey(StrPrivKey)
|
||||
@ -1912,15 +1925,18 @@ function SetPrivKey(StrPrivKey)
|
||||
Storage.setItem(WALLET_KEY_NAME, Key);
|
||||
Storage.setItem(WALLET_PUB_KEY_NAME, StrPubKey);
|
||||
Storage.setItem("WALLET_PUB_KEY_MAIN", StrPubKey);
|
||||
sessionStorage[WALLET_KEY_NAME] = StrPrivKey;
|
||||
sessionStorage[WALLET_PUB_KEY_NAME] = StrPubKey;
|
||||
if(window.sessionStorage)
|
||||
{
|
||||
sessionStorage[WALLET_KEY_NAME] = StrPrivKey;
|
||||
sessionStorage[WALLET_PUB_KEY_NAME] = StrPubKey;
|
||||
}
|
||||
};
|
||||
|
||||
function SetWalletPassword(Str)
|
||||
{
|
||||
WALLET_PASSWORD = Str;
|
||||
if(localStorage["idPrivKey"])
|
||||
delete localStorage["idPrivKey"];
|
||||
if(Storage.getItem("idPrivKey"))
|
||||
Storage.setItem("idPrivKey", "");
|
||||
};
|
||||
|
||||
function HashProtect(Str)
|
||||
@ -1942,3 +1958,11 @@ function XORHash(arr1,arr2,length)
|
||||
}
|
||||
return arr3;
|
||||
};
|
||||
|
||||
function Right(Str,count)
|
||||
{
|
||||
if(Str.length > count)
|
||||
return Str.substr(Str.length - count, count);
|
||||
else
|
||||
return Str.substr(0, Str.length);
|
||||
};
|
||||
|
@ -11,6 +11,14 @@
|
||||
var MAX_SUM_TER = 1e9;
|
||||
var MAX_SUM_CENT = 1e9;
|
||||
|
||||
function CHECKSUM(Coin)
|
||||
{
|
||||
if(typeof Coin.SumCOIN !== "number")
|
||||
Coin.SumCOIN = 0;
|
||||
if(typeof Coin.SumCENT !== "number")
|
||||
Coin.SumCENT = 0;
|
||||
};
|
||||
|
||||
function ADD(Coin,Value2)
|
||||
{
|
||||
Coin.SumCOIN += Value2.SumCOIN;
|
||||
@ -102,6 +110,7 @@ function COIN_FROM_STRING(Str)
|
||||
};
|
||||
if(typeof global === "object")
|
||||
{
|
||||
global.CHECKSUM = CHECKSUM;
|
||||
global.ADD = ADD;
|
||||
global.SUB = SUB;
|
||||
global.DIV = DIV;
|
||||
|
@ -135,6 +135,15 @@ window.GetCurrentBlockNumByTime = function ()
|
||||
return 0;
|
||||
};
|
||||
|
||||
function SetMinPow()
|
||||
{
|
||||
var item = $("idDeltaPow");
|
||||
if(item)
|
||||
{
|
||||
window.DELTA_POWER_POW_TR = ParseNum(item.value);
|
||||
}
|
||||
};
|
||||
|
||||
function GetBlockNumTr(arr)
|
||||
{
|
||||
var BlockNum = window.DELTA_FOR_TIME_TX + GetCurrentBlockNumByTime();
|
||||
@ -153,6 +162,7 @@ var LastCreatePOWHash = [255, 255, 255, 255];
|
||||
|
||||
function CreateHashBodyPOWInnerMinPower(arr,MinPow,startnonce)
|
||||
{
|
||||
SetMinPow();
|
||||
var TrType = arr[0];
|
||||
var BlockNum = GetBlockNumTr(arr);
|
||||
if(MinPow === undefined)
|
||||
|
@ -75,16 +75,24 @@ window.onload = function ()
|
||||
|
||||
function OnLoad()
|
||||
{
|
||||
if(Storage.getItem("NETWORK"))
|
||||
if(window.location.protocol === "https:")
|
||||
{
|
||||
NETWORK = Storage.getItem("NETWORK");
|
||||
NETWORK = "TERA-MAIN";
|
||||
FillSelect("idCurNetwork", [{value:NETWORK, text:"TERA MAIN"}]);
|
||||
$("idCurNetwork").value = NETWORK;
|
||||
Storage.setItem("NETWORK", NETWORK);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Storage.getItem("NETWORK"))
|
||||
{
|
||||
NETWORK = Storage.getItem("NETWORK");
|
||||
}
|
||||
$("idCurNetwork").value = NETWORK;
|
||||
}
|
||||
$("idCurNetwork").value = NETWORK;
|
||||
LoadValues();
|
||||
InitDappsCard();
|
||||
StartWebWallet();
|
||||
UpdatesExplorerData();
|
||||
UpdatesAccountsData();
|
||||
setInterval(UpdatesExplorerData, 1000);
|
||||
setInterval(UpdatesAccountsData, 1000);
|
||||
DoStableScroll();
|
||||
@ -107,9 +115,14 @@ function ChangeNetwork()
|
||||
CONNECT_STATUS = 0;
|
||||
NETWORK = $("idCurNetwork").value;
|
||||
Storage.setItem("NETWORK", NETWORK);
|
||||
StartWebWallet();
|
||||
ConnectWebWallet();
|
||||
};
|
||||
|
||||
function UpdateTabs()
|
||||
{
|
||||
UpdatesExplorerData();
|
||||
UpdatesAccountsData();
|
||||
ViewDapps();
|
||||
};
|
||||
|
||||
function OnFindServer()
|
||||
@ -124,13 +137,16 @@ function OnFindServer()
|
||||
CONNECT_STATUS = 2;
|
||||
Storage.setItem("MainServer", JSON.stringify({ip:MainServer.ip, port:MainServer.port}));
|
||||
FillCurrencyAsync("idAccountCur");
|
||||
UpdateTabs();
|
||||
};
|
||||
|
||||
function LoadValues()
|
||||
{
|
||||
var StrDelList = localStorage["DelList"];
|
||||
var StrDelList = Storage.getItem("DelList");
|
||||
if(StrDelList)
|
||||
DelList = JSON.parse(StrDelList);
|
||||
if(typeof DelList !== "object")
|
||||
DelList = {};
|
||||
if(LoadValuesByArr(SaveIdArr))
|
||||
{
|
||||
ChangeLang();
|
||||
@ -141,7 +157,7 @@ function LoadValues()
|
||||
function SaveValues()
|
||||
{
|
||||
SaveValuesByArr(SaveIdArr);
|
||||
localStorage["DelList"] = JSON.stringify(DelList);
|
||||
Storage.setItem("DelList", JSON.stringify(DelList));
|
||||
};
|
||||
var TabArr = [{name:"TabWelcome"}, {name:"TabWalletSet"}, {name:"TabKeySet"}, {name:"TabAccounts"}, {name:"TabSend"}, {name:"TabDapps"},
|
||||
{name:"TabExplorer"}, {name:"TabLogo"}];
|
||||
@ -300,10 +316,6 @@ function UpdatesAccountsData()
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FirstAccountsData && !Data.arr.length)
|
||||
{
|
||||
SelectTab('TabAccounts');
|
||||
}
|
||||
}
|
||||
FirstAccountsData = 0;
|
||||
});
|
||||
@ -409,9 +421,21 @@ function SetAccountsCard(Data,AccountsDataStr)
|
||||
var Str = StrAccCardTemplate;
|
||||
Str = Str.replace("AccCardTemplate", "idCard" + Item.Num);
|
||||
Str = Str.replace(/{Item.Num}/g, Item.Num);
|
||||
Str = Str.replace("{Value.SumCOIN}", Item.Value.SumCOIN);
|
||||
Str = Str.replace("{Value.SumCENT}", Item.Value.SumCENT);
|
||||
Str = Str.replace("{Value.CurrencyName}", CurrencyName(Item.Currency));
|
||||
var Str1, Str2;
|
||||
if(Item.Value.SumCOIN || Item.Value.SumCENT)
|
||||
{
|
||||
Str1 = Item.Value.SumCOIN;
|
||||
Str2 = "," + Right("000000000" + Item.Value.SumCENT, 9);
|
||||
}
|
||||
else
|
||||
{
|
||||
Str1 = "";
|
||||
Str2 = "";
|
||||
}
|
||||
var StrCurrencyName = CurrencyName(Item.Currency);
|
||||
Str = Str.replace("{Value.SumCOIN}", Str1);
|
||||
Str = Str.replace("{Value.SumCENT}", Str2);
|
||||
Str = Str.replace("{Value.CurrencyName}", StrCurrencyName);
|
||||
var CurrencyObj = Item.CurrencyObj;
|
||||
if(!CurrencyObj)
|
||||
CurrencyObj = {IconBlockNum:0, Num:0};
|
||||
@ -422,11 +446,12 @@ function SetAccountsCard(Data,AccountsDataStr)
|
||||
Str = Str.replace("{Item.Name}", escapeHtml(Item.Name));
|
||||
var SmartObj = Item.SmartObj;
|
||||
if(!SmartObj)
|
||||
SmartObj = {Name:"", Num:0};
|
||||
SmartObj = {Name:"", Num:0, HTMLLength:0};
|
||||
SmartObj.IconPath = RetIconPath(SmartObj, 0);
|
||||
Str = Str.replace("{SmartObj.IconPath}", SmartObj.IconPath);
|
||||
Str = Str.replace("{SmartObj.Name}", escapeHtml(SmartObj.Name));
|
||||
Str = Str.replace(/{SmartObj.Num}/g, SmartObj.Num);
|
||||
Str = Str.replace(/{SmartObj.HTMLLength}/g, SmartObj.HTMLLength);
|
||||
if(SmartObj.Num)
|
||||
{
|
||||
Str = Str.replace("prod-card__link--connect", "myhidden");
|
||||
@ -462,15 +487,40 @@ function SetAccountsCard(Data,AccountsDataStr)
|
||||
delete LoadMapAfter["idAccount"];
|
||||
}
|
||||
};
|
||||
var glWasSmart;
|
||||
var glWasNumAccount;
|
||||
|
||||
function ChangeSmartLocal(NumAccount,WasSmart)
|
||||
{
|
||||
if(!IsPrivateMode())
|
||||
{
|
||||
SetError("Pls, open wallet");
|
||||
return 0;
|
||||
}
|
||||
openModal('idSmartEnter');
|
||||
if(WasSmart)
|
||||
$("idSmartNum").value = WasSmart;
|
||||
else
|
||||
$("idSmartNum").value = "";
|
||||
$("idSmartNum").focus();
|
||||
glWasNumAccount = NumAccount;
|
||||
glWasSmart = WasSmart;
|
||||
};
|
||||
|
||||
function DoSetSmartLocal()
|
||||
{
|
||||
DoChangeSmart(glWasNumAccount, glWasSmart, $("idSmartNum").value);
|
||||
closeModal();
|
||||
};
|
||||
|
||||
function ConnectSmart(NumAccount)
|
||||
{
|
||||
ChangeSmart(NumAccount, 0);
|
||||
ChangeSmartLocal(NumAccount, 0);
|
||||
};
|
||||
|
||||
function SetSmart(NumAccount,WasSmart)
|
||||
{
|
||||
ChangeSmart(NumAccount, WasSmart);
|
||||
ChangeSmartLocal(NumAccount, WasSmart);
|
||||
};
|
||||
|
||||
function DelSmart(NumAccount,WasSmart)
|
||||
@ -914,6 +964,7 @@ function FillDappCard(Str,Item)
|
||||
Str = Str.replace("{Item.Owner}", Item.Owner);
|
||||
if(!Item.TokenGenerate)
|
||||
Str = Str.replace("dapp-modal__ok-token", "myhidden");
|
||||
Str = Str.replace(/{Item.HTMLLength}/g, Item.HTMLLength);
|
||||
Str = Str.replace("{Item.IconPath}", RetIconPath(Item, 0));
|
||||
return Str;
|
||||
};
|
||||
@ -940,10 +991,13 @@ function OpenDappCard(Num)
|
||||
openModal('DappCardTemplate');
|
||||
};
|
||||
|
||||
function OpenDapp(Num)
|
||||
function OpenOnlyDapp(Num,HTMLLength)
|
||||
{
|
||||
OpenDapps(Num);
|
||||
closeModal();
|
||||
if(HTMLLength)
|
||||
{
|
||||
OpenDapps(Num, 0, HTMLLength);
|
||||
closeModal();
|
||||
}
|
||||
};
|
||||
|
||||
function FillDappCategory(Str,Item,Num)
|
||||
|
@ -658,17 +658,11 @@ function SendTrCreateAcc(Currency,PubKey,Description,Adviser,Smart,bFindAcc,bAdd
|
||||
CancelCreateAccount();
|
||||
};
|
||||
|
||||
function ChangeSmart(NumAccount,WasSmart)
|
||||
function DoChangeSmart(NumAccount,WasSmart,SmartNum)
|
||||
{
|
||||
if(!IsPrivateMode())
|
||||
if(SmartNum !== null && SmartNum != WasSmart)
|
||||
{
|
||||
SetError("Pls, open wallet");
|
||||
return 0;
|
||||
}
|
||||
var Result = prompt("Enter smart number:", WasSmart);
|
||||
if(Result !== null && Result != WasSmart)
|
||||
{
|
||||
var Smart = parseInt(Result);
|
||||
var Smart = parseInt(SmartNum);
|
||||
if(Smart)
|
||||
{
|
||||
GetData("GetDappList", {StartNum:Smart, CountNum:1}, function (Data)
|
||||
@ -690,6 +684,17 @@ function ChangeSmart(NumAccount,WasSmart)
|
||||
}
|
||||
};
|
||||
|
||||
function ChangeSmart(NumAccount,WasSmart)
|
||||
{
|
||||
if(!IsPrivateMode())
|
||||
{
|
||||
SetError("Pls, open wallet");
|
||||
return 0;
|
||||
}
|
||||
var SmartNum = prompt("Enter smart number:", WasSmart);
|
||||
DoChangeSmart(NumAccount, WasSmart, SmartNum);
|
||||
};
|
||||
|
||||
function SetSmartToAccount(NumAccount,Smart)
|
||||
{
|
||||
var OperationID = 0;
|
||||
|
@ -30,7 +30,7 @@
|
||||
{
|
||||
InitMainServer();
|
||||
|
||||
document.body.className="univers "+localStorage["idSelStyle"];
|
||||
document.body.className="univers "+Storage.getItem("idSelStyle");
|
||||
var i=document.URL.indexOf("#");
|
||||
if(i>0)
|
||||
{
|
||||
|
@ -69,12 +69,14 @@
|
||||
$("idConsoleSend").value=Data.Type;
|
||||
$("idProcessTX").checked=Data.ProcessTX;
|
||||
$("idProcessWEB").checked=Data.ProcessWEB;
|
||||
$("idProcessST").checked=Data.ProcessST;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("idConsoleText").value=Data;
|
||||
$("idProcessTX").checked=0;
|
||||
$("idProcessWEB").checked=0;
|
||||
$("idProcessST").checked=0;
|
||||
$("idConsoleSend").value="ServerCode";
|
||||
}
|
||||
if(bRun)
|
||||
@ -101,7 +103,7 @@
|
||||
|
||||
if(Name)
|
||||
{
|
||||
var Data={Code:$("idConsoleText").value,Type:$("idConsoleSend").value,ProcessTX:$("idProcessTX").checked,ProcessWEB:$("idProcessWEB").checked};
|
||||
var Data={Code:$("idConsoleText").value,Type:$("idConsoleSend").value,ProcessTX:$("idProcessTX").checked,ProcessWEB:$("idProcessWEB").checked,ProcessST:$("idProcessST").checked};
|
||||
CodeList[Name]=Data;
|
||||
}
|
||||
|
||||
@ -209,9 +211,11 @@
|
||||
{
|
||||
var bProcessTX = $("idProcessTX").checked;
|
||||
var bProcessWEB = $("idProcessWEB").checked;
|
||||
var bProcessST = $("idProcessST").checked;
|
||||
|
||||
|
||||
SetStatus("");
|
||||
GetData("SendDirectCode",{Code:Value,TX:bProcessTX,WEB:bProcessWEB }, function (Data)
|
||||
GetData("SendDirectCode",{Code:Value,TX:bProcessTX,WEB:bProcessWEB,ST:bProcessST }, function (Data)
|
||||
{
|
||||
if(Data)
|
||||
{
|
||||
@ -403,7 +407,7 @@
|
||||
LoadValues();
|
||||
SaveArrToSelect();
|
||||
|
||||
document.body.className="univers "+localStorage["idSelStyle"];
|
||||
document.body.className="univers "+Storage.getItem("idSelStyle");
|
||||
|
||||
|
||||
SetStatus("");
|
||||
@ -427,6 +431,7 @@
|
||||
|
||||
$("idProcessTX").checked=(localStorage["idConsoleProcessTX"]==="true");
|
||||
$("idProcessWEB").checked=(localStorage["idConsoleProcessWEB"]==="true");
|
||||
$("idProcessST").checked=(localStorage["idConsoleProcessST"]==="true");
|
||||
if(localStorage["idConsolePeriodRun"])
|
||||
$("idPeriodRun").value=localStorage["idConsolePeriodRun"];
|
||||
}
|
||||
@ -443,6 +448,8 @@
|
||||
|
||||
localStorage["idConsoleProcessTX"]=$("idProcessTX").checked;
|
||||
localStorage["idConsoleProcessWEB"]=$("idProcessWEB").checked;
|
||||
localStorage["idConsoleProcessST"]=$("idProcessST").checked;
|
||||
|
||||
|
||||
localStorage["idConsolePeriodRun"]=$("idPeriodRun").value;
|
||||
}
|
||||
@ -506,6 +513,7 @@
|
||||
<INPUT type="number" id="idPeriodRun" style="width: 50px;" onchange="SaveValues();" value="1">sec
|
||||
TX process:<INPUT type="checkbox" id="idProcessTX">
|
||||
WEB process:<INPUT type="checkbox" id="idProcessWEB">
|
||||
Static process:<INPUT type="checkbox" id="idProcessST">
|
||||
|
||||
|
||||
<BR>
|
||||
|
@ -28,8 +28,9 @@
|
||||
|
||||
function SetStatus(Str)
|
||||
{
|
||||
var id = $("idStatus");
|
||||
id.innerHTML=Str;
|
||||
console.log(Str);
|
||||
// var id = $("idStatus");
|
||||
// id.innerHTML=Str;
|
||||
}
|
||||
|
||||
window.onload=function()
|
||||
@ -48,7 +49,7 @@
|
||||
{
|
||||
InitMainServer();
|
||||
|
||||
document.body.className="univers "+localStorage["idSelStyle"];
|
||||
document.body.className="univers "+Storage.getItem("idSelStyle");
|
||||
var i=document.URL.indexOf("#");
|
||||
if(i>0)
|
||||
{
|
||||
|
@ -444,7 +444,7 @@
|
||||
ArrSystem=DiagramArrR;
|
||||
}
|
||||
|
||||
var StrArr=localStorage["DiagramArr"];
|
||||
var StrArr=Storage.getItem("DiagramArr");
|
||||
if(StrArr && StrArr!=="undefined")
|
||||
{
|
||||
DiagramArr=JSON.parse(StrArr);
|
||||
|
@ -63,7 +63,7 @@
|
||||
var SaveIdArr=["idAccount","idTo","idSumSend","idDescription","idSelStyle",
|
||||
"idViewAccountNum","idViewBlockNum","idViewActNum","idViewHashNum","idViewDappNum",
|
||||
"idRunText","idViewAccountFilter",
|
||||
"idBlockCount","idPeriodAutoCheckPoint"];
|
||||
"idBlockCount","idPeriodAutoCheckPoint","idDeltaPow"];
|
||||
|
||||
|
||||
var MaxAccID=0;
|
||||
@ -1731,6 +1731,7 @@
|
||||
<BR>
|
||||
<INPUT type="button" onclick="SignJSON()" class="btdoit bt" value="Sign JSON" id="idSignJSON">
|
||||
<INPUT type="button" onclick="SendMoneyJSON()" class="btdoit bt" value="Send from JSON">
|
||||
Pow:<INPUT type="number" id="idDeltaPow" style="width: 60px" value="" onchange="SetMinPow()">
|
||||
</DIV>
|
||||
|
||||
<script>
|
||||
|
@ -143,7 +143,7 @@
|
||||
<div class="wallet-wrapper" style="padding-top: 10px;">
|
||||
<button class="btn btn--full-width wallet-settings__generate" id="idKeyEdit" onclick="SelectTab('TabWalletSet')">Edit</button>
|
||||
|
||||
<div class="wallet-settings__btns-wrapper">
|
||||
<div class="wallet-settings__btns-wrapper nomobile">
|
||||
<button class="btn btn--white" onclick="downloadKey('idPrivKeyEdit')" id="idSave2">Save key</button>
|
||||
<label for="load-key2" class="btn btn--white" onchange="UploadKey('load-key2')" id="idLoad2">
|
||||
<input class="hidden" id="load-key2" type="file">
|
||||
@ -214,7 +214,7 @@
|
||||
<a onclick="OpenHistoryPage({Item.Num})" class="prod-card__id prod-card__id--mobile-active pointer">{Item.Num}</a>
|
||||
<a onclick="OpenHistoryPage({Item.Num})" target='_blank' class="prod-card__id prod-card__id--desktop pointer">{Item.Num}</a>
|
||||
<div class="prod-card__heading">
|
||||
<span class="prod-card__coins-count">{Value.SumCOIN}<sup>,{Value.SumCENT}</sup><br>
|
||||
<span class="prod-card__coins-count">{Value.SumCOIN}<sup>{Value.SumCENT}</sup><br>
|
||||
<span class="light-grey-text small-text mob-hidden">{Value.CurrencyName}</span>
|
||||
</span>
|
||||
<span class="prod-card__currency prod-card__currency--with-dot">
|
||||
@ -227,7 +227,7 @@
|
||||
|
||||
<div class="prod-card__footer">
|
||||
<div class="prod-card__footer-wrap" >
|
||||
<a onclick="OpenDapps({SmartObj.Num},{Item.Num})" class="prod-card__link prod-card__link--dapp">
|
||||
<a onclick="OpenDapps({SmartObj.Num},{Item.Num},{SmartObj.HTMLLength})" class="prod-card__link prod-card__link--dapp">
|
||||
<img src="{SmartObj.IconPath}" alt="." width="32" height="32">
|
||||
<span class="prod-card__dapp-name mob-hidden">{SmartObj.Name}</span>
|
||||
</a>
|
||||
@ -414,7 +414,7 @@
|
||||
<div class="prod-card__second-line">
|
||||
<div class="prod-card__second-line-left">
|
||||
<div class="prod-card__heading">
|
||||
<a class="prod-card__link" onclick="OpenDapp({Item.Num})">{Item.Name}</a>
|
||||
<a class="prod-card__link" onclick="OpenOnlyDapp({Item.Num},{Item.HTMLLength})">{Item.Name}</a>
|
||||
<!--<span class="lighter-grey-text">Without token generate</span>-->
|
||||
<!--<span class="dapp-modal__ok-token">Token generate</span>-->
|
||||
</div>
|
||||
@ -426,7 +426,7 @@
|
||||
<!--</ol> -->
|
||||
</div>
|
||||
<div class="prod-card__second-line-img">
|
||||
<a class="prod-card__link" onclick="OpenDapp({Item.Num})"><img src="{Item.IconPath}" width="32"></a>
|
||||
<a class="prod-card__link" onclick="OpenOnlyDapp({Item.Num},{Item.HTMLLength})"><img src="{Item.IconPath}" width="32"></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@ -551,7 +551,7 @@
|
||||
</dl>
|
||||
|
||||
<div class="modal__btns-wrap">
|
||||
<button class="btn" onclick="OpenDapp({Item.Num})">Open DApp</button>
|
||||
<button class="btn" onclick="OpenOnlyDapp({Item.Num},{Item.HTMLLength})">Open DApp</button>
|
||||
<button class="btn btn--white" onclick="closeModal()">Back</button>
|
||||
</div>
|
||||
|
||||
@ -633,6 +633,17 @@
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
<section class="modal password-modal" id="idSmartEnter">
|
||||
<h2 class="password-modal__title">Enter number of dapp</h2>
|
||||
<p class="password-modal__subtitle">Enter the dapps number that will be added to your account. Attention make sure that you trust this dapp, otherwise you may lose all funds in this account.</p>
|
||||
|
||||
<input type="number" class="password-modal__input" placeholder="Dapp number" id="idSmartNum">
|
||||
<a class="btn btn--270 btn--float" onclick="DoSetSmartLocal()">OK</a>
|
||||
<a class="btn btn--270 btn--float btn--white" onclick="closeModal()">Cancel</a>
|
||||
</section>
|
||||
|
||||
|
||||
<div class="fixed-status">
|
||||
<div class="fixed-status__wrap">
|
||||
<div id="idStatus" class="fixed-status__status"> </div>
|
||||
@ -640,7 +651,7 @@
|
||||
<option value="TERA-MAIN">TERA MAIN</option>
|
||||
<option value="TERA-TEST3">TERA TEST3</option>
|
||||
</select>
|
||||
<button class="grey-btn reconnect" onclick="ConnectWebWallet()" title="Reconnect"><span>RECONNECT</span></button>
|
||||
<button class="grey-btn reconnect" onclick="ChangeNetwork()" title="Reconnect"><span>RECONNECT</span></button>
|
||||
<!--рудименты-->
|
||||
<span id="idNetwork" style="display: none"></span>
|
||||
<span id="idSignJSON"></span>
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Telegram: https://t.me/terafoundation
|
||||
*/
|
||||
|
||||
global.UPDATE_CODE_VERSION_NUM = 1137;
|
||||
global.UPDATE_CODE_VERSION_NUM = 1151;
|
||||
global.MIN_CODE_VERSION_NUM = 1114;
|
||||
global.MINING_VERSION_NUM = 0;
|
||||
global.InitParamsArg = InitParamsArg;
|
||||
@ -67,7 +67,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;
|
||||
@ -80,7 +80,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;
|
||||
@ -91,7 +90,7 @@ global.TRUST_PROCESS_COUNT = 80000;
|
||||
global.MAX_NODES_RETURN = 100;
|
||||
global.MAX_WAIT_PERIOD_FOR_STATUS = 10 * 1000;
|
||||
global.MAX_GRAY_CONNECTIONS_TO_SERVER = 10;
|
||||
global.MAX_PACKET_LENGTH = 450 * 1024;
|
||||
global.MAX_PACKET_LENGTH = 550 * 1024;
|
||||
global.COUNT_BLOCKS_FOR_LOAD = 600;
|
||||
global.TR_LEN = 100;
|
||||
global.BLOCK_PROCESSING_LENGTH = 8;
|
||||
@ -165,7 +164,6 @@ if(global.LOCAL_RUN)
|
||||
global.NEW_FORMULA_TARGET2 = 1;
|
||||
NETWORK = "LOCAL";
|
||||
global.ALL_VIEW_ROWS = 1;
|
||||
global.COUNT_NODE_PROOF = 1;
|
||||
global.NEW_SIGN_TIME = 0;
|
||||
}
|
||||
else
|
||||
@ -196,11 +194,11 @@ else
|
||||
global.NEW_FORMULA_KTERA = 3;
|
||||
global.NEW_FORMULA_TARGET1 = 0;
|
||||
global.NEW_FORMULA_TARGET2 = 1;
|
||||
global.COUNT_NODE_PROOF = 8;
|
||||
global.REST_START_COUNT = 1000;
|
||||
global.NEW_SIGN_TIME = 1;
|
||||
global.MAX_LENGTH_SENDER_MAP = 100;
|
||||
global.DELTA_START_SENDER_MAP = 12;
|
||||
global.REST_START_COUNT = 0;
|
||||
global.LOAD_TO_BEGIN = 0;
|
||||
}
|
||||
if(global.LOCAL_RUN)
|
||||
{
|
||||
|
@ -685,13 +685,15 @@ HTTPCaller.SendTransactionHex = function (Params)
|
||||
HTTPCaller.SendDirectCode = function (Params,response)
|
||||
{
|
||||
var Result;
|
||||
if(Params.TX || Params.WEB)
|
||||
if(Params.TX || Params.WEB || Params.ST)
|
||||
{
|
||||
var RunProcess;
|
||||
if(Params.TX)
|
||||
RunProcess = global.TX_PROCESS;
|
||||
if(Params.WEB)
|
||||
RunProcess = global.WEB_PROCESS;
|
||||
if(Params.ST)
|
||||
RunProcess = global.STATIC_PROCESS;
|
||||
if(RunProcess && RunProcess.RunRPC)
|
||||
{
|
||||
RunProcess.RunRPC("EvalCode", Params.Code, function (Err,Ret)
|
||||
|
@ -9,6 +9,13 @@
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
var MIN_POW_CHAINS = 2;
|
||||
global.COUNT_NODE_PROOF = 6;
|
||||
if(global.TEST_NETWORK)
|
||||
{
|
||||
MIN_POW_CHAINS = 1;
|
||||
global.COUNT_NODE_PROOF = 1;
|
||||
}
|
||||
module.exports = class CRest extends require("./db/block-db")
|
||||
{
|
||||
constructor(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)
|
||||
@ -54,6 +61,10 @@ module.exports = class CRest extends require("./db/block-db")
|
||||
switch(Context.Mode)
|
||||
{
|
||||
case 0:
|
||||
if(!global.TX_PROCESS)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
var ArrNodes = this.GetActualNodes();
|
||||
for(var i = 0; i < ArrNodes.length; i++)
|
||||
{
|
||||
@ -63,7 +74,7 @@ module.exports = class CRest extends require("./db/block-db")
|
||||
continue;
|
||||
}
|
||||
Node.SendRestGetHeader = 1
|
||||
ToLog("Send rest get headers from " + Context.BlockNumProof + " to " + NodeName(Node), 2)
|
||||
ToLog("Send rest get header " + Context.BlockNumProof + " to " + NodeName(Node), 2)
|
||||
this.SendF(Node, {"Method":"GETBLOCKHEADER", "Data":{Foward:1, BlockNum:Context.BlockNumProof, Hash:[]}, "Context":{F:this.RETBLOCKHEADER_REST.bind(this)},
|
||||
})
|
||||
Context.SendGetHeaderCount++
|
||||
@ -95,7 +106,7 @@ module.exports = class CRest extends require("./db/block-db")
|
||||
MaxPow = parseInt(key)
|
||||
}
|
||||
}
|
||||
if(MaxCount < 2 || MaxPow === 0)
|
||||
if(MaxCount < MIN_POW_CHAINS || MaxPow === 0)
|
||||
{
|
||||
ToLog("****************************************************************** Error MaxPow=" + MaxPow + " - reload.")
|
||||
this.CheckSyncRest()
|
||||
|
@ -15,8 +15,10 @@ require("../system/smart");
|
||||
require("../system/file");
|
||||
require("../system/messager");
|
||||
require("../system/names");
|
||||
if(global.PROCESS_NAME === "MAIN" || global.PROCESS_NAME === "TX")
|
||||
if(global.PROCESS_NAME === "MAIN")
|
||||
{
|
||||
require("./wallet");
|
||||
}
|
||||
module.exports = class CSmartContract extends require("./block-exchange")
|
||||
{
|
||||
constructor(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)
|
||||
|
@ -28,6 +28,14 @@ function RunOnUpdate()
|
||||
{
|
||||
SERVER.ClearDataBase();
|
||||
}
|
||||
if(CurNum < 1142)
|
||||
{
|
||||
setTimeout(function ()
|
||||
{
|
||||
ToLog("UPD: START RewriteAllTransactions");
|
||||
SERVER.RewriteAllTransactions();
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ class CApp
|
||||
this.KeyPair = crypto.createECDH('secp256k1')
|
||||
if(Params.Protect)
|
||||
{
|
||||
ToLogClient("Wallet protect by password")
|
||||
ToLog("Wallet protect by password")
|
||||
this.KeyXOR = GetArrFromHex(Params.KeyXOR)
|
||||
this.WalletOpen = false
|
||||
this.SetPrivateKey(Params.PubKey)
|
||||
|
143
Source/process/child-process.js
Normal file
143
Source/process/child-process.js
Normal file
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* @project: TERA
|
||||
* @version: Development (beta)
|
||||
* @license: MIT (not for evil)
|
||||
* @copyright: Yuriy Ivanov (Vtools) 2017-2019 [progr76@gmail.com]
|
||||
* Web: https://terafoundation.org
|
||||
* Twitter: https://twitter.com/terafoundation
|
||||
* Telegram: https://t.me/terafoundation
|
||||
*/
|
||||
|
||||
global.GlobalRunID = 0;
|
||||
global.GlobalRunMap = {};
|
||||
var LastAlive = Date.now();
|
||||
setTimeout(function ()
|
||||
{
|
||||
setInterval(CheckAlive, 1000);
|
||||
}, 20000);
|
||||
if(process.send)
|
||||
{
|
||||
setInterval(function ()
|
||||
{
|
||||
process.send({cmd:"Alive"});
|
||||
}, 1000);
|
||||
process.send({cmd:"online", message:"OK"});
|
||||
setInterval(function ()
|
||||
{
|
||||
process.send({cmd:"Alive"});
|
||||
}, 1000);
|
||||
global.ToLogClient = function (Str,StrKey,bFinal)
|
||||
{
|
||||
process.send({cmd:"ToLogClient", Str:"" + Str, StrKey:StrKey, bFinal:bFinal});
|
||||
};
|
||||
}
|
||||
|
||||
function CheckAlive()
|
||||
{
|
||||
if(global.NOALIVE)
|
||||
return ;
|
||||
var Delta = Date.now() - LastAlive;
|
||||
if(Delta > CHECK_STOP_CHILD_PROCESS)
|
||||
{
|
||||
ToLog("ALIVE TIMEOUT. Stop and exit: " + Delta + "/" + global.CHECK_STOP_CHILD_PROCESS);
|
||||
Exit();
|
||||
return ;
|
||||
}
|
||||
};
|
||||
process.on('message', function (msg)
|
||||
{
|
||||
LastAlive = Date.now();
|
||||
switch(msg.cmd)
|
||||
{
|
||||
case "Alive":
|
||||
DELTA_CURRENT_TIME = msg.DELTA_CURRENT_TIME;
|
||||
break;
|
||||
case "Exit":
|
||||
Exit();
|
||||
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 "retcall":
|
||||
var F = GlobalRunMap[msg.id];
|
||||
if(F)
|
||||
{
|
||||
delete GlobalRunMap[msg.id];
|
||||
F(msg.Err, msg.Params);
|
||||
}
|
||||
break;
|
||||
case "ToLogClient":
|
||||
{
|
||||
ToLogClient0(msg.Str, msg.StrKey, msg.bFinal);
|
||||
break;
|
||||
}
|
||||
case "Eval":
|
||||
EvalCode(msg.Code);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
function Exit()
|
||||
{
|
||||
if(global.OnExit)
|
||||
global.OnExit();
|
||||
process.exit(0);
|
||||
};
|
||||
process.RunRPC = function (Name,Params,F)
|
||||
{
|
||||
if(F)
|
||||
{
|
||||
GlobalRunID++;
|
||||
try
|
||||
{
|
||||
process.send({cmd:"call", id:GlobalRunID, Name:Name, Params:Params});
|
||||
GlobalRunMap[GlobalRunID] = F;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
process.send({cmd:"call", id:0, Name:Name, Params:Params});
|
||||
}
|
||||
};
|
||||
global.EvalCode = function (Code)
|
||||
{
|
||||
var Result;
|
||||
try
|
||||
{
|
||||
var ret = eval(Code);
|
||||
Result = JSON.stringify(ret, "", 4);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
Result = "" + e;
|
||||
}
|
||||
return Result;
|
||||
};
|
||||
process.on('uncaughtException', function (err)
|
||||
{
|
||||
ToError(err.stack);
|
||||
ToLog(err.stack);
|
||||
TO_ERROR_LOG(global.PROCESS_NAME, 777, err);
|
||||
ToLog("-----------------" + global.PROCESS_NAME + " EXIT------------------");
|
||||
process.exit();
|
||||
});
|
||||
process.on('error', function (err)
|
||||
{
|
||||
ToError(global.PROCESS_NAME + ":\n" + err.stack);
|
||||
ToLog(err.stack);
|
||||
});
|
@ -404,7 +404,7 @@ function AllAlive()
|
||||
{
|
||||
for(var i = 0; i < ArrMiningWrk.length; i++)
|
||||
{
|
||||
ArrMiningWrk[i].send({cmd:"Alive"});
|
||||
ArrMiningWrk[i].send({cmd:"Alive", DELTA_CURRENT_TIME:DELTA_CURRENT_TIME});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -46,37 +46,14 @@ PROCESS.on('message', function (msg)
|
||||
}
|
||||
}
|
||||
else
|
||||
if(msg.cmd === "SetBlock")
|
||||
if(msg.cmd === "Alive")
|
||||
{
|
||||
var StartNonce = 1000000 * (1 + msg.Num);
|
||||
if(Block.HashCount)
|
||||
{
|
||||
process.send({cmd:"HASHRATE", CountNonce:Block.HashCount, Hash:Block.Hash});
|
||||
}
|
||||
Block.HashCount = 0;
|
||||
Block = msg;
|
||||
Block.Time = Date.now();
|
||||
Block.LastNonce = StartNonce;
|
||||
Block.Period = CONSENSUS_PERIOD_TIME * Block.Percent / 100;
|
||||
if(Block.Period > 0 && Block.RunPeriod > 0)
|
||||
{
|
||||
CalcPOWHash();
|
||||
if(idInterval !== undefined)
|
||||
{
|
||||
clearInterval(idInterval);
|
||||
}
|
||||
idInterval = setInterval(CalcPOWHash, Block.RunPeriod);
|
||||
}
|
||||
}
|
||||
else
|
||||
if(msg.cmd === "Alive")
|
||||
if(msg.cmd === "Exit")
|
||||
{
|
||||
PROCESS.exit(0);
|
||||
}
|
||||
else
|
||||
if(msg.cmd === "Exit")
|
||||
{
|
||||
PROCESS.exit(0);
|
||||
}
|
||||
});
|
||||
|
||||
function CheckAlive()
|
||||
|
@ -20,41 +20,11 @@ global.DATA_PATH = GetNormalPathString(global.DATA_PATH);
|
||||
global.CODE_PATH = GetNormalPathString(global.CODE_PATH);
|
||||
require("../core/library");
|
||||
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"});
|
||||
require("./child-process");
|
||||
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;
|
||||
@ -75,32 +45,6 @@ process.on('message', function (msg)
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
function CheckAlive()
|
||||
{
|
||||
if(global.NOALIVE)
|
||||
return ;
|
||||
var Delta = Date.now() - LastAlive;
|
||||
if(Delta > CHECK_STOP_CHILD_PROCESS)
|
||||
{
|
||||
ToLog("STATIC-DB: ALIVE TIMEOUT Stop and exit: " + Delta + "/" + global.CHECK_STOP_CHILD_PROCESS);
|
||||
process.exit(0);
|
||||
return ;
|
||||
}
|
||||
};
|
||||
process.on('uncaughtException', function (err)
|
||||
{
|
||||
ToError(err.stack);
|
||||
ToLog(err.stack);
|
||||
TO_ERROR_LOG("STATIC-DB", 777, err);
|
||||
ToLog("-----------------STATIC-DB EXIT------------------");
|
||||
process.exit();
|
||||
});
|
||||
process.on('error', function (err)
|
||||
{
|
||||
ToError("STATIC-DB:\n" + err.stack);
|
||||
ToLog(err.stack);
|
||||
});
|
||||
var CServerDB = require("../core/db/block-db");
|
||||
var KeyPair = crypto.createECDH('secp256k1');
|
||||
KeyPair.setPrivateKey(Buffer.from([77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
|
||||
|
@ -16,58 +16,18 @@ global.DATA_PATH = GetNormalPathString(global.DATA_PATH);
|
||||
global.CODE_PATH = GetNormalPathString(global.CODE_PATH);
|
||||
require("../core/library");
|
||||
global.READ_ONLY_DB = 0;
|
||||
var LastAlive = Date.now();
|
||||
setTimeout(function ()
|
||||
{
|
||||
setInterval(CheckAlive, 1000);
|
||||
}, 20000);
|
||||
require("./child-process");
|
||||
setInterval(PrepareStatEverySecond, 1000);
|
||||
if(process.send)
|
||||
{
|
||||
setInterval(function ()
|
||||
{
|
||||
process.send({cmd:"Alive"});
|
||||
}, 1000);
|
||||
process.send({cmd:"online", message:"OK"});
|
||||
global.ToLogClient = function (Str,StrKey,bFinal)
|
||||
{
|
||||
process.send({cmd:"ToLogClient", Str:"" + Str, StrKey:StrKey, bFinal:bFinal});
|
||||
};
|
||||
}
|
||||
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 "FindTX":
|
||||
global.TreeFindTX.SaveValue(msg.TX, msg);
|
||||
break;
|
||||
case "SetSmartEvent":
|
||||
global.TreeFindTX.SaveValue("Smart:" + msg.Smart, 1);
|
||||
break;
|
||||
case "Eval":
|
||||
EvalCode(msg.Code);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -77,32 +37,6 @@ global.SetStatMode = function (Val)
|
||||
global.STAT_MODE = Val;
|
||||
return global.STAT_MODE;
|
||||
};
|
||||
|
||||
function CheckAlive()
|
||||
{
|
||||
if(global.NOALIVE)
|
||||
return ;
|
||||
var Delta = Date.now() - LastAlive;
|
||||
if(Delta > 100 * 1000)
|
||||
{
|
||||
ToLog("TX-PROCESS: ALIVE TIMEOUT Stop and exit: " + Delta);
|
||||
process.exit(0);
|
||||
return ;
|
||||
}
|
||||
};
|
||||
process.on('uncaughtException', function (err)
|
||||
{
|
||||
ToError(err.stack);
|
||||
ToLog(err.stack);
|
||||
TO_ERROR_LOG("TX-PROCESS", 777, err);
|
||||
ToLog("-----------------TX-PROCESS EXIT------------------");
|
||||
process.exit();
|
||||
});
|
||||
process.on('error', function (err)
|
||||
{
|
||||
ToError("TX-PROCESS:\n" + err.stack);
|
||||
ToLog(err.stack);
|
||||
});
|
||||
global.HTTP_PORT_NUMBER = 0;
|
||||
var CServerDB = require("../core/transaction-validator");
|
||||
var KeyPair = crypto.createECDH('secp256k1');
|
||||
@ -395,17 +329,3 @@ function TXWriteAccHash()
|
||||
return DataHash;
|
||||
};
|
||||
global.TXWriteAccHash = TXWriteAccHash;
|
||||
global.EvalCode = function (Code)
|
||||
{
|
||||
var Result;
|
||||
try
|
||||
{
|
||||
var ret = eval(Code);
|
||||
Result = JSON.stringify(ret, "", 4);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
Result = "" + e;
|
||||
}
|
||||
return Result;
|
||||
};
|
||||
|
@ -18,54 +18,16 @@ global.DATA_PATH = GetNormalPathString(global.DATA_PATH);
|
||||
global.CODE_PATH = GetNormalPathString(global.CODE_PATH);
|
||||
require("../core/library");
|
||||
require("../core/geo");
|
||||
require("./child-process");
|
||||
global.READ_ONLY_DB = 1;
|
||||
global.MAX_STAT_PERIOD = 600;
|
||||
var HostNodeList = [];
|
||||
var AllNodeList = [];
|
||||
var NodeBlockChain = [];
|
||||
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":
|
||||
Exit();
|
||||
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 "retcall":
|
||||
var F = GlobalRunMap[msg.id];
|
||||
if(F)
|
||||
{
|
||||
delete GlobalRunMap[msg.id];
|
||||
F(msg.Err, msg.Params);
|
||||
}
|
||||
break;
|
||||
case "Stat":
|
||||
ADD_TO_STAT(msg.Name, msg.Value);
|
||||
break;
|
||||
@ -101,52 +63,21 @@ process.on('message', function (msg)
|
||||
ArrLogClient.push({text:msg.ResultStr, key:msg.TX, final:msg.bFinal, });
|
||||
break;
|
||||
}
|
||||
case "Eval":
|
||||
EvalCode(msg.Code);
|
||||
break;
|
||||
}
|
||||
});
|
||||
var RedirectServer;
|
||||
var HostingServer;
|
||||
|
||||
function Exit()
|
||||
global.OnExit = function ()
|
||||
{
|
||||
ToLogWeb("=Exit1=");
|
||||
if(RedirectServer)
|
||||
RedirectServer.close();
|
||||
if(HostingServer)
|
||||
HostingServer.close();
|
||||
ToLogWeb("=Exit2=");
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
function CheckAlive()
|
||||
{
|
||||
if(global.NOALIVE)
|
||||
return ;
|
||||
var Delta = Date.now() - LastAlive;
|
||||
if(Delta > CHECK_STOP_CHILD_PROCESS)
|
||||
{
|
||||
Exit();
|
||||
return ;
|
||||
}
|
||||
};
|
||||
process.on('uncaughtException', function (err)
|
||||
{
|
||||
ToError(err.stack);
|
||||
ToLog(err.stack);
|
||||
TO_ERROR_LOG("HOSTING", 777, err);
|
||||
ToLog("-----------------HOSTING EXIT------------------", 0);
|
||||
process.exit();
|
||||
});
|
||||
process.on('error', function (err)
|
||||
{
|
||||
ToError("HOSTING:\n" + err.stack);
|
||||
ToLog(err.stack);
|
||||
});
|
||||
if(!global.HTTP_HOSTING_PORT)
|
||||
{
|
||||
ToLogTrace("global.HTTP_HOSTING_PORT=" + global.HTTP_HOSTING_PORT);
|
||||
OnExit();
|
||||
process.exit();
|
||||
}
|
||||
var CServerDB = require("../core/db/block-db");
|
||||
@ -275,24 +206,25 @@ function RunListenServer()
|
||||
TimeToRerun = Math.floor(TimeToRerun * 1.1);
|
||||
if(TimeToRerun > 1000000 * 1000)
|
||||
return ;
|
||||
ToLogClient('Port ' + global.HTTP_HOSTING_PORT + ' in use, retrying...');
|
||||
ToLog('Port ' + global.HTTP_HOSTING_PORT + ' in use, retrying...');
|
||||
if(HostingServer.Server)
|
||||
HostingServer.Server.close();
|
||||
if(!bWasRun)
|
||||
setTimeout(function ()
|
||||
{
|
||||
RunListenServer();
|
||||
if(!bWasRun)
|
||||
RunListenServer();
|
||||
}, TimeToRerun);
|
||||
return ;
|
||||
}
|
||||
ToError("H##6");
|
||||
ToError(err);
|
||||
});
|
||||
ToLogClient("Prepare to run WEB-server on port: " + global.HTTP_HOSTING_PORT);
|
||||
ToLog("Prepare to run WEB-server on port: " + global.HTTP_HOSTING_PORT);
|
||||
HostingServer.listen(global.HTTP_HOSTING_PORT, LISTEN_IP, function ()
|
||||
{
|
||||
if(!bWasRun)
|
||||
ToLogClient("Run WEB-server on " + LISTEN_IP + ":" + global.HTTP_HOSTING_PORT);
|
||||
ToLog("Run WEB-server on " + LISTEN_IP + ":" + global.HTTP_HOSTING_PORT);
|
||||
bWasRun = 1;
|
||||
});
|
||||
};
|
||||
@ -899,41 +831,6 @@ HostingCaller.GetTotalSupply = function (Params)
|
||||
{
|
||||
return "" + global.TOTAL_SUPPLY_TERA;
|
||||
};
|
||||
global.GlobalRunID = 0;
|
||||
global.GlobalRunMap = {};
|
||||
process.RunRPC = function (Name,Params,F)
|
||||
{
|
||||
if(F)
|
||||
{
|
||||
GlobalRunID++;
|
||||
try
|
||||
{
|
||||
process.send({cmd:"call", id:GlobalRunID, Name:Name, Params:Params});
|
||||
GlobalRunMap[GlobalRunID] = F;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
process.send({cmd:"call", id:0, Name:Name, Params:Params});
|
||||
}
|
||||
};
|
||||
global.EvalCode = function (Code)
|
||||
{
|
||||
var Result;
|
||||
try
|
||||
{
|
||||
var ret = eval(Code);
|
||||
Result = JSON.stringify(ret, "", 4);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
Result = "" + e;
|
||||
}
|
||||
return Result;
|
||||
};
|
||||
setInterval(function ()
|
||||
{
|
||||
if(SERVER)
|
||||
|
@ -674,10 +674,6 @@ class AccountApp extends require("./dapp")
|
||||
Account.Adviser = TR.Adviser
|
||||
Account.Value.Smart = TR.Smart
|
||||
this.WriteStateTR(Account, TrNum)
|
||||
if(CompareArr(Account.PubKey, WALLET.PubKeyArr) === 0)
|
||||
{
|
||||
WALLET.OnCreateAccount(Account)
|
||||
}
|
||||
this.ResultTx = Account.Num
|
||||
return true;
|
||||
}
|
||||
|
@ -1099,6 +1099,7 @@ function $Send(ToID,CoinSum,Description)
|
||||
ToID = ParseNum(ToID);
|
||||
if(typeof CoinSum === "number")
|
||||
CoinSum = COIN_FROM_FLOAT(CoinSum);
|
||||
CHECKSUM(CoinSum);
|
||||
if(CoinSum.SumCENT >= 1e9)
|
||||
{
|
||||
throw "ERROR SumCENT>=1e9";
|
||||
@ -1147,6 +1148,7 @@ function $Move(FromID,ToID,CoinSum,Description)
|
||||
{
|
||||
CoinSum = COIN_FROM_FLOAT(CoinSum);
|
||||
}
|
||||
CHECKSUM(CoinSum);
|
||||
if(CoinSum.SumCENT >= 1e9)
|
||||
{
|
||||
throw "ERROR SumCENT>=1e9";
|
||||
|
Loading…
Reference in New Issue
Block a user