Sat Jul 13 09:15:47 CST 2019 Source Update...

This commit is contained in:
MiaoWoo 2019-07-13 09:15:47 +08:00
parent 750a54c15f
commit b415da0a52
21 changed files with 1515 additions and 3682 deletions

View File

@ -1,109 +1 @@
hljs.registerLanguage('html', FLanguage);
function FLanguage(hljs)
{
var XML_IDENT_RE = '[A-Za-z0-9\\._:-]+';
var TAG_INTERNALS = {
endsWithParent: true,
illegal: /</,
relevance: 0,
contains: [
{
className: 'attr',
begin: XML_IDENT_RE,
relevance: 0
},
{
begin: /=\s*/,
relevance: 0,
contains: [
{
className: 'string',
endsParent: true,
variants: [
{begin: /"/, end: /"/},
{begin: /'/, end: /'/},
{begin: /[^\s"'=<>`]+/}
]
}
]
}
]
};
return {
aliases: ['html', 'xhtml', 'rss', 'atom', 'xjb', 'xsd', 'xsl', 'plist'],
case_insensitive: true,
contains: [
{
className: 'meta',
begin: '<!DOCTYPE', end: '>',
relevance: 10,
contains: [{begin: '\\[', end: '\\]'}]
},
hljs.COMMENT(
'<!--',
'-->',
{
relevance: 10
}
),
{
begin: '<\\!\\[CDATA\\[', end: '\\]\\]>',
relevance: 10
},
{
className: 'meta',
begin: /<\?xml/, end: /\?>/, relevance: 10
},
{
begin: /<\?(php)?/, end: /\?>/,
subLanguage: 'php',
contains: [
// We don't want the php closing tag ?> to close the PHP block when
// inside any of the following blocks:
{begin: '/\\*', end: '\\*/', skip: true},
{begin: 'b"', end: '"', skip: true},
{begin: 'b\'', end: '\'', skip: true},
hljs.inherit(hljs.APOS_STRING_MODE, {illegal: null, className: null, contains: null, skip: true}),
hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null, className: null, contains: null, skip: true})
]
},
{
className: 'tag',
/*
The lookahead pattern (?=...) ensures that 'begin' only matches
'<style' as a single word, followed by a whitespace or an
ending braket. The '$' is needed for the lexeme to be recognized
by hljs.subMode() that tests lexemes outside the stream.
*/
begin: '<style(?=\\s|>|$)', end: '>',
keywords: {name: 'style'},
contains: [TAG_INTERNALS],
starts: {
end: '</style>', returnEnd: true,
subLanguage: ['css', 'xml']
}
},
{
className: 'tag',
// See the comment in the <style tag about the lookahead pattern
begin: '<script(?=\\s|>|$)', end: '>',
keywords: {name: 'script'},
contains: [TAG_INTERNALS],
starts: {
end: '\<\/script\>', returnEnd: true,
subLanguage: ['actionscript', 'javascript', 'handlebars', 'xml']
}
},
{
className: 'tag',
begin: '</?', end: '/?>',
contains: [
{
className: 'name', begin: /[^\/><\s]+/, relevance: 0
},
TAG_INTERNALS
]
}
]
};
};
function FLanguage(e){var n={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:"[A-Za-z0-9\\._:-]+",relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/},{begin:/'/,end:/'/},{begin:/[^\s"'=<>`]+/}]}]}]};return{aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist"],case_insensitive:!0,contains:[{className:"meta",begin:"<!DOCTYPE",end:">",relevance:10,contains:[{begin:"\\[",end:"\\]"}]},e.COMMENT("\x3c!--","--\x3e",{relevance:10}),{begin:"<\\!\\[CDATA\\[",end:"\\]\\]>",relevance:10},{className:"meta",begin:/<\?xml/,end:/\?>/,relevance:10},{begin:/<\?(php)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]},{className:"tag",begin:"<style(?=\\s|>|$)",end:">",keywords:{name:"style"},contains:[n],starts:{end:"</style>",returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:"<script(?=\\s|>|$)",end:">",keywords:{name:"script"},contains:[n],starts:{end:"<\/script>",returnEnd:!0,subLanguage:["actionscript","javascript","handlebars","xml"]}},{className:"tag",begin:"</?",end:"/?>",contains:[{className:"name",begin:/[^\/><\s]+/,relevance:0},n]}]}}hljs.registerLanguage("html",FLanguage);

View File

@ -1,174 +1 @@
hljs.registerLanguage('javascript', FLanguage);
hljs.registerLanguage('js', FLanguage);
function FLanguage(hljs)
{
var IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
var KEYWORDS = {
keyword:
'in of if for while finally var new function do return void else break catch ' +
'instanceof with throw case default try this switch continue typeof delete ' +
'let yield const export super debugger as async await static ' +
// ECMAScript 6 modules import
'import from as'
,
literal:
'true false null undefined NaN Infinity',
built_in:
'eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent ' +
'encodeURI encodeURIComponent escape unescape Object Function Boolean Error ' +
'EvalError InternalError RangeError ReferenceError StopIteration SyntaxError ' +
'TypeError URIError Number Math Date String RegExp Array Float32Array ' +
'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array ' +
'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require ' +
'module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect ' +
'Promise'
};
var EXPRESSIONS;
var NUMBER = {
className: 'number',
variants: [
{ begin: '\\b(0[bB][01]+)' },
{ begin: '\\b(0[oO][0-7]+)' },
{ begin: hljs.C_NUMBER_RE }
],
relevance: 0
};
var SUBST = {
className: 'subst',
begin: '\\$\\{', end: '\\}',
keywords: KEYWORDS,
contains: [] // defined later
};
var TEMPLATE_STRING = {
className: 'string',
begin: '`', end: '`',
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
]
};
SUBST.contains = [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
TEMPLATE_STRING,
NUMBER,
hljs.REGEXP_MODE
]
var PARAMS_CONTAINS = SUBST.contains.concat([
hljs.C_BLOCK_COMMENT_MODE,
hljs.C_LINE_COMMENT_MODE
]);
return {
aliases: ['js', 'jsx'],
keywords: KEYWORDS,
contains: [
{
className: 'meta',
relevance: 10,
begin: /^\s*['"]use (strict|asm)['"]/
},
{
className: 'meta',
begin: /^#!/, end: /$/
},
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
TEMPLATE_STRING,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
NUMBER,
{ // object attr container
begin: /[{,]\s*/, relevance: 0,
contains: [
{
begin: IDENT_RE + '\\s*:', returnBegin: true,
relevance: 0,
contains: [{className: 'attr', begin: IDENT_RE, relevance: 0}]
}
]
},
{ // "value" container
begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
keywords: 'return throw case',
contains: [
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
hljs.REGEXP_MODE,
{
className: 'function',
begin: '(\\(.*?\\)|' + IDENT_RE + ')\\s*=>', returnBegin: true,
end: '\\s*=>',
contains: [
{
className: 'params',
variants: [
{
begin: IDENT_RE
},
{
begin: /\(\s*\)/,
},
{
begin: /\(/, end: /\)/,
excludeBegin: true, excludeEnd: true,
keywords: KEYWORDS,
contains: PARAMS_CONTAINS
}
]
}
]
},
{ // E4X / JSX
begin: /</, end: /(\/\w+|\w+\/)>/,
subLanguage: 'xml',
contains: [
{begin: /<\w+\s*\/>/, skip: true},
{
begin: /<\w+/, end: /(\/\w+|\w+\/)>/, skip: true,
contains: [
{begin: /<\w+\s*\/>/, skip: true},
'self'
]
}
]
}
],
relevance: 0
},
{
className: 'function',
beginKeywords: 'function', end: /\{/, excludeEnd: true,
contains: [
hljs.inherit(hljs.TITLE_MODE, {begin: IDENT_RE}),
{
className: 'params',
begin: /\(/, end: /\)/,
excludeBegin: true,
excludeEnd: true,
contains: PARAMS_CONTAINS
}
],
illegal: /\[|%/
},
{
begin: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
},
hljs.METHOD_GUARD,
{ // ES6 class
className: 'class',
beginKeywords: 'class', end: /[{;=]/, excludeEnd: true,
illegal: /[:"\[\]]/,
contains: [
{beginKeywords: 'extends'},
hljs.UNDERSCORE_TITLE_MODE
]
},
{
beginKeywords: 'constructor', end: /\{/, excludeEnd: true
}
],
illegal: /#(?!!)/
};
};
function FLanguage(e){var n="[A-Za-z$_][0-9A-Za-z$_]*",a={keyword:"in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await static import from as",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"},r={className:"number",variants:[{begin:"\\b(0[bB][01]+)"},{begin:"\\b(0[oO][0-7]+)"},{begin:e.C_NUMBER_RE}],relevance:0},s={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},i={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,s]};s.contains=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,i,r,e.REGEXP_MODE];var t=s.contains.concat([e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]);return{aliases:["js","jsx"],keywords:a,contains:[{className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},{className:"meta",begin:/^#!/,end:/$/},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,i,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,r,{begin:/[{,]\s*/,relevance:0,contains:[{begin:n+"\\s*:",returnBegin:!0,relevance:0,contains:[{className:"attr",begin:n,relevance:0}]}]},{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.REGEXP_MODE,{className:"function",begin:"(\\(.*?\\)|"+n+")\\s*=>",returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:n},{begin:/\(\s*\)/},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:t}]}]},{begin:/</,end:/(\/\w+|\w+\/)>/,subLanguage:"xml",contains:[{begin:/<\w+\s*\/>/,skip:!0},{begin:/<\w+/,end:/(\/\w+|\w+\/)>/,skip:!0,contains:[{begin:/<\w+\s*\/>/,skip:!0},"self"]}]}],relevance:0},{className:"function",beginKeywords:"function",end:/\{/,excludeEnd:!0,contains:[e.inherit(e.TITLE_MODE,{begin:n}),{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,contains:t}],illegal:/\[|%/},{begin:/\$[(.]/},e.METHOD_GUARD,{className:"class",beginKeywords:"class",end:/[{;=]/,excludeEnd:!0,illegal:/[:"\[\]]/,contains:[{beginKeywords:"extends"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"constructor",end:/\{/,excludeEnd:!0}],illegal:/#(?!!)/}}hljs.registerLanguage("javascript",FLanguage),hljs.registerLanguage("js",FLanguage);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1163,3 +1163,21 @@ LangMap["简体中文"] = {"TERA WALLET":"TERA 钱包", "Generate key":"生成
"Pay to ID:":"收款ID:", "Account":"账号", "Owner":"拥有者", "Block num":"区块编号", "Private key (secret)":"私钥 (机密)", "Load key":"载入私钥",
"Create your first account and start using TERA":"创建你的第一个账号开启TERA之旅", "0 Accounts":"0 账号", "OWNER: {Item.Owner}":"拥有者: {Item.Owner}",
"More info":"详情", "Public key":"公钥"};
LangMap["한글"] = {"TERA WALLET":"TERA 지갑", "Generate key":"개인 키 생성", "OK":"OK", "Cancel":"취소", "Edit":"편집", "Save key":"개인 키 저장",
"+ CREATE A NEW ACCOUNT":"+ 새 계정 만들기", "Create account":"계정 만들기", "Send":"발송", "CONFIRM":"확인", "Accounts":"계정", "Account(s)":"계정",
"Blocks & Tx":"블록 & 교역 번호", "Counters":"컨디션 통계", "Open DApp":" DApp을 열기", "Back":"되돌아가기", "Delete":"삭제", "Save to book":"저장",
"Choose":"선택", "RECONNECT":"다시 연결", "DApps":"DApps", "ID":"ID", "Amount":"잔금", "Cur":"화폐", "Name":"이름", "PubKey":"공공키", "Operation":"조작 횟수",
"Smart":"DApp", "Block Num":"블록 번호", "Num":"번호", "Date":"날짜", "Data Hash":"데이터 하희", "PowHash":"Pow하희", "Block Hash":"블록 하희",
"Bytes":"바이트", "Pow":"Pow", "Miner":"바이트", "(secret)":"(비밀)", "Show":"쇼", "TERA":"TERA", "Blockchain height:":"블록높이:", "Current create:":"최근 블록:",
"Protocol ver:":"프로토콜 버전:", "ID: {Item.Num}":"ID: {Item.Num}", "Token generate":"생성대폐", "ACCOUNTS":"계정", "SEND":"발송", "DAPPS":"DAPPS",
"EXPLORER":"브라우저", "ATTENTION: Before using the wallet, save the private key.":"주의: 지갑을 사용하기 전에 반드시 개인 키를 저장해야 한다.", "Web-site":"사이트",
"Bitcointalk":"비트 화폐포럼", "Twitter":"트위터", "Telegram":"전보", "Discord":"Discord", "QQchat":"QQ ", "Buy/sell/mine TERA":"TERA거래 /채광",
"+ CREATE NEW":"+신건", "Confirm Transaction":"거래 확인", "CREATE DAPPS":" DAPPS만들기", "Set pass":"비밀번호 설정", "Unlock":"잠금 풀기", "Entrance to sub-wallet":"부속 지갑 들어가기",
"Public name":"이름", "Currency":"화폐", "Pay to:":"지불:", "Amount:":"수량:", "Description:":"묘사:", "Welcome to TERA Wallet":"TERA 지갑을 환영합니다",
"Edit your wallet":"지갑 편집", "Key settings":"개인 키 설정", "KEY SETTINGS":"개인 키 설정", "Create an account":"계정 만들기", "Sending coins":"동전 보내기",
"Decentralized applications (dApps)":"분산식 응용(DApps)", "Secure your wallet":"지갑 비밀번호 설정", "Wallet is secured":"지갑 비밀번호가 설정되었습니다. ",
"Total":"총계", "Item.Name":"Item.Name", "You have no accounts yet":"당신 아직 계정이 없다", "Wait 10-15 sec":" 10 -15초 기다리기", "Creating your account":"계정 만들기",
"From:":"부터:", "\n Item.Description\n ":"\n Item.Description\n ", "Set a password for protect entry":"접근 비밀번호 설정", "Enter password to unlock wallet":"비밀번호 잠금 풀기",
"From ID:":" ID부터:", "Pay to ID:":"ID 에게 지불:", "Account":"계정", "Owner":"소유자", "Block num":"블록 번호", "Private key (secret)":"개인 키",
"Load key":"개인 키 불러오기", "Create your first account and start using TERA":"첫 번째 계정 만들기, TERA 의 여정을 열고", "0 Accounts":"0계정",
"OWNER: {Item.Owner}":"소유자: {Item.Owner}", "More info":"자세", "Public key":"공공키", };

File diff suppressed because one or more lines are too long

View File

@ -91,7 +91,7 @@ function CheckNameAccTo()
function SetNameAccTo()
{
var Str = "";
var ToID = ($("idTo").value);
var ToID = $("idTo").value.trim();
var Item = MapAccounts[ToID];
var StrTo = GetAccountText(Item, ToID, 1);
var element = $("idNameTo");

View File

@ -528,7 +528,8 @@
function InstallApp()
{
CreateNewAccount(0);
CreateNewAccount(BASE_ACCOUNT.Currency);
if(idInstallApp)
{

View File

@ -1126,6 +1126,7 @@
if(CurBlockNum<ServerBlockNumDB+8)
CurBlockNum=ServerBlockNumDB;
var WasArr=0;
var Arr=[];
for(var i=ArrInfo.length-1;i>=0;i--)
@ -1144,6 +1145,7 @@
{
if(!Item.PowerArr[n])//есть нули
{
//ToLog("n="+n+" Item.BlockNum1="+Item.BlockNum1);
MustUpdate=1;
break;
}
@ -1153,7 +1155,6 @@
var DeltaTime=Math.abs(Item.TimeBlockNum-TimeBlockNum);
if(DeltaTime>Item.Delta/20)
{
//ToLog("i="+i+" DeltaTime="+DeltaTime+" > "+(Item.Delta/20))
MustUpdate=1;
}
}

View File

@ -8,9 +8,37 @@
* Telegram: https://t.me/terafoundation
*/
global.PERIOD_GET_BLOCK = 300, global.COUNT_HISTORY_BLOCKS_FOR_LOAD = 600, global.COUNT_BLOCKS_FOR_CHECK_POW = 50, global.MAX_DELTA_COUNT_SUM_FOR_LOAD = 10,
global.MAX_COUNT_CHAIN_LOAD = 120, global.PACKET_ALIVE_PERIOD = 4 * CONSENSUS_PERIOD_TIME, global.PACKET_ALIVE_PERIOD_NEXT_NODE = PACKET_ALIVE_PERIOD / 2,
global.MAX_BLOCK_SEND = 8, global.COUNT_TASK_FOR_NODE = 10, global.FORMAT_BLOCK_TRANSFER = "{ BlockNum:uint, TreeHash:hash, arrContent:[tr], }",
global.WRK_BLOCK_TRANSFER = {}, global.MAX_ACCOUNTS_TRANSFER = 1024, global.MAX_SMARTS_TRANSFER = 10, global.TEST_NETWORK && (global.MAX_ACCOUNTS_TRANSFER = 128,
global.MAX_SMARTS_TRANSFER = 10), global.FORMAT_REST_TRANSFER = "{ Result:uint, Version:uint, Arr:[arr200], ProofHash:hash, ProofArrL:<hash>, ProofArrR:<hash>, }",
global.FORMAT_SMART_TRANSFER = "{ Result:uint, Arr:[tr], }";
global.PERIOD_GET_BLOCK = 300;
global.COUNT_HISTORY_BLOCKS_FOR_LOAD = 600;
global.COUNT_BLOCKS_FOR_CHECK_POW = 50;
global.MAX_DELTA_COUNT_SUM_FOR_LOAD = 10;
global.MAX_COUNT_CHAIN_LOAD = 120;
global.PACKET_ALIVE_PERIOD = 4 * CONSENSUS_PERIOD_TIME;
global.PACKET_ALIVE_PERIOD_NEXT_NODE = PACKET_ALIVE_PERIOD / 2;
global.MAX_BLOCK_SEND = 8;
global.COUNT_TASK_FOR_NODE = 10;
global.FORMAT_BLOCK_TRANSFER = "{\
BlockNum:uint,\
TreeHash:hash,\
arrContent:[tr],\
}";
global.WRK_BLOCK_TRANSFER = {};
global.MAX_ACCOUNTS_TRANSFER = 1024;
global.MAX_SMARTS_TRANSFER = 10;
if(global.TEST_NETWORK)
{
global.MAX_ACCOUNTS_TRANSFER = 128;
global.MAX_SMARTS_TRANSFER = 10;
}
global.FORMAT_REST_TRANSFER = "{\
Result:uint,\
Version:uint,\
Arr:[arr200],\
ProofHash:hash,\
ProofArrL:<hash>,\
ProofArrR:<hash>,\
}";
global.FORMAT_SMART_TRANSFER = "{\
Result:uint,\
Arr:[tr],\
}";

View File

@ -133,7 +133,7 @@ module.exports = class CBlock extends require("./rest-loader.js")
var PrevHash = CalcHashFromArray(arr, true);
return PrevHash;
}
StartSyncBlockchain(Node, bSilent, bCheckPoint)
StartSyncBlockchain(Node, bSilent, bCheckPoint, PrevStartedBlockNum)
{
this.FREE_ALL_MEM_CHAINS()
if(global.NO_HISTORY_MODE)
@ -149,9 +149,24 @@ module.exports = class CBlock extends require("./rest-loader.js")
this.RelayMode = false
if(!bSilent)
this.RelayMode = true
var StartBlockNum;
if(PrevStartedBlockNum)
{
var DeltaNum = Math.floor(1.2 * (this.BlockNumDB - PrevStartedBlockNum));
if(DeltaNum < 1000)
DeltaNum = 1000
StartBlockNum = this.BlockNumDB - DeltaNum
if(StartBlockNum <= 0)
StartBlockNum = 15
ToLog("Current DeltaNum=" + DeltaNum + " StartBlockNum=" + StartBlockNum, 2)
}
else
{
StartBlockNum = this.BlockNumDB
}
this.LoadHistoryMode = true
this.LoadHistoryMessage = !bSilent
this.LoadHistoryContext = {PrevBlockNum: - 1, Node:Node, BlockNum:this.BlockNumDB, MapSend:{}, Foward:1, Pause:0, DeltaBlockNum:10,
this.LoadHistoryContext = {PrevBlockNum: - 1, Node:Node, BlockNum:StartBlockNum, MapSend:{}, Foward:1, Pause:0, DeltaBlockNum:10,
StartTimeHistory:Date.now(), MaxTimeOut:30 * 1000}
if(!bSilent && !bCheckPoint && REST_START_COUNT)
{
@ -184,7 +199,7 @@ module.exports = class CBlock extends require("./rest-loader.js")
if(DeltaTime > Context.MaxTimeOut)
{
ToLog("DETECT TIMEOUT LOAD")
this.StartSyncBlockchain()
this.StartSyncBlockchain(undefined, undefined, undefined, Context.BlockNum)
return ;
}
}
@ -543,6 +558,7 @@ module.exports = class CBlock extends require("./rest-loader.js")
{
if(!Context.WasLoadNum)
{
ToLog("Not found: " + Context.BlockNum + " from node:" + NodeName(Info.Node), 2)
Context.BlockNum = Math.floor(Context.BlockNum - Context.DeltaBlockNum)
Context.DeltaBlockNum = Context.DeltaBlockNum * 1.2
if(Context.BlockNum < BLOCK_PROCESSING_LENGTH2)

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
* Telegram: https://t.me/terafoundation
*/
global.UPDATE_CODE_VERSION_NUM = 1131;
global.UPDATE_CODE_VERSION_NUM = 1133;
global.MIN_CODE_VERSION_NUM = 1114;
global.MINING_VERSION_NUM = 0;
global.InitParamsArg = InitParamsArg;
@ -18,8 +18,8 @@ global.CONST_NAME_ARR = ["AUTO_CORRECT_TIME", "DELTA_CURRENT_TIME", "COMMON_KEY"
"ALL_LOG_TO_CLIENT", "LOG_LEVEL", "USE_MINING", "MINING_START_TIME", "MINING_PERIOD_TIME", "POW_MAX_PERCENT", "COUNT_MINING_CPU",
"SIZE_MINING_MEMORY", "POW_RUN_COUNT", "USE_AUTO_UPDATE", "RESTART_PERIOD_SEC", "MAX_GRAY_CONNECTIONS_TO_SERVER", "TRANSACTION_PROOF_COUNT",
"UPDATE_NUM_COMPLETE", "LIMIT_SEND_TRAFIC", "WATCHDOG_DEV", "ADDRLIST_MODE", "CheckPointDelta", "MIN_VER_STAT", "DEBUG_WALLET",
"HTTP_HOSTING_PORT", "HTTPS_HOSTING_DOMAIN", "HTTP_MAX_COUNT_ROWS", "HTTP_ADMIN_PASSORD", "WATCHDOG_BADACCOUNT", "RESYNC_CONDITION",
"MAX_CONNECTIONS_COUNT", "TRUST_PROCESS_COUNT", "REST_START_COUNT", "LOAD_TO_BEGIN", ];
"HTTP_HOSTING_PORT", "HTTPS_HOSTING_DOMAIN", "HTTP_MAX_COUNT_ROWS", "HTTP_ADMIN_PASSWORD", "HTTP_START_PAGE", "WATCHDOG_BADACCOUNT",
"RESYNC_CONDITION", "MAX_CONNECTIONS_COUNT", "TRUST_PROCESS_COUNT", "REST_START_COUNT", "LOAD_TO_BEGIN", ];
global.MAX_LENGTH_SENDER_MAP = 3000;
global.DELTA_START_SENDER_MAP = 24;
global.NODES_DELTA_CALC_HOUR = 4;
@ -73,7 +73,8 @@ global.SIZE_MINING_MEMORY = 0;
global.HTTP_HOSTING_PORT = 0;
global.HTTPS_HOSTING_DOMAIN = "";
global.HTTP_MAX_COUNT_ROWS = 20;
global.HTTP_ADMIN_PASSORD = "";
global.HTTP_ADMIN_PASSWORD = "";
global.HTTP_START_PAGE = "";
require("./startlib.js");
global.MIN_POWER_POW_HANDSHAKE = 12;
global.USE_HINT = 0;

View File

@ -8,80 +8,127 @@
* Telegram: https://t.me/terafoundation
*/
var BufIP, fs = require("fs");
var fs = require('fs');
require("./library.js");
var MapNames = {}, FileIp = "./SITE/DB/iplocation.db", FileNames = "./SITE/DB/locationnames.csv", Format = "{Value:uint32,Length:uint32, id:uint32, latitude:uint32, longitude:uint32}",
FormatStruct = {};
var BufIP;
var MapNames = {};
var FileIp = "./SITE/DB/iplocation.db";
var FileNames = "./SITE/DB/locationnames.csv";
var Format = "{Value:uint32,Length:uint32, id:uint32, latitude:uint32, longitude:uint32}";
var FormatStruct = {};
function SetGeoLocation(e)
function SetGeoLocation(Item)
{
if(!e.ip || !BufIP || !BufIP.length)
return !1;
var t = IPToUint(e.ip), i = FindItem(BufIP, 20, t);
return i && (e.latitude = i.latitude, e.longitude = i.longitude, e.name = MapNames[i.id]), e.Geo = 1, !0;
if(!Item.ip || !BufIP || !BufIP.length)
return false;
var Num = IPToUint(Item.ip);
var Location = FindItem(BufIP, 20, Num);
if(Location)
{
Item.latitude = Location.latitude;
Item.longitude = Location.longitude;
Item.name = MapNames[Location.id];
}
Item.Geo = 1;
return true;
};
function ReadItem(e,t)
function ReadItem(Num,Size)
{
return BufIP.len = e * t, BufLib.Read(BufIP, Format, void 0, FormatStruct);
BufIP.len = Num * Size;
var Data = BufLib.Read(BufIP, Format, undefined, FormatStruct);
return Data;
};
function FindItem(e,t,i)
function FindItem(Buf,Size,FindValue)
{
var n, r = Math.trunc(e.length / t), a = (ReadItem(0, t), ReadItem(r, t), 0), u = r, o = Math.trunc(i * r / 4294967296);
r <= o && (o = r - 1), o < a && (o = a);
for(var f = 40; 0 < f; )
var Item;
var MaxNum = Math.trunc(Buf.length / Size);
var MinItem = ReadItem(0, Size);
var MaxItem = ReadItem(MaxNum, Size);
var StartNum = 0;
var EndNum = MaxNum;
var CurNum = Math.trunc(FindValue * MaxNum / 0x100000000);
if(CurNum >= MaxNum)
CurNum = MaxNum - 1;
if(CurNum < StartNum)
CurNum = StartNum;
var CountIt = 40;
while(CountIt > 0)
{
if(f--, !(n = ReadItem(o, t)))
return void ToLog("GEO FindItem - Error read num: " + o);
if(n.Value > i)
CountIt--;
Item = ReadItem(CurNum, Size);
if(Item)
{
if(u = o - 1, 0 === (l = o - a))
return ;
o -= l = Math.trunc((1 + l) / 2);
if(Item.Value > FindValue)
{
EndNum = CurNum - 1;
var Delta = CurNum - StartNum;
if(Delta === 0)
return undefined;
Delta = Math.trunc((1 + Delta) / 2);
CurNum = CurNum - Delta;
}
else
if(n.Value < i)
if(Item.Value < FindValue)
{
if(n.Value + n.Length >= i)
return n;
var l;
if(a = o + 1, 0 === (l = u - o))
return ;
o += l = Math.trunc((1 + l) / 2);
if(Item.Value + Item.Length >= FindValue)
return Item;
StartNum = CurNum + 1;
var Delta = EndNum - CurNum;
if(Delta === 0)
return undefined;
Delta = Math.trunc((1 + Delta) / 2);
CurNum = CurNum + Delta;
}
else
if(n.Value === i)
return n;
if(Item.Value === FindValue)
return Item;
}
else
{
ToLog("GEO FindItem - Error read num: " + CurNum);
return undefined;
}
}
return undefined;
};
function Init()
{
if(fs.existsSync(FileIp) && fs.existsSync(FileNames))
{
if(!fs.existsSync(FileIp))
return ;
if(!fs.existsSync(FileNames))
return ;
BufIP = fs.readFileSync(FileIp);
for(var e = fs.readFileSync(FileNames), t = 0; ; )
var Buf = fs.readFileSync(FileNames);
var index2 = 0;
var Count = 0;
while(true)
{
var i = e.indexOf("\n", t);
if(i < 0)
var index = Buf.indexOf("\n", index2);
if(index < 0)
break;
var n = e.toString("utf-8", t, i - 1);
t = i + 1;
var r = n.split(","), a = parseInt(r[0]);
if(a)
{
0;
var u = r[10];
u = (u = u || r[7]) || r[5], MapNames[a] = u;
}
}
var Str = Buf.toString('utf-8', index2, index - 1);
index2 = index + 1;
var Arr = Str.split(',');
var Num = parseInt(Arr[0]);
if(!Num)
continue;
Count++;
var Name = Arr[10];
if(!Name)
Name = Arr[7];
if(!Name)
Name = Arr[5];
MapNames[Num] = Name;
}
};
function IPToUint(e)
function IPToUint(IPv4)
{
var t = e.split(".");
return 256 * (256 * (256 * + t[0] + + t[1]) + + t[2]) + + t[3];
var d = IPv4.split('.');
return (((((( + d[0]) * 256) + ( + d[1])) * 256) + ( + d[2])) * 256) + ( + d[3]);
};
global.SetGeoLocation = SetGeoLocation, Init();
global.SetGeoLocation = SetGeoLocation;
Init();

View File

@ -1951,6 +1951,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)
{
@ -1966,7 +1969,7 @@ HTTPCaller.GetHashRate = function (ArrParams)
var CountSum = 0;
for(var d = 0; d < CountAvg; d++)
{
var Block = SERVER.ReadBlockHeaderDB(Num + d);
var Block = SERVER.ReadBlockHeaderDB(Num + d * StepDeltaAvg);
if(Block)
{
CountSum++;

View File

@ -9,259 +9,492 @@
*/
require("./constant.js");
var fs = require("fs");
var fs = require('fs');
require("./log-strict.js");
var file_name_info = GetDataPath("info.log"), file_name_infoPrev = GetDataPath("info-prev.log");
var file_name_info = GetDataPath("info.log");
var file_name_infoPrev = GetDataPath("info-prev.log");
CheckSizeLogFile(file_name_info, file_name_infoPrev);
var file_name_log = GetDataPath("log.log"), file_name_logPrev = GetDataPath("log-prev.log");
var file_name_log = GetDataPath("log.log");
var file_name_logPrev = GetDataPath("log-prev.log");
CheckSizeLogFile(file_name_log, file_name_logPrev);
var file_name_log_web = GetDataPath("web.log"), file_name_log_webPrev = GetDataPath("web-prev.log");
var file_name_log_web = GetDataPath("web.log");
var file_name_log_webPrev = GetDataPath("web-prev.log");
CheckSizeLogFile(file_name_log_web, file_name_log_webPrev);
var file_name_error = GetDataPath("err.log"), file_name_errorPrev = GetDataPath("err-prev.log");
var file_name_error = GetDataPath("err.log");
var file_name_errorPrev = GetDataPath("err-prev.log");
CheckSizeLogFile(file_name_error, file_name_errorPrev);
var StartStatTime, file_name_error_tx = GetDataPath("err-tx.log"), file_name_error_txPrev = GetDataPath("err-tx-prev.log");
function ToLogFile(e,t,r)
var file_name_error_tx = GetDataPath("err-tx.log");
var file_name_error_txPrev = GetDataPath("err-tx-prev.log");
CheckSizeLogFile(file_name_error_tx, file_name_error_txPrev);
global.ToLog = function (Str,Level)
{
t instanceof Error && (t = t.message + "\n" + t.stack), global.START_SERVER || (t = global.PROCESS_NAME + ": " + t), "MAIN" !== global.PROCESS_NAME && process.send ? process.send({cmd:"log",
message:t}) : (console.log(START_PORT_NUMBER + ": " + GetStrOnlyTime() + ": " + t), r || SaveToLogFileSync(e, t));
if(Level === undefined)
Level = 1;
if(Level && Level > global.LOG_LEVEL)
return ;
if(global.ALL_LOG_TO_CLIENT)
ToLogClient(Str, undefined, undefined);
else
ToLogFile(file_name_log, Str);
};
function ToLogClient(e,t,r)
global.WEB_LOG = 0;
global.ToLogWeb = function (Str)
{
e && (ToLogFile(file_name_log, e), t = t || "", ArrLogClient.push({text:GetStrOnlyTime() + " " + e, key:t, final:r}), 13 < ArrLogClient.length && ArrLogClient.shift());
};
CheckSizeLogFile(file_name_error_tx, file_name_error_txPrev), global.ToLog = function (e,t)
if(global.WEB_LOG)
{
void 0 === t && (t = 1), t && t > global.LOG_LEVEL || (global.ALL_LOG_TO_CLIENT ? ToLogClient(e, void 0, void 0) : ToLogFile(file_name_log,
e));
}, global.WEB_LOG = 0, global.ToLogWeb = function (e)
{
global.WEB_LOG && SaveToLogFileSync(file_name_log_web, e);
}, global.SmallAddr = function (e)
{
return e.substr(0, 5);
}, global.ToErrorTrace = function (e)
{
ToError(e + ":" + (new Error).stack);
}, global.ToLogTrace = function (e)
{
ToErrorTrace(e);
}, global.ToInfo = function (e)
{
ToLogFile(file_name_info, e, 1);
}, global.ToError = function (e)
{
ToLogFile(file_name_error, e);
}, global.ToErrorTx = function (e)
{
SaveToLogFileSync(file_name_error_tx, e), ToLog(e);
}, global.ArrLogClient = [], global.ToLogClient = ToLogClient, global.ToLogClient0 = ToLogClient;
var CONTEXT_STATS = {Total:{}, Interval:[]}, CONTEXT_ERRORS = {Total:{}, Interval:[]}, CurStatIndex = 0;
function GetCurrentStatIndex()
{
var e = 2 * MAX_STAT_PERIOD + 2;
return CurStatIndex % e;
};
function ResizeArrMax(e)
{
for(var t = [], r = Math.trunc(e.length / 2), o = 0; o < r; o++)
t[o] = Math.max(e[2 * o], e[2 * o + 1]);
return t;
};
function ResizeArrAvg(e)
{
for(var t = [], r = Math.trunc(e.length / 2), o = 0; o < r; o++)
t[o] = (e[2 * o] + e[2 * o + 1]) / 2;
return t;
};
function ResizeArr(e)
{
for(var t = [], r = Math.trunc(e.length / 2), o = 0; o < r; o++)
t[o] = e[2 * o];
return t;
};
function GetDiagramData(e,t)
{
var r, o = 2 * MAX_STAT_PERIOD + 2;
r = "MAX:" === t.substr(0, 4);
for(var n, a = MAX_STAT_PERIOD, l = (GetCurrentStatIndex() - a + o) % o, i = (e.Total, []), T = void 0, g = l; g < l + a; g++)
{
var S = g % o;
if(n = e.Interval[S])
{
var _ = n[t];
void 0 !== _ ? r ? i.push(_) : (void 0 !== T ? i.push(_ - T) : i.push(_), T = _) : i.push(0);
SaveToLogFileSync(file_name_log_web, Str);
}
};
global.SmallAddr = function (Str)
{
return Str.substr(0, 5);
};
global.ToErrorTrace = function (Str)
{
ToError("" + Str + ":" + new Error().stack);
};
global.ToLogTrace = function (Str)
{
ToErrorTrace(Str);
};
global.ToInfo = function (Str)
{
ToLogFile(file_name_info, Str, 1);
};
global.ToError = function (Str)
{
ToLogFile(file_name_error, Str);
};
global.ToErrorTx = function (Str)
{
SaveToLogFileSync(file_name_error_tx, Str);
ToLog(Str);
};
function ToLogFile(file_name,Str,bNoFile)
{
if(Str instanceof Error)
{
Str = Str.message + "\n" + Str.stack;
}
return i;
};
function CalcInterval(e,t,r)
if(!global.START_SERVER)
Str = global.PROCESS_NAME + ": " + Str;
if(global.PROCESS_NAME !== "MAIN" && process.send)
{
for(var o, n = 2 * MAX_STAT_PERIOD + 2, a = {}, l = (t - r + n) % n, i = e.Total, T = l; T < l + r; T++)
{
var g = T % n;
if(o = e.Interval[g])
break;
process.send({cmd:"log", message:Str});
return ;
}
if(o)
for(var S in i)
"MAX:" === S.substr(0, 4) ? a[S] = 0 : void 0 === o[S] ? a[S] = i[S] : a[S] = i[S] - o[S];
return a;
};
function AddToStatContext(e,t,r)
{
void 0 === r && (r = 1);
var o = e.Total[t];
o = o || 0, "MAX:" === t.substr(0, 4) ? o = Math.max(o, r) : o += r, e.Total[t] = o, StartStatTime = StartStatTime || GetCurrentTime(0);
};
function CopyStatInterval(e,t)
{
var r = e.Interval[t];
r || (r = {}, e.Interval[t] = r);
var o = e.Total;
for(var n in o)
r[n] = o[n], "MAX:" === n.substr(0, 4) && (o[n] = 0);
};
function SaveToLogFileAsync(e,o)
{
fs.open(e, "a", void 0, function (e,r)
{
if(e)
console.log("Ошибка открытия лог-файла ошибок");
else
{
var t = GetStrTime() + " : " + o + "\r\n";
fs.write(r, t, null, "utf8", function (e,t)
{
e ? console.log("Ошибка записи в лог-файл ошибок!") : fs.close(r, function (e)
{
e && console.log(e);
});
});
console.log("" + START_PORT_NUMBER + ": " + GetStrOnlyTime() + ": " + Str);
}
});
if(bNoFile)
return ;
SaveToLogFileSync(file_name, Str);
};
global.ArrLogClient = [];
function SaveToLogFileSync(e,t)
function ToLogClient(Str,StrKey,bFinal)
{
try
{
var r = GetStrTime() + " : " + t + "\r\n", o = fs.openSync(e, "a");
fs.writeSync(o, r, null, "utf8"), fs.closeSync(o);
}
catch(e)
{
console.log(e.message);
}
if(!Str)
return ;
ToLogFile(file_name_log, Str);
if(!StrKey)
StrKey = "";
ArrLogClient.push({text:GetStrOnlyTime() + " " + Str, key:StrKey, final:bFinal, });
if(ArrLogClient.length > 13)
ArrLogClient.shift();
};
global.ToLogClient = ToLogClient;
global.ToLogClient0 = ToLogClient;
var StartStatTime;
var CONTEXT_STATS = {Total:{}, Interval:[]};
var CONTEXT_ERRORS = {Total:{}, Interval:[]};
var CurStatIndex = 0;
global.PrepareStatEverySecond = function ()
{
CurStatIndex++;
var e = GetCurrentStatIndex();
CopyStatInterval(CONTEXT_STATS, e), CopyStatInterval(CONTEXT_ERRORS, e);
}, global.TO_ERROR_LOG = function (e,t,r,o,n,a)
var index = GetCurrentStatIndex();
CopyStatInterval(CONTEXT_STATS, index);
CopyStatInterval(CONTEXT_ERRORS, index);
};
global.TO_ERROR_LOG = function (Module,ErrNum,Str,type,data1,data2)
{
r instanceof Error && (r = r.message + "\n"), "rinfo" === o ? r += " from: " + n.address + ":" + n.port : "node" === o && (r += " from: " + n.ip + ":" + n.port);
var l = e + ":" + t;
ToError(" ==ERROR== " + l + " " + r), AddToStatContext(CONTEXT_ERRORS, l), ADD_TO_STAT("ERRORS");
}, global.HASH_RATE = 0, global.ADD_HASH_RATE = function (e)
if(Str instanceof Error)
{
e /= 1e6, global.HASH_RATE += e, ADD_TO_STAT("HASHRATE", e);
}, global.GET_STAT = function (e)
{
var t = CONTEXT_STATS.Total[e];
return t = t || 0;
}, global.ADD_TO_STAT_TIME = function (e,t,r)
{
if(global.STAT_MODE)
{
if(r && 2 !== global.STAT_MODE)
return ;
var o = process.hrtime(t), n = 1e3 * o[0] + o[1] / 1e6;
ADD_TO_STAT(e, n);
Str = Str.message + "\n";
}
}, global.ADD_TO_STAT = function (e,t,r)
{
if(global.STAT_MODE)
{
if(r && 2 !== global.STAT_MODE)
return ;
AddToStatContext(CONTEXT_STATS, e, t);
}
}, global.GET_STATDIAGRAMS = function (e)
{
GetCurrentTime();
var t = GetCurrentStatIndex();
if(!e || !e.length)
return [];
for(var r = [], o = 0; o < e.length; o++)
{
var n = e[o], a = GetDiagramData(CONTEXT_STATS, n);
r.push({name:n, maxindex:t, arr:a, starttime:StartStatTime - 0, steptime:1});
}
var l = void 0;
for(o = 0; o < r.length; o++)
{
0 < (T = r[o].arr).length && (void 0 === l || T.length < l) && (l = T.length);
}
for(o = 0; o < r.length; o++)
{
var i = r[o], T = i.arr;
l && T.length > l && (T = T.slice(T.length - l)), l && 0 <= ",POWER_MY_WIN,POWER_BLOCKCHAIN,".indexOf("," + i.name + ",") && (T = SERVER.GetStatBlockchain(i.name,
l));
for(var g = 0, S = 0; S < T.length; S++)
T[S] && (g += T[S]);
0 < T.length && (g /= T.length);
var _ = 1;
if("MAX:" === i.name.substr(0, 4))
for(; 500 <= T.length; )
T = ResizeArrMax(T), _ *= 2;
if(type === "rinfo")
Str += " from: " + data1.address + ':' + data1.port;
else
for(; 500 <= T.length; )
T = ResizeArrAvg(T), _ *= 2;
i.AvgValue = g, i.steptime = _, i.arr = T.slice(1);
if(type === "node")
Str += " from: " + data1.ip + ':' + data1.port;
var Key = Module + ":" + ErrNum;
ToError(" ==ERROR== " + Key + " " + Str);
AddToStatContext(CONTEXT_ERRORS, Key);
ADD_TO_STAT("ERRORS");
};
function GetCurrentStatIndex()
{
var DefMaxStatPeriod = MAX_STAT_PERIOD * 2 + 2;
return CurStatIndex % DefMaxStatPeriod;
};
global.HASH_RATE = 0;
global.ADD_HASH_RATE = function (Count)
{
Count = Count / 1000000;
global.HASH_RATE += Count;
ADD_TO_STAT("HASHRATE", Count);
};
global.GET_STAT = function (Key)
{
var Val = CONTEXT_STATS.Total[Key];
if(!Val)
Val = 0;
return Val;
};
global.ADD_TO_STAT_TIME = function (Name,startTime,bDetail)
{
if(global.STAT_MODE)
{
if(bDetail && global.STAT_MODE !== 2)
return ;
var Time = process.hrtime(startTime);
var deltaTime = Time[0] * 1000 + Time[1] / 1e6;
ADD_TO_STAT(Name, deltaTime);
}
return r;
}, global.GET_STATS = function (e)
};
global.ADD_TO_STAT = function (Key,Count,bDetail)
{
var t = GetCurrentTime(), r = GetCurrentStatIndex();
return {stats:{Counter:CONTEXT_STATS.Total, Counter10S:CalcInterval(CONTEXT_STATS, r, 10), Counter10M:CalcInterval(CONTEXT_STATS,
r, 600)}, errors:{Counter:CONTEXT_ERRORS.Total, Counter10S:CalcInterval(CONTEXT_ERRORS, r, 10), Counter10M:CalcInterval(CONTEXT_ERRORS,
r, 600)}, period:(t - StartStatTime) / 1e3, Confirmation:[]};
}, global.StartCommonStat = function ()
if(global.STAT_MODE)
{
for(var e in CONTEXT_STATS.Total)
if(bDetail && global.STAT_MODE !== 2)
return ;
AddToStatContext(CONTEXT_STATS, Key, Count);
}
};
global.GET_STATDIAGRAMS = function (Keys)
{
var now = GetCurrentTime();
var index = GetCurrentStatIndex();
if(!Keys || !Keys.length)
return [];
var Data = [];
for(var i = 0; i < Keys.length; i++)
{
var name = Keys[i];
var Value = GetDiagramData(CONTEXT_STATS, name);
Data.push({name:name, maxindex:index, arr:Value, starttime:(StartStatTime - 0), steptime:1});
}
var MinLength = undefined;
for(var i = 0; i < Data.length; i++)
{
var arr = Data[i].arr;
if(arr.length > 0 && (MinLength === undefined || arr.length < MinLength))
MinLength = arr.length;
}
var MaxSizeArr = 500;
for(var i = 0; i < Data.length; i++)
{
var ItemServer = Data[i];
var arr = ItemServer.arr;
if(MinLength && arr.length > MinLength)
{
arr = arr.slice(arr.length - MinLength);
}
if(MinLength)
if(",POWER_MY_WIN,POWER_BLOCKCHAIN,".indexOf("," + ItemServer.name + ",") >= 0)
{
arr = SERVER.GetStatBlockchain(ItemServer.name, MinLength);
}
var AvgValue = 0;
for(var j = 0; j < arr.length; j++)
{
if(arr[j])
AvgValue += arr[j];
}
if(arr.length > 0)
AvgValue = AvgValue / arr.length;
var StepTime = 1;
if(ItemServer.name.substr(0, 4) === "MAX:")
{
while(arr.length >= MaxSizeArr)
{
arr = ResizeArrMax(arr);
StepTime = StepTime * 2;
}
}
else
{
while(arr.length >= MaxSizeArr)
{
arr = ResizeArrAvg(arr);
StepTime = StepTime * 2;
}
}
ItemServer.AvgValue = AvgValue;
ItemServer.steptime = StepTime;
ItemServer.arr = arr.slice(1);
}
return Data;
};
global.GET_STATS = function (Key)
{
var now = GetCurrentTime();
var index = GetCurrentStatIndex();
var stats = {Counter:CONTEXT_STATS.Total, Counter10S:CalcInterval(CONTEXT_STATS, index, 10), Counter10M:CalcInterval(CONTEXT_STATS,
index, 10 * 60), };
var errors = {Counter:CONTEXT_ERRORS.Total, Counter10S:CalcInterval(CONTEXT_ERRORS, index, 10), Counter10M:CalcInterval(CONTEXT_ERRORS,
index, 10 * 60), };
var Period = (now - StartStatTime) / 1000;
return {stats:stats, errors:errors, period:Period, Confirmation:[]};
};
global.StartCommonStat = function ()
{
for(var key in CONTEXT_STATS.Total)
return ;
ClearCommonStat();
}, global.ClearCommonStat = function ()
{
StartStatTime = void (CurStatIndex = 0), CONTEXT_STATS = {Total:{}, Interval:[]}, CONTEXT_ERRORS = {Total:{}, Interval:[]},
global.HASH_RATE = 0, SERVER.ClearStat();
}, global.ResizeArrAvg = ResizeArrAvg, global.ResizeArrMax = ResizeArrMax, DEBUG_MODE ? global.TO_DEBUG_LOG = function (e,t,r,o)
{
DEBUG_MODE && ("rinfo" === t && (e += " from: " + r.address + ":" + r.port + " - " + o.length), ToLog(e));
} : global.TO_DEBUG_LOG = function (e,t,r,o)
{
}, global.GetStrOnlyTime = function (e)
{
if(!global.GetCurrentTime)
return ":::";
var t = "" + (e = e || GetCurrentTime()).getHours().toStringZ(2);
return t = (t = (t = t + ":" + e.getMinutes().toStringZ(2)) + ":" + e.getSeconds().toStringZ(2)) + "." + e.getMilliseconds().toStringZ(3);
}, global.GetStrTime = function (e)
{
if(!global.GetCurrentTime)
return ":::";
var t = "" + (e = e || GetCurrentTime()).getDate().toStringZ(2);
return t = (t = (t = (t = (t = (t = t + "." + (1 + e.getMonth()).toStringZ(2)) + "." + e.getFullYear()) + " " + e.getHours().toStringZ(2)) + ":" + e.getMinutes().toStringZ(2)) + ":" + e.getSeconds().toStringZ(2)) + "." + e.getMilliseconds().toStringZ(3);
};
global.ClearCommonStat = function ()
{
CurStatIndex = 0;
StartStatTime = undefined;
CONTEXT_STATS = {Total:{}, Interval:[]};
CONTEXT_ERRORS = {Total:{}, Interval:[]};
global.HASH_RATE = 0;
SERVER.ClearStat();
};
function ResizeArrMax(arr)
{
var arr2 = [];
var Count2 = Math.trunc(arr.length / 2);
for(var i = 0; i < Count2; i++)
{
arr2[i] = Math.max(arr[i * 2], arr[i * 2 + 1]);
}
return arr2;
};
function ResizeArrAvg(arr)
{
var arr2 = [];
var Count2 = Math.trunc(arr.length / 2);
for(var i = 0; i < Count2; i++)
{
arr2[i] = (arr[i * 2] + arr[i * 2 + 1]) / 2;
}
return arr2;
};
function ResizeArr(arr)
{
var arr2 = [];
var Count2 = Math.trunc(arr.length / 2);
for(var i = 0; i < Count2; i++)
{
arr2[i] = arr[i * 2];
}
return arr2;
};
global.ResizeArrAvg = ResizeArrAvg;
global.ResizeArrMax = ResizeArrMax;
function GetDiagramData(Context,Key)
{
var DefMaxStatPeriod = MAX_STAT_PERIOD * 2 + 2;
var IsMax;
if(Key.substr(0, 4) === "MAX:")
IsMax = true;
else
IsMax = false;
var delta = MAX_STAT_PERIOD;
var index2 = GetCurrentStatIndex();
var index1 = (index2 - delta + DefMaxStatPeriod) % DefMaxStatPeriod;
var Total = Context.Total;
var Counter1;
var arr = [];
var PrevValue = undefined;
for(var i = index1; i < index1 + delta; i++)
{
var index3 = i % DefMaxStatPeriod;
Counter1 = Context.Interval[index3];
if(Counter1)
{
var Value = Counter1[Key];
if(Value !== undefined)
{
if(!IsMax)
{
if(PrevValue !== undefined)
{
arr.push(Value - PrevValue);
}
else
{
arr.push(Value);
}
PrevValue = Value;
}
else
{
arr.push(Value);
}
}
else
{
arr.push(0);
}
}
}
return arr;
};
function CalcInterval(Context,index2,delta)
{
var DefMaxStatPeriod = MAX_STAT_PERIOD * 2 + 2;
var Res = {};
var index1 = (index2 - delta + DefMaxStatPeriod) % DefMaxStatPeriod;
var Total = Context.Total;
var Counter1;
for(var i = index1; i < index1 + delta; i++)
{
var index3 = i % DefMaxStatPeriod;
Counter1 = Context.Interval[index3];
if(Counter1)
break;
}
if(Counter1)
for(var Key in Total)
{
if(Key.substr(0, 4) === "MAX:")
Res[Key] = 0;
else
{
if(Counter1[Key] === undefined)
Res[Key] = Total[Key];
else
Res[Key] = Total[Key] - Counter1[Key];
}
}
return Res;
};
function AddToStatContext(Context,Key,AddValue)
{
if(AddValue === undefined)
AddValue = 1;
var Val = Context.Total[Key];
if(!Val)
Val = 0;
if(Key.substr(0, 4) === "MAX:")
Val = Math.max(Val, AddValue);
else
Val = Val + AddValue;
Context.Total[Key] = Val;
if(!StartStatTime)
StartStatTime = GetCurrentTime(0);
};
function CopyStatInterval(Context,index)
{
var Counter = Context.Interval[index];
if(!Counter)
{
Counter = {};
Context.Interval[index] = Counter;
}
var Total = Context.Total;
for(var Key in Total)
{
Counter[Key] = Total[Key];
if(Key.substr(0, 4) === "MAX:")
Total[Key] = 0;
}
};
if(DEBUG_MODE)
global.TO_DEBUG_LOG = function (Str,type,data1,data2)
{
if(!DEBUG_MODE)
return ;
if(type === "rinfo")
Str += " from: " + data1.address + ':' + data1.port + ' - ' + data2.length;
ToLog(Str);
};
else
global.TO_DEBUG_LOG = function (Str,type,data1,data2)
{
};
function SaveToLogFileAsync(fname,Str)
{
fs.open(fname, "a", undefined, function (err,file_handle)
{
if(!err)
{
var StrLog = GetStrTime() + " : " + Str + "\r\n";
fs.write(file_handle, StrLog, null, 'utf8', function (err,written)
{
if(!err)
{
fs.close(file_handle, function (err)
{
if(err)
console.log(err);
});
}
else
{
console.log("Ошибка записи в лог-файл ошибок!");
}
});
}
else
{
console.log("Ошибка открытия лог-файла ошибок");
}
});
};
function SaveToLogFileSync(fname,Str)
{
try
{
var StrLog = GetStrTime() + " : " + Str + "\r\n";
var file_handle = fs.openSync(fname, "a");
fs.writeSync(file_handle, StrLog, null, 'utf8');
fs.closeSync(file_handle);
}
catch(err)
{
console.log(err.message);
}
};
global.GetStrOnlyTime = function (now)
{
if(!global.GetCurrentTime)
return ":::";
if(!now)
now = GetCurrentTime();
var Str = "" + now.getHours().toStringZ(2);
Str = Str + ":" + now.getMinutes().toStringZ(2);
Str = Str + ":" + now.getSeconds().toStringZ(2);
Str = Str + "." + now.getMilliseconds().toStringZ(3);
return Str;
};
global.GetStrTime = function (now)
{
if(!global.GetCurrentTime)
return ":::";
if(!now)
now = GetCurrentTime();
var Str = "" + now.getDate().toStringZ(2);
Str = Str + "." + (1 + now.getMonth()).toStringZ(2);
Str = Str + "." + now.getFullYear();
Str = Str + " " + now.getHours().toStringZ(2);
Str = Str + ":" + now.getMinutes().toStringZ(2);
Str = Str + ":" + now.getSeconds().toStringZ(2);
Str = Str + "." + now.getMilliseconds().toStringZ(3);
return Str;
};

View File

@ -9,65 +9,108 @@
*/
function DoRest(r,t,e)
function DoRest(RestData,Data,BlockNum)
{
var u = r.Arr[0], o = Math.floor(e / REST_BLOCK_SCALE);
if(o !== Math.floor((u.BlockNum - 1) / REST_BLOCK_SCALE))
var Prev = RestData.Arr[0];
var BlockNum0 = Math.floor(BlockNum / REST_BLOCK_SCALE);
if(BlockNum0 !== Math.floor((Prev.BlockNum - 1) / REST_BLOCK_SCALE))
{
for(var n = GetRestArr(o), l = [], a = n.length - 2; 0 <= a; a--)
l.push(n[a] * REST_BLOCK_SCALE);
RestPush(r, l, e, 1);
var arr = GetRestArr(BlockNum0);
var arr2 = [];
for(var i = arr.length - 2; i >= 0; i--)
{
arr2.push(arr[i] * REST_BLOCK_SCALE);
}
r.Arr[0] = {BlockNum:e, Value:t.Value};
RestPush(RestData, arr2, BlockNum, 1);
}
RestData.Arr[0] = {BlockNum:BlockNum, Value:Data.Value};
};
function RestPush(r,t,e,u)
function RestPush(RestData,ArrRest,BlockNum,Index)
{
var o = r.Arr[u - 1], n = r.Arr[u];
if(1 < u)
var Prev = RestData.Arr[Index - 1];
var Cur = RestData.Arr[Index];
if(Index > 1)
{
var l = t[u - 2];
if(o.BlockNum > l)
var RestNum = ArrRest[Index - 2];
if(Prev.BlockNum > RestNum)
return ;
}
if(n.BlockNum && n.BlockNum >= e || o.BlockNum >= e)
return n.BlockNum = 0, void (n.Value = {});
n.BlockNum && u < r.Arr.length - 1 && RestPush(r, t, e, u + 1), r.Arr[u] = o;
if((Cur.BlockNum && Cur.BlockNum >= BlockNum) || Prev.BlockNum >= BlockNum)
{
Cur.BlockNum = 0;
Cur.Value = {};
return ;
}
if(Cur.BlockNum)
{
if(Index < RestData.Arr.length - 1)
{
RestPush(RestData, ArrRest, BlockNum, Index + 1);
}
}
RestData.Arr[Index] = Prev;
};
function GetRestArr(r)
function GetRestArr(CurBlockNum)
{
for(var t = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], e = t.length, u = 0; u <= r; u++)
for(var o = 0, n = u, l = e - 1; 0 <= l; l--)
var Arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var ArrLength = Arr.length;
var StartNum = 0;
for(var num = StartNum; num <= CurBlockNum; num++)
{
var a = t[l];
if(t[l] = n, n = a, 0 == ((o = o << 4 | 15) & u))
var maska = 0;
var CurNum = num;
for(var i = ArrLength - 1; i >= 0; i--)
{
var PosNum = Arr[i];
Arr[i] = CurNum;
CurNum = PosNum;
maska = (maska << 4) | 15;
if((maska & num) === 0)
break;
if(0 != (o & n))
if((maska & CurNum) !== 0)
break;
}
return t;
}
return Arr;
};
var RestArrMap = {};
function GetCurrentRestArr()
{
var r = GetCurrentBlockNumByTime(), t = Math.floor(r / REST_BLOCK_SCALE), e = RestArrMap[t];
if(void 0 === e)
var BlockNum = GetCurrentBlockNumByTime();
var BlockNum0 = Math.floor(BlockNum / REST_BLOCK_SCALE);
var arr = RestArrMap[BlockNum0];
if(arr === undefined)
{
RestArrMap = {}, (e = GetRestArr(t)).length = e.length - 1;
for(var u = 0; u < e.length; u++)
e[u] = e[u] * REST_BLOCK_SCALE;
RestArrMap[t] = e;
RestArrMap = {};
arr = GetRestArr(BlockNum0);
arr.length = arr.length - 1;
for(var i = 0; i < arr.length; i++)
{
arr[i] = arr[i] * REST_BLOCK_SCALE;
}
return e;
RestArrMap[BlockNum0] = arr;
}
return arr;
};
function GetCurrentRestNum(r)
function GetCurrentRestNum(NumDelta)
{
for(var t = GetCurrentBlockNumByTime() - r, e = GetCurrentRestArr(), u = e.length - 1; 0 <= u; u--)
if(e[u] <= t)
return e[u];
var BlockNum = GetCurrentBlockNumByTime();
var BlockNumMin = BlockNum - NumDelta;
var arr = GetCurrentRestArr();
for(var i = arr.length - 1; i >= 0; i--)
{
if(arr[i] <= BlockNumMin)
{
return arr[i];
}
}
return 0;
};
global.DoRest = DoRest, global.GetRestArr = GetRestArr, global.GetCurrentRestArr = GetCurrentRestArr, global.GetCurrentRestNum = GetCurrentRestNum;
global.DoRest = DoRest;
global.GetRestArr = GetRestArr;
global.GetCurrentRestArr = GetCurrentRestArr;
global.GetCurrentRestNum = GetCurrentRestNum;

View File

@ -9,42 +9,77 @@
*/
var fs = require("fs");
function CopyFiles(l,o,t)
global.GetDataPath = function GetDataPath(name)
{
if(fs.existsSync(l))
for(var e = fs.readdirSync(l), n = 0; n < e.length; n++)
if(global.DATA_PATH.substr(global.DATA_PATH.length - 1, 1) !== "/")
global.DATA_PATH = global.DATA_PATH + "/";
return GetNormalPathString(global.DATA_PATH + name);
};
global.GetCodePath = function GetCodePath(name)
{
var a = l + "/" + e[n], s = o + "/" + e[n];
if(fs.statSync(a).isDirectory())
t && (fs.existsSync(s) || fs.mkdirSync(s), CopyFiles(a, s, t));
else
if(global.CODE_PATH.substr(global.CODE_PATH.length - 1, 1) !== "/")
global.CODE_PATH = global.CODE_PATH + "/";
return GetNormalPathString(global.CODE_PATH + name);
};
global.GetNormalPathString = function (Str)
{
var r = fs.readFileSync(a), i = fs.openSync(s, "w");
fs.writeSync(i, r, 0, r.length), fs.closeSync(i);
return Str.split("\\").join('/');
};
global.CheckCreateDir = function (Path,bHidden,IsFile)
{
Path = GetNormalPathString(Path);
if(!fs.existsSync(Path))
{
if(!bHidden)
console.log("Create: " + Path);
var arr = Path.split('/');
var CurPath = arr[0];
if(IsFile)
{
arr.length--;
}
for(var i = 1; i < arr.length; i++)
{
CurPath += "/" + arr[i];
if(!fs.existsSync(CurPath))
{
fs.mkdirSync(CurPath);
}
}
}
};
global.GetDataPath = function (l)
global.CopyFiles = CopyFiles;
function CopyFiles(FromPath,ToPath,bRecursive)
{
return "/" !== global.DATA_PATH.substr(global.DATA_PATH.length - 1, 1) && (global.DATA_PATH = global.DATA_PATH + "/"), GetNormalPathString(global.DATA_PATH + l);
}, global.GetCodePath = function (l)
if(fs.existsSync(FromPath))
{
return "/" !== global.CODE_PATH.substr(global.CODE_PATH.length - 1, 1) && (global.CODE_PATH = global.CODE_PATH + "/"), GetNormalPathString(global.CODE_PATH + l);
}, global.GetNormalPathString = function (l)
var arr = fs.readdirSync(FromPath);
for(var i = 0; i < arr.length; i++)
{
return l.split("\\").join("/");
}, global.CheckCreateDir = function (l,o,t)
var name1 = FromPath + "/" + arr[i];
var name2 = ToPath + "/" + arr[i];
if(fs.statSync(name1).isDirectory())
{
if(l = GetNormalPathString(l), !fs.existsSync(l))
if(bRecursive)
{
o || console.log("Create: " + l);
var e = l.split("/"), n = e[0];
t && e.length--;
for(var a = 1; a < e.length; a++)
n += "/" + e[a], fs.existsSync(n) || fs.mkdirSync(n);
if(!fs.existsSync(name2))
fs.mkdirSync(name2);
CopyFiles(name1, name2, bRecursive);
}
}, global.CopyFiles = CopyFiles, global.ToLog || (global.ToLog = function (l)
}
else
{
console.log(l);
});
var data = fs.readFileSync(name1);
var file_handle = fs.openSync(name2, "w");
fs.writeSync(file_handle, data, 0, data.length);
fs.closeSync(file_handle);
}
}
}
};
if(!global.ToLog)
global.ToLog = function (Str)
{
console.log(Str);
};

View File

@ -8,90 +8,151 @@
* Telegram: https://t.me/terafoundation
*/
global.PROCESS_NAME = "POW", global.POWPROCESS = 1, require("../core/library"), require("../core/crypto-library"), require("../core/terahashmining");
global.PROCESS_NAME = "POW";
global.POWPROCESS = 1;
require("../core/library");
require("../core/crypto-library");
require("../core/terahashmining");
var PROCESS = process;
process.send && !global.DEBUGPROCESS ? process.send({cmd:"online", message:"OK"}) : PROCESS = global.DEBUGPROCESS;
if(process.send && !global.DEBUGPROCESS)
{
process.send({cmd:"online", message:"OK"});
}
else
{
PROCESS = global.DEBUGPROCESS;
}
var LastAlive = Date.now();
setInterval(CheckAlive, 1e3);
var idInterval = void 0, Block = {};
setInterval(CheckAlive, 1000);
var idInterval = undefined;
var Block = {};
PROCESS.on('message', function (msg)
{
LastAlive = Date.now();
if(msg.cmd === "FastCalcBlock")
{
var FastBlock = msg;
StartHashPump(FastBlock);
FastBlock.RunCount = 0;
try
{
if(CreatePOWVersionX(FastBlock))
process.send({cmd:"POW", BlockNum:FastBlock.BlockNum, SeqHash:FastBlock.SeqHash, Hash:FastBlock.Hash, PowHash:FastBlock.PowHash,
AddrHash:FastBlock.AddrHash, Num:FastBlock.Num});
}
catch(e)
{
ToError(e);
}
}
else
if(msg.cmd === "SetBlock")
{
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")
{
}
else
if(msg.cmd === "Exit")
{
PROCESS.exit(0);
}
});
function CheckAlive()
{
if(!global.NOALIVE)
if(global.NOALIVE)
return ;
var Delta = Date.now() - LastAlive;
if(Math.abs(Delta) > CHECK_STOP_CHILD_PROCESS)
{
var e = Date.now() - LastAlive;
Math.abs(e) > CHECK_STOP_CHILD_PROCESS && PROCESS.exit(0);
PROCESS.exit(0);
return ;
}
};
function CalcPOWHash()
{
if(Block.SeqHash)
if(!Block.SeqHash)
return ;
if(new Date() - Block.Time > Block.Period)
{
if(new Date - Block.Time > Block.Period)
return clearInterval(idInterval), void (idInterval = void 0);
clearInterval(idInterval);
idInterval = undefined;
return ;
}
try
{
CreatePOWVersionX(Block) && process.send({cmd:"POW", BlockNum:Block.BlockNum, SeqHash:Block.SeqHash, Hash:Block.Hash, PowHash:Block.PowHash,
AddrHash:Block.AddrHash, Num:Block.Num});
if(CreatePOWVersionX(Block))
process.send({cmd:"POW", BlockNum:Block.BlockNum, SeqHash:Block.SeqHash, Hash:Block.Hash, PowHash:Block.PowHash, AddrHash:Block.AddrHash,
Num:Block.Num});
}
catch(e)
{
ToError(e);
}
}
};
PROCESS.on("message", function (e)
{
if(LastAlive = Date.now(), "FastCalcBlock" === e.cmd)
{
var o = e;
StartHashPump(o), o.RunCount = 0;
try
{
CreatePOWVersionX(o) && process.send({cmd:"POW", BlockNum:o.BlockNum, SeqHash:o.SeqHash, Hash:o.Hash, PowHash:o.PowHash, AddrHash:o.AddrHash,
Num:o.Num});
}
catch(e)
{
ToError(e);
}
}
else
if("SetBlock" === e.cmd)
{
var a = 1e6 * (1 + e.Num);
Block.HashCount && process.send({cmd:"HASHRATE", CountNonce:Block.HashCount, Hash:Block.Hash}), Block.HashCount = 0, (Block = e).Time = Date.now(),
Block.LastNonce = a, Block.Period = CONSENSUS_PERIOD_TIME * Block.Percent / 100, 0 < Block.Period && 0 < Block.RunPeriod && (CalcPOWHash(),
void 0 !== idInterval && clearInterval(idInterval), idInterval = setInterval(CalcPOWHash, Block.RunPeriod));
}
else
"Alive" === e.cmd || "Exit" === e.cmd && PROCESS.exit(0);
});
var idIntervalPump = global.BlockPump = void 0;
global.BlockPump = undefined;
var idIntervalPump = undefined;
function StartHashPump(e)
function StartHashPump(SetBlock)
{
(!BlockPump || BlockPump.BlockNum < e.BlockNum || BlockPump.MinerID !== e.MinerID || BlockPump.Percent !== e.Percent) && (global.BlockPump = {BlockNum:e.BlockNum,
RunCount:e.RunCount, MinerID:e.MinerID, Percent:e.Percent, LastNonce:0}), idIntervalPump = idIntervalPump || setInterval(PumpHash,
global.POWRunPeriod);
if(!BlockPump || BlockPump.BlockNum < SetBlock.BlockNum || BlockPump.MinerID !== SetBlock.MinerID || BlockPump.Percent !== SetBlock.Percent)
{
global.BlockPump = {BlockNum:SetBlock.BlockNum, RunCount:SetBlock.RunCount, MinerID:SetBlock.MinerID, Percent:SetBlock.Percent,
LastNonce:0, };
}
if(!idIntervalPump)
{
idIntervalPump = setInterval(PumpHash, global.POWRunPeriod);
}
};
var StartTime = 1, EndTime = 0;
var StartTime = 1;
var EndTime = 0;
function PumpHash()
{
if(BlockPump)
if(!BlockPump)
return ;
var CurTime = Date.now();
if(StartTime > EndTime)
{
var e = Date.now();
if(EndTime < StartTime)
var Delta = CurTime - StartTime;
var PeriodPercent = 100 * Delta / CONSENSUS_PERIOD_TIME;
if(PeriodPercent >= BlockPump.Percent)
{
if(100 * (e - StartTime) / CONSENSUS_PERIOD_TIME >= BlockPump.Percent)
return void (EndTime = e);
EndTime = CurTime;
return ;
}
CreatePOWVersionX(BlockPump, 1);
}
else
{
100 * (e - EndTime) / CONSENSUS_PERIOD_TIME > 100 - BlockPump.Percent && (StartTime = e);
var Delta = CurTime - EndTime;
var PeriodPercent = 100 * Delta / CONSENSUS_PERIOD_TIME;
if(PeriodPercent > 100 - BlockPump.Percent)
{
StartTime = CurTime;
}
}
};

View File

@ -274,7 +274,8 @@ function GETREST(msg)
var Tree = GetRestMerkleTree(BlockNumRest, RestIndexArr);
if(CompareArr(Data.AccHash, Tree.Root) !== 0)
{
ToLog("Get bad rest acc hash: " + BlockNumRest + " = " + GetHexFromArr(Data.AccHash) + "/" + GetHexFromArr(Tree.Root), 2);
ToLog("Get bad rest acc hash: " + BlockNumRest + " = " + GetHexFromArr(Data.AccHash).substr(0, 8) + "/" + GetHexFromArr(Tree.Root).substr(0,
8), 2);
ArrRest = [];
nResult = 0;
}

View File

@ -296,11 +296,16 @@ function RunListenServer()
bWasRun = 1;
});
};
if(global.HTTP_START_PAGE)
IndexName = global.HTTP_START_PAGE;
else
{
var SiteFolder = GetNormalPathString("./SITE");
if(!fs.existsSync(SiteFolder))
{
IndexName = "web-wallet.html";
}
}
var LangPathMap = {};
LangPathMap["ru"] = 1;
LangPathMap["cn"] = 1;