Sat Jul 20 14:20:10 CST 2019 Source Update...

This commit is contained in:
MiaoWoo 2019-07-20 14:20:10 +08:00
parent 6d7e4474f7
commit 59a5459080
10 changed files with 189 additions and 67 deletions

View File

@ -20,6 +20,7 @@ body {
main {
max-width: 1200px;
margin: 0 auto;
padding-top: 100px;
}
*,
@ -207,9 +208,14 @@ textarea {
}
.header {
position: fixed;
z-index: 100;
width: 100%;
background: linear-gradient(270deg, #3D4C61 0%, #445368 100%);
color: #fff;
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.15);
/*position: fixed; top: 0;*/
}
.header__wrapper {
display: flex;
@ -1738,6 +1744,9 @@ td.hash {
@media (min-width: 768px) {
.main {
padding-top: 60px;
}
.main-logo {
width: 125px;
height: 30px;
@ -1845,12 +1854,11 @@ td.hash {
position: absolute;
font-size: 14px;
line-height: 16px;
bottom: -38px;
right: 7px;
right: 165px;
width: 60px;
border-radius: 3px;
background: transparent;
color: var(--blue-grey);
color: rgba(255, 255, 255, 0.6);
}
.white-select {
display: block;
@ -2107,6 +2115,13 @@ td.hash {
}
@media (min-width: 768px) and (max-width: 800px) {
.header__nav {
margin-right: 35px;
}
}
@media (max-width: 960px) {
/* .prod-card--line:hover {
@ -2211,7 +2226,7 @@ td.hash {
margin-left: 0;
}
.header__right select {
right: 37px;
right: 207px;
}
.send-page__send-btn-wrp {
max-width: 100%;
@ -2438,7 +2453,7 @@ td.hash {
margin-right: 18px;
}
.header__right select {
right: 10px;
right: 190px;
}
.accounts-info__add .key-field {
min-width: 920px;

View File

@ -1035,7 +1035,7 @@ function RetHistoryAccount(Item,Name)
if(Num < 1)
return "" + Num;
var Str;
if(IsLocalClient())
if(UseInnerPage())
Str = "<a class='olink' target='_blank' onclick='OpenHistoryPage(" + Num + ")'>" + Num + "</a>";
else
Str = "<a class='olink' target='_blank' href='./history.html#" + Num + "'>" + Num + "</a>";
@ -1052,7 +1052,7 @@ function RetBaseAccount(Item)
function ViewTransaction(BlockNum)
{
if(IsLocalClient())
if(UseInnerPage())
OpenBlockViewerPage(BlockNum);
else
window.Open('./blockviewer.html#' + BlockNum, 'viewer', 800, 800);
@ -1966,3 +1966,20 @@ function Right(Str,count)
else
return Str.substr(0, Str.length);
};
function UseInnerPage()
{
if(isMobile() && !IsLocalClient())
return 1;
else
return 0;
};
function isMobile()
{
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
{
return true;
}
return false;
};

View File

@ -71,6 +71,11 @@ window.onload = function ()
{
window.attachEvent("onmessage", OnMessage);
}
if(UseInnerPage())
{
AddFrame("HistoryPage", "./history.html");
AddFrame("BlockViewerPage", "./blockviewer.html");
}
};
function OnLoad()
@ -110,11 +115,13 @@ function OnLoad()
}
};
function ChangeNetwork()
function ChangeNetwork(bStart)
{
CONNECT_STATUS = 0;
NETWORK = $("idCurNetwork").value;
Storage.setItem("NETWORK", NETWORK);
if(bStart)
StartWebWallet();
ConnectWebWallet();
};
@ -1047,7 +1054,7 @@ function MyToggleList(e)
function OpenHistoryPage(Num)
{
if(!IsLocalClient())
if(!UseInnerPage())
{
window.open("./history.html#" + Num);
return ;
@ -1058,7 +1065,7 @@ function OpenHistoryPage(Num)
function OpenBlockViewerPage(Num)
{
if(!IsLocalClient())
if(!UseInnerPage())
{
window.open("./blockviewer.html#" + Num);
return ;
@ -1067,6 +1074,17 @@ function OpenBlockViewerPage(Num)
SendMessage("BlockViewerPage", {BlockNum:Num, FrameName:"idBlockViewerPage"});
};
function AddFrame(name,filename)
{
var iframe = document.createElement('iframe');
iframe.name = name;
iframe.src = filename;
iframe.sandbox = "allow-scripts allow-same-origin allow-popups";
iframe.id = "id" + name;
iframe.style = "display: none";
document.getElementsByTagName('body')[0].appendChild(iframe);
};
function SetVisibleFrame(name,bVisible)
{
SetVisibleBlock("idMainHeader", !bVisible);
@ -1175,7 +1193,7 @@ function ChangeLang()
function GetNewLangItem()
{
ToLog(JSON.stringify(LangMap["ENG"]));
console.log(JSON.stringify(LangMap["ENG"]));
};
var LangMap = {};
LangMap["ENG"] = {};
@ -1189,17 +1207,18 @@ LangMap["RUS"] = {"TERA WALLET":"TERA КОШЕЛЕК", "Generate key":"Сген
"Current create:":"Текущий блок:", "Protocol ver:":"Версия протокола:", "ID: {Item.Num}":"ИД: {Item.Num}", "Token generate":"Генерация токенов",
"ACCOUNTS":"СЧЕТА", "SEND":"ПОСЛАТЬ", "DAPPS":"ДАППС", "EXPLORER":"ПРОСМ", "ATTENTION: Before using the wallet, save the private key.":"ВНИМАНИЕ: Перед использованием кошелька сохраните приватный ключ",
"Web-site":"Веб-сайт", "Bitcointalk":"Bitcointalk", "Twitter":"Твиттер", "Telegram":"Телеграм", "Discord":"Дискорд", "QQchat":"QQchat",
"Buy/sell/mine TERA":"Купить/Продать", "+ CREATE NEW":"+ СОЗДАТЬ НОВЫЙ", "Confirm Transaction":"Подтверждение транзакции",
"CREATE 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)":"Децентрализованные приложения (Даппс)",
"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:":"Отправитель:", "Set a password for protect entry":"Установите пароль для безопасности", "Enter password to unlock wallet":"Введите пароль для разблокировки кошелька",
"From ID:":"Отправитель:", "Pay to 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":"Публичный ключ"};
"Buy/sell/mine TERA":"Купить/Продать", "+ CREATE NEW":"+ СОЗДАТЬ", "Confirm Transaction":"Подтверждение транзакции", "CREATE 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)":"Децентрализованные приложения (Даппс)", "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:":"Отправитель:", "Set a password for protect entry":"Установите пароль для безопасности",
"Enter password to unlock wallet":"Введите пароль для разблокировки кошелька", "From ID:":"Отправитель:", "Pay to 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":"Публичный ключ", "Enter number of dapp":"Введите номер Даппа",
"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.":"Введите номер Даппа, который будет добавлен в ваш аккаунт. Внимание убедитесь, что Вы доверяете ему, в противном случае вы можете потерять все средства на этом счете."};
LangMap["简体中文"] = {"TERA WALLET":"TERA 钱包", "Generate key":"生成私钥", "OK":"OK", "Cancel":"取消", "Edit":"编辑", "Save key":"保存私钥",
"+ CREATE A NEW ACCOUNT":"+ 新建账号", "Create account":"创建账号", "Send":"发送", "SEND":"转账", "CONFIRM":"确认", "Accounts":"账号", "Account(s)":"账号",
"Blocks and Tx":"区块和交易", "Counters":"状态统计", "Open DApp":"打开DApp", "Back":"返回", "Delete":"删除", "Save to book":"保存到地址本", "Choose":"选择",

View File

@ -8,12 +8,13 @@
* Telegram: https://t.me/terafoundation
*/
var MIN_VERSION = 1020;
var MIN_VERSION = 1114;
var COUNT_BLOCK_PROOF = 300;
var MIN_SUM_POWER = COUNT_BLOCK_PROOF * 35;
var MIN_SUM_POWER = 0;
var MainServer = undefined;
var MaxConnectedCount = 10;
var MaxTimeConnecting = 3 * 1000;
var TIME_LENGTH_CONNECT_ALL = 2 * 1000;
var MAX_TIME_FOR_CONNECT = 1000;
var StartTimeConnecting = 0;
var ConnectedCount = 0;
var NETWORK = "TERA-MAIN";
@ -26,7 +27,8 @@ var ServerMainMap = {"127.0.0.1":{"ip":"127.0.0.1", "port":80, "Name":"LOCAL"},
"port":80, "Name":"SUPPORT2", "System":1}, "t1.teraexplorer.com":{"ip":"t1.teraexplorer.com", "port":80, "Name":"t1.teraexplorer.com",
"System":1}, };
var ServerTestMap = {"127.0.0.1":{"ip":"127.0.0.1", "port":80, "Name":"LOCAL"}, "dappsgate.com":{"ip":"dappsgate.com", "port":88,
"Name":"SUPPORT2", "System":1}, };
"Name":"SUPPORT1", "System":1}, "terablockchain.org":{"ip":"terablockchain.org", "port":88, "Name":"SUPPORT2", "System":1},
};
function StartWebWallet()
{
@ -111,9 +113,11 @@ function ConnectWebWallet()
setTimeout(LoopWalletInfo, 1500);
};
var Stage = 0;
var PreparingStartLoopHandShake = 0;
function LoopHandShake()
{
PreparingStartLoopHandShake = 0;
Stage++;
SetStatus("Connecting: " + Stage + "...");
for(var key in ServerMap)
@ -130,13 +134,12 @@ function LoopHandShake()
function DoNodeList(Item)
{
console.log(GetProtocolServerPath(Item) + "/GetNodeList");
if(window.location.protocol === "https:" && Item.port !== 443)
return ;
if(Item.port === 443 && IsIPAddres(Item.ip))
return ;
SetStatus("Try: " + Item.ip + ":" + Item.port);
Item.SendHandShake = 1;
Item.StartTime = Date.now();
GetData(GetProtocolServerPath(Item) + "/GetNodeList", {}, function (Data)
{
if(Data && Data.result && Data.NETWORK === NETWORK && Data.VersionNum >= MIN_VERSION)
@ -144,7 +147,7 @@ function DoNodeList(Item)
ConnectedCount++;
Item.GetHandShake = 1;
Item.BlockChain = Data.BlockChain;
SetStatus("Get: " + Item.ip + ":" + Item.port);
Item.DeltaTime = Date.now() - Item.StartTime;
var bWas = 0;
for(var i = 0; i < Data.arr.length; i++)
{
@ -152,33 +155,47 @@ function DoNodeList(Item)
if(!ServerMap[Node.ip] && Node.port)
{
ServerMap[Node.ip] = Node;
console.log("New: " + Node.ip + ":" + Node.port);
bWas = 1;
}
}
if(bWas && ConnectedCount < MaxConnectedCount && new Date() - StartTimeConnecting < MaxTimeConnecting)
var DeltaAll = Date.now() - StartTimeConnecting;
if(!PreparingStartLoopHandShake && bWas && ConnectedCount < MaxConnectedCount && DeltaAll < TIME_LENGTH_CONNECT_ALL)
{
PreparingStartLoopHandShake = 1;
setTimeout(LoopHandShake, 100);
}
}
});
};
var idTimeFindLider = 0;
var CountDoWalletInfoAll = 0;
var CountDoWalletInfoGet = 0;
function LoopWalletInfo()
{
SetStatus("Get wallets info...");
CountDoWalletInfoAll = 0;
CountDoWalletInfoGet = 0;
var Arr = [];
for(var key in ServerMap)
{
var Item = ServerMap[key];
if(Item.port)
if(Item.port && Item.DeltaTime < MAX_TIME_FOR_CONNECT)
{
CountWallet++;
if(window.BrowserIE && CountWallet > 4)
break;
DoWalletInfo(Item);
Arr.push(Item);
}
}
setTimeout(FindLider, 500);
Arr.sort(function (a,b)
{
a.DeltaTime - b.DeltaTime;
});
CountWallet = Math.min(Arr.length, 8);
if(window.BrowserIE && CountWallet > 4)
CountWallet = 4;
for(var i = 0; i < CountWallet; i++)
{
DoWalletInfo(Arr[i]);
}
idTimeFindLider = setTimeout(FindLider, 2500);
};
function DoWalletInfo(Item)
@ -187,18 +204,28 @@ function DoWalletInfo(Item)
return ;
if(Item.port === 443 && IsIPAddres(Item.ip))
return ;
CountDoWalletInfoAll++;
Item.StartTime = Date.now();
Item.SendWalletInfo = 1;
GetData(GetProtocolServerPath(Item) + "/GetCurrentInfo", {BlockChain:1}, function (Data)
{
if(!idTimeFindLider)
return ;
if(Data && Data.result && Data.BlockChain && Data.NETWORK === NETWORK)
{
Item.Name = Data.NODES_NAME;
Item.GetWalletInfo = 1;
Item.DeltaTime = new Date() - Item.StartTime;
Item.DeltaTime = Date.now() - Item.StartTime;
Item.BlockChain = Data.BlockChain;
Item.MaxNumBlockDB = Data.MaxNumBlockDB;
console.log("Get: " + Item.ip + ":" + Item.port + " delta=" + Item.DeltaTime);
SetStatus("Get: " + Item.ip + ":" + Item.port + " t:" + Item.DeltaTime);
CountDoWalletInfoGet++;
if(idTimeFindLider && CountDoWalletInfoAll && CountDoWalletInfoGet >= 2 && CountDoWalletInfoGet / CountDoWalletInfoAll > 0.7)
{
clearTimeout(idTimeFindLider);
idTimeFindLider = 0;
FindLider();
}
}
});
};
@ -219,7 +246,6 @@ function FindLider()
Item.SumPower = CalcPowFromBlockChain(arr);
if(Item.SumPower < MIN_SUM_POWER)
{
console.log("Skip: " + Item.ip + ":" + Item.port + " SumPower(" + Item.SumPower + ") < MIN_SUM_POWER(" + MIN_SUM_POWER + ")");
continue;
}
if(!MapSumPower[Item.SumPower])
@ -246,7 +272,7 @@ function FindLider()
var Item = Arr[i];
if(Item.SumPower === MaxKey)
{
SetStatus("Find " + Item.ip + ":" + Item.port + " with pow=" + Item.SumPower + "/" + MaxKey + " ping=" + Item.DeltaTime);
SetStatus("Find " + Item.ip + ":" + Item.port + " pow=" + Item.SumPower + " t:" + Item.DeltaTime + " ms");
MainServer = Item;
SaveServerMap();
break;

View File

@ -359,6 +359,9 @@
SendMessage({cmd:"History",OPEN_PATH:OPEN_PATH});
}, false);
if(isMobile())
SetMobileMode();
}
function CreateFrame(SetData)
@ -409,8 +412,6 @@
newchild.name = "viewport"
newchild.content = "width=device-width, initial-scale=1.0";//, maximum-scale=1.0, user-scalable=0;
window.parent.document.getElementsByTagName("head")[0].appendChild(newchild);
//ToLog("SetMobileMode 2");
}

View File

@ -1105,10 +1105,10 @@
ArrInfo=
[
{Name:"Hashrate from the beginning of the chain", Delta:1000000000, DX:310},
{Name:"month", Delta:30.5*24*3600, DX:200},
{Name:"day", Delta:24*3600, DX:140},
{Name:"hour", Delta:3600, DX:90},
{Name:"minute", Delta:60, DX:60}
{Name:"month", Delta:30.5*24*3600, DX:200, Mult:10000},
{Name:"day", Delta:24*3600, DX:140, Mult:1000},
{Name:"hour", Delta:3600, DX:90, Mult:100},
{Name:"minute", Delta:60, DX:60, Mult:2},
];
for(var i=0;i<ArrInfo.length;i++)
@ -1137,7 +1137,7 @@
if(Item.BlockNum1<0)
Item.BlockNum1=0;
CurBlockNum=Item.BlockNum1;
CurBlockNum=Math.floor(Item.BlockNum1/Item.Mult)*Item.Mult;
var MustUpdate=0;
if(Item.PowerArr)

View File

@ -635,7 +635,7 @@
<section class="modal password-modal" id="idSmartEnter">
<h2 class="password-modal__title">Enter number of dapp</h2>
<h2 class="password-modal__title"><span>Enter number of dapp</span></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">
@ -647,7 +647,7 @@
<div class="fixed-status">
<div class="fixed-status__wrap">
<div id="idStatus" class="fixed-status__status">&nbsp;</div>
<select class="grey-btn" id="idCurNetwork" onchange="ChangeNetwork()">
<select class="grey-btn" id="idCurNetwork" onchange="ChangeNetwork(1)">
<option value="TERA-MAIN">TERA MAIN</option>
<option value="TERA-TEST3">TERA TEST3</option>
</select>
@ -668,8 +668,8 @@
</DIV>
</DIV>
<iframe id="idHistoryPage" name="HistoryPage" style="display: none" src="./history.html"></iframe>
<iframe id="idBlockViewerPage" name="BlockViewerPage" style="display: none" src="./blockviewer.html"></iframe>
<!--<iframe id="idHistoryPage" name="HistoryPage" style="display: none" src="./history.html"></iframe>-->
<!--<iframe id="idBlockViewerPage" name="BlockViewerPage" style="display: none" src="./blockviewer.html"></iframe>-->
</body>
</html>

View File

@ -8,7 +8,7 @@
* Telegram: https://t.me/terafoundation
*/
global.UPDATE_CODE_VERSION_NUM = 1151;
global.UPDATE_CODE_VERSION_NUM = 1159;
global.MIN_CODE_VERSION_NUM = 1114;
global.MINING_VERSION_NUM = 0;
global.InitParamsArg = InitParamsArg;

View File

@ -360,7 +360,7 @@ module.exports = class CDB extends require("../code")
{
var BufWrite, FileItem, written;
var BlockNum = Math.trunc(Block.BlockNum);
this.ClearBufMap()
this.TruncateBufMap(BlockNum)
Block.VersionDB = global.DB_VERSION
BufWrite = BufLib.GetBufferFromObject(Block, FORMAT_STREAM_HEADER, 200, WorkStructStreamHeader)
FileItem = BlockDB.OpenDBFile(FILE_NAME_BODY, 1)
@ -401,7 +401,7 @@ module.exports = class CDB extends require("../code")
WriteBufHeaderToFile1(BufWrite, BlockNum)
{
BlockNum = Math.trunc(BlockNum)
this.ClearBufMap()
this.TruncateBufMap(BlockNum)
var FileItem = BlockDB.OpenDBFile(FILE_NAME_HEADER, 1);
var Position = BlockNum * BLOCK_HEADER_SIZE;
var written = fs.writeSync(FileItem.fd, BufWrite, 0, BufWrite.length, Position);
@ -578,6 +578,19 @@ module.exports = class CDB extends require("../code")
Block.Prepared = true
return this.PrepareBlockFields(Block, BlockNum);
}
ClearBufMap()
{
this.MapHeader = {}
}
TruncateBufMap(BlockNum)
{
if(BlockNum % 10000 === 0)
this.ClearBufMap()
else
{
delete this.MapHeader[BlockNum]
}
}
ReadBlockHeaderFromMapDB(BlockNum)
{
var Block = this.MapHeader[BlockNum];
@ -586,6 +599,10 @@ module.exports = class CDB extends require("../code")
Block = this.ReadBlockHeaderDB(BlockNum)
this.MapHeader[BlockNum] = Block
}
else
{
Block.FromMap = 1
}
return Block;
}
SetTruncateBlockDB(BlockNum)
@ -659,10 +676,6 @@ module.exports = class CDB extends require("../code")
this.CreateGenesisBlocks()
this.StartSyncBlockchain()
}
ClearBufMap()
{
this.MapHeader = {}
}
Close()
{
this.ClearBufMap()

View File

@ -22,9 +22,9 @@ ContenTypeMap["wav"] = "audio/wav";
ContenTypeMap["mp3"] = "audio/mpeg";
ContenTypeMap["mp4"] = "video/mp4";
ContenTypeMap["ico"] = "image/vnd.microsoft.icon";
ContenTypeMap["jpg"] = "image/jpeg";
ContenTypeMap["png"] = "image/png";
ContenTypeMap["gif"] = "image/gif";
ContenTypeMap["jpg"] = "image/jpeg";
ContenTypeMap["html"] = "text/html";
ContenTypeMap["txt"] = "text/plain";
ContenTypeMap["csv"] = "text/csv";
@ -35,7 +35,6 @@ ContenTypeMap["pdf"] = "application/pdf";
ContenTypeMap["exe"] = "application/octet-stream";
ContenTypeMap["msi"] = "application/octet-stream";
ContenTypeMap["woff"] = "application/font-woff";
ContenTypeMap[".js"] = "application/javascript";
ContenTypeMap["html"] = "text/html";
ContenTypeMap["psd"] = "application/octet-stream";
global.HTTPCaller = {};
@ -1456,7 +1455,11 @@ function SendWebFile(response,name,StrCookie,bParsing)
var type = name.substr(name.length - 4, 4);
if(type.substr(0, 1) === ".")
type = type.substr(1);
var Path = "./" + name;
var Path;
if(name.substr(0, 2) !== "./")
Path = "./" + name;
else
Path = name;
if(!fs.existsSync(Path))
{
if(type === "ico")
@ -1492,6 +1495,13 @@ function SendWebFile(response,name,StrCookie,bParsing)
response.end(data);
return ;
}
else
if("image/jpeg,image/vnd.microsoft.icon,image/svg+xml,image/png,application/javascript,text/css,text/html".indexOf(StrContentType) > - 1)
{
var data = GetFileSimpleBin(Path);
response.end(data);
return ;
}
const stream = fs.createReadStream(Path);
setTimeout(function ()
{
@ -1595,6 +1605,18 @@ function GetFileSimple(Path)
return data;
};
function GetFileSimpleBin(Path)
{
var Key = "GetFileSimpleBin-" + Path;
var data = global.SendHTMLMap[Key];
if(!data)
{
data = (fs.readFileSync(Path));
global.SendHTMLMap[Key] = data;
}
return data;
};
function SaveFileSimple(Path,Str)
{
global.SendHTMLMap = {};
@ -1609,6 +1631,14 @@ global.GetFileHTMLFromMarkdown = GetFileHTMLFromMarkdown;
global.GetFileSimple = GetFileSimple;
global.SaveFileSimple = SaveFileSimple;
function ReloaSenddBufer()
{
global.SendHTMLMap = {};
};
setInterval(ReloaSenddBufer, 60 * 1000);
if(global.DEV_MODE)
setInterval(ReloaSenddBufer, 1 * 1000);
function GetStrTime(now)
{
if(!now)
@ -1926,6 +1956,7 @@ function GetEventArray(SmartNum,Context)
};
HTTPCaller.GetHashRate = function (ArrParams)
{
var AllReadCount = 0;
var CurBlockNum = GetCurrentBlockNumByTime();
var ResArr = [];
for(var i = 0; i < ArrParams.length; i++)
@ -1950,9 +1981,7 @@ HTTPCaller.GetHashRate = function (ArrParams)
var StepDelta = Math.floor(Delta / Count);
if(StepDelta < 1)
StepDelta = 1;
var CountAvg = 10;
if(i === ArrParams.length - 1)
CountAvg = 3;
var CountAvg = 3;
var StepDeltaAvg = Math.floor(StepDelta / CountAvg);
if(StepDeltaAvg < 1)
StepDeltaAvg = 1;
@ -1971,9 +2000,11 @@ HTTPCaller.GetHashRate = function (ArrParams)
var CountSum = 0;
for(var d = 0; d < CountAvg; d++)
{
var Block = SERVER.ReadBlockHeaderDB(Num + d * StepDeltaAvg);
var Block = SERVER.ReadBlockHeaderFromMapDB(Num + d * StepDeltaAvg);
if(Block)
{
if(!Block.FromMap)
AllReadCount++;
CountSum++;
Sum += GetPowPower(Block.PowHash);
}