sync: sync upstream code

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2019-07-20 22:19:06 +08:00
parent b05a00f87d
commit a981ccbcae
7 changed files with 126 additions and 42 deletions

View File

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

View File

@ -1035,7 +1035,7 @@ function RetHistoryAccount(Item,Name)
if(Num < 1) if(Num < 1)
return "" + Num; return "" + Num;
var Str; var Str;
if(IsLocalClient()) if(UseInnerPage())
Str = "<a class='olink' target='_blank' onclick='OpenHistoryPage(" + Num + ")'>" + Num + "</a>"; Str = "<a class='olink' target='_blank' onclick='OpenHistoryPage(" + Num + ")'>" + Num + "</a>";
else else
Str = "<a class='olink' target='_blank' href='./history.html#" + Num + "'>" + Num + "</a>"; Str = "<a class='olink' target='_blank' href='./history.html#" + Num + "'>" + Num + "</a>";
@ -1052,7 +1052,7 @@ function RetBaseAccount(Item)
function ViewTransaction(BlockNum) function ViewTransaction(BlockNum)
{ {
if(IsLocalClient()) if(UseInnerPage())
OpenBlockViewerPage(BlockNum); OpenBlockViewerPage(BlockNum);
else else
window.Open('./blockviewer.html#' + BlockNum, 'viewer', 800, 800); window.Open('./blockviewer.html#' + BlockNum, 'viewer', 800, 800);
@ -1966,3 +1966,20 @@ function Right(Str,count)
else else
return Str.substr(0, Str.length); 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); window.attachEvent("onmessage", OnMessage);
} }
if(UseInnerPage())
{
AddFrame("HistoryPage", "./history.html");
AddFrame("BlockViewerPage", "./blockviewer.html");
}
}; };
function OnLoad() function OnLoad()
@ -110,11 +115,13 @@ function OnLoad()
} }
}; };
function ChangeNetwork() function ChangeNetwork(bStart)
{ {
CONNECT_STATUS = 0; CONNECT_STATUS = 0;
NETWORK = $("idCurNetwork").value; NETWORK = $("idCurNetwork").value;
Storage.setItem("NETWORK", NETWORK); Storage.setItem("NETWORK", NETWORK);
if(bStart)
StartWebWallet();
ConnectWebWallet(); ConnectWebWallet();
}; };
@ -1047,7 +1054,7 @@ function MyToggleList(e)
function OpenHistoryPage(Num) function OpenHistoryPage(Num)
{ {
if(!IsLocalClient()) if(!UseInnerPage())
{ {
window.open("./history.html#" + Num); window.open("./history.html#" + Num);
return ; return ;
@ -1058,7 +1065,7 @@ function OpenHistoryPage(Num)
function OpenBlockViewerPage(Num) function OpenBlockViewerPage(Num)
{ {
if(!IsLocalClient()) if(!UseInnerPage())
{ {
window.open("./blockviewer.html#" + Num); window.open("./blockviewer.html#" + Num);
return ; return ;
@ -1067,6 +1074,17 @@ function OpenBlockViewerPage(Num)
SendMessage("BlockViewerPage", {BlockNum:Num, FrameName:"idBlockViewerPage"}); 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) function SetVisibleFrame(name,bVisible)
{ {
SetVisibleBlock("idMainHeader", !bVisible); SetVisibleBlock("idMainHeader", !bVisible);
@ -1175,7 +1193,7 @@ function ChangeLang()
function GetNewLangItem() function GetNewLangItem()
{ {
ToLog(JSON.stringify(LangMap["ENG"])); console.log(JSON.stringify(LangMap["ENG"]));
}; };
var LangMap = {}; var LangMap = {};
LangMap["ENG"] = {}; LangMap["ENG"] = {};
@ -1189,17 +1207,18 @@ LangMap["RUS"] = {"TERA WALLET":"TERA КОШЕЛЕК", "Generate key":"Сген
"Current create:":"Текущий блок:", "Protocol ver:":"Версия протокола:", "ID: {Item.Num}":"ИД: {Item.Num}", "Token generate":"Генерация токенов", "Current create:":"Текущий блок:", "Protocol ver:":"Версия протокола:", "ID: {Item.Num}":"ИД: {Item.Num}", "Token generate":"Генерация токенов",
"ACCOUNTS":"СЧЕТА", "SEND":"ПОСЛАТЬ", "DAPPS":"ДАППС", "EXPLORER":"ПРОСМ", "ATTENTION: Before using the wallet, save the private key.":"ВНИМАНИЕ: Перед использованием кошелька сохраните приватный ключ", "ACCOUNTS":"СЧЕТА", "SEND":"ПОСЛАТЬ", "DAPPS":"ДАППС", "EXPLORER":"ПРОСМ", "ATTENTION: Before using the wallet, save the private key.":"ВНИМАНИЕ: Перед использованием кошелька сохраните приватный ключ",
"Web-site":"Веб-сайт", "Bitcointalk":"Bitcointalk", "Twitter":"Твиттер", "Telegram":"Телеграм", "Discord":"Дискорд", "QQchat":"QQchat", "Web-site":"Веб-сайт", "Bitcointalk":"Bitcointalk", "Twitter":"Твиттер", "Telegram":"Телеграм", "Discord":"Дискорд", "QQchat":"QQchat",
"Buy/sell/mine TERA":"Купить/Продать", "+ CREATE NEW":"+ СОЗДАТЬ НОВЫЙ", "Confirm Transaction":"Подтверждение транзакции", "Buy/sell/mine TERA":"Купить/Продать", "+ CREATE NEW":"+ СОЗДАТЬ", "Confirm Transaction":"Подтверждение транзакции", "CREATE DAPPS":"СОЗДАТЬ",
"CREATE DAPPS":"СОЗДАТЬ", "Set pass":"Установить пароль", "Unlock":"Разблокировать", "Entrance to sub-wallet":"Войти в под-кошелек", "Set pass":"Установить пароль", "Unlock":"Разблокировать", "Entrance to sub-wallet":"Войти в под-кошелек", "Public name":"Публичное имя",
"Public name":"Публичное имя", "Currency":"Валюта", "Pay to:":"Получатель:", "Amount:":"Сумма:", "Description:":"Описание:", "Currency":"Валюта", "Pay to:":"Получатель:", "Amount:":"Сумма:", "Description:":"Описание:", "Welcome to TERA Wallet":"Добропожаловать в кошелек TERA",
"Welcome to TERA Wallet":"Добропожаловать в кошелек TERA", "Edit your wallet":"Редактирование вашего кошелька", "Key settings":"Задание ключей", "Edit your wallet":"Редактирование вашего кошелька", "Key settings":"Задание ключей", "KEY SETTINGS":"ЗАДАНИЕ КЛЮЧЕЙ", "Create an account":"Создание счета",
"KEY SETTINGS":"ЗАДАНИЕ КЛЮЧЕЙ", "Create an account":"Создание счета", "Sending coins":"Отправка монет", "Decentralized applications (dApps)":"Децентрализованные приложения (Даппс)", "Sending coins":"Отправка монет", "Decentralized applications (dApps)":"Децентрализованные приложения (Даппс)", "Secure your wallet":"Безопасность вашего кошелька",
"Secure your wallet":"Безопасность вашего кошелька", "Wallet is secured":"Установлен пароль", "Total":"Всего", "Item.Name":"Item.Name", "Wallet is secured":"Установлен пароль", "Total":"Всего", "Item.Name":"Item.Name", "You have no accounts yet":"У вас нет ни одного счета",
"You have no accounts yet":"У вас нет ни одного счета", "Wait 10-15 sec":"Ждите 10-15 сек", "Creating your account":"Идет создание вашего счета", "Wait 10-15 sec":"Ждите 10-15 сек", "Creating your account":"Идет создание вашего счета", "From:":"Отправитель:", "Set a password for protect entry":"Установите пароль для безопасности",
"From:":"Отправитель:", "Set a password for protect entry":"Установите пароль для безопасности", "Enter password to unlock wallet":"Введите пароль для разблокировки кошелька", "Enter password to unlock wallet":"Введите пароль для разблокировки кошелька", "From ID:":"Отправитель:", "Pay to ID:":"Получатель:",
"From ID:":"Отправитель:", "Pay to ID:":"Получатель:", "Account":"Счет", "Owner":"Владелец", "Block num":"Ном блока", "Private key (secret)":"Приватный ключ (секретно)", "Account":"Счет", "Owner":"Владелец", "Block num":"Ном блока", "Private key (secret)":"Приватный ключ (секретно)", "Load key":"Загруз.",
"Load key":"Загруз.", "Create your first account and start using TERA":"Создайте свой первый счет и начните использовать TERA", "Create your first account and start using TERA":"Создайте свой первый счет и начните использовать TERA", "0 Accounts":"0 Счетов",
"0 Accounts":"0 Счетов", "OWNER: {Item.Owner}":"Владелец: {Item.Owner}", "More info":"Информация", "Public key":"Публичный ключ"}; "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":"保存私钥", LangMap["简体中文"] = {"TERA WALLET":"TERA 钱包", "Generate key":"生成私钥", "OK":"OK", "Cancel":"取消", "Edit":"编辑", "Save key":"保存私钥",
"+ CREATE A NEW ACCOUNT":"+ 新建账号", "Create account":"创建账号", "Send":"发送", "SEND":"转账", "CONFIRM":"确认", "Accounts":"账号", "Account(s)":"账号", "+ 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":"选择", "Blocks and Tx":"区块和交易", "Counters":"状态统计", "Open DApp":"打开DApp", "Back":"返回", "Delete":"删除", "Save to book":"保存到地址本", "Choose":"选择",

View File

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

View File

@ -635,7 +635,7 @@
<section class="modal password-modal" id="idSmartEnter"> <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> <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"> <input type="number" class="password-modal__input" placeholder="Dapp number" id="idSmartNum">
@ -647,7 +647,7 @@
<div class="fixed-status"> <div class="fixed-status">
<div class="fixed-status__wrap"> <div class="fixed-status__wrap">
<div id="idStatus" class="fixed-status__status">&nbsp;</div> <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-MAIN">TERA MAIN</option>
<option value="TERA-TEST3">TERA TEST3</option> <option value="TERA-TEST3">TERA TEST3</option>
</select> </select>
@ -668,9 +668,6 @@
</DIV> </DIV>
</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>
</body> </body>
</html> </html>

View File

@ -327,7 +327,7 @@ export default class CDB extends CCode {
WriteBlockHeaderToFile2(Block) { WriteBlockHeaderToFile2(Block) {
var BufWrite, FileItem, written; var BufWrite, FileItem, written;
var BlockNum = Math.trunc(Block.BlockNum); var BlockNum = Math.trunc(Block.BlockNum);
this.ClearBufMap() this.TruncateBufMap(BlockNum)
Block.VersionDB = global.DB_VERSION Block.VersionDB = global.DB_VERSION
BufWrite = global.BufLib.GetBufferFromObject(Block, FORMAT_STREAM_HEADER, 200, WorkStructStreamHeader) BufWrite = global.BufLib.GetBufferFromObject(Block, FORMAT_STREAM_HEADER, 200, WorkStructStreamHeader)
FileItem = global.BlockDB.OpenDBFile(FILE_NAME_BODY, 1) FileItem = global.BlockDB.OpenDBFile(FILE_NAME_BODY, 1)
@ -361,7 +361,7 @@ export default class CDB extends CCode {
} }
WriteBufHeaderToFile1(BufWrite, BlockNum) { WriteBufHeaderToFile1(BufWrite, BlockNum) {
BlockNum = Math.trunc(BlockNum) BlockNum = Math.trunc(BlockNum)
this.ClearBufMap() this.TruncateBufMap(BlockNum)
var FileItem = global.BlockDB.OpenDBFile(FILE_NAME_HEADER, 1); var FileItem = global.BlockDB.OpenDBFile(FILE_NAME_HEADER, 1);
var Position = BlockNum * global.BLOCK_HEADER_SIZE; var Position = BlockNum * global.BLOCK_HEADER_SIZE;
var written = fs.writeSync(FileItem.fd, BufWrite, 0, BufWrite.length, Position); var written = fs.writeSync(FileItem.fd, BufWrite, 0, BufWrite.length, Position);
@ -510,11 +510,23 @@ export default class CDB extends CCode {
Block.Prepared = true Block.Prepared = true
return this.PrepareBlockFields(Block, BlockNum); return this.PrepareBlockFields(Block, BlockNum);
} }
ClearBufMap() {
this.MapHeader = {}
}
TruncateBufMap(BlockNum) {
if (BlockNum % 10000 === 0)
this.ClearBufMap()
else {
delete this.MapHeader[BlockNum]
}
}
ReadBlockHeaderFromMapDB(BlockNum) { ReadBlockHeaderFromMapDB(BlockNum) {
var Block = this.MapHeader[BlockNum]; var Block = this.MapHeader[BlockNum];
if (!Block) { if (!Block) {
Block = this.ReadBlockHeaderDB(BlockNum) Block = this.ReadBlockHeaderDB(BlockNum)
this.MapHeader[BlockNum] = Block this.MapHeader[BlockNum] = Block
} else {
Block.FromMap = 1
} }
return Block; return Block;
} }
@ -585,9 +597,6 @@ export default class CDB extends CCode {
StartSyncBlockchain(Node?, bSilent?, bCheckPoint?) { StartSyncBlockchain(Node?, bSilent?, bCheckPoint?) {
// defiend in block-loader.ts(CBlock) // defiend in block-loader.ts(CBlock)
} }
ClearBufMap() {
this.MapHeader = {}
}
Close() { Close() {
this.ClearBufMap() this.ClearBufMap()
this.ReadStateTX() this.ReadStateTX()

View File

@ -28,9 +28,9 @@ ContenTypeMap["wav"] = "audio/wav";
ContenTypeMap["mp3"] = "audio/mpeg"; ContenTypeMap["mp3"] = "audio/mpeg";
ContenTypeMap["mp4"] = "video/mp4"; ContenTypeMap["mp4"] = "video/mp4";
ContenTypeMap["ico"] = "image/vnd.microsoft.icon"; ContenTypeMap["ico"] = "image/vnd.microsoft.icon";
ContenTypeMap["jpg"] = "image/jpeg";
ContenTypeMap["png"] = "image/png"; ContenTypeMap["png"] = "image/png";
ContenTypeMap["gif"] = "image/gif"; ContenTypeMap["gif"] = "image/gif";
ContenTypeMap["jpg"] = "image/jpeg";
ContenTypeMap["html"] = "text/html"; ContenTypeMap["html"] = "text/html";
ContenTypeMap["txt"] = "text/plain"; ContenTypeMap["txt"] = "text/plain";
ContenTypeMap["csv"] = "text/csv"; ContenTypeMap["csv"] = "text/csv";
@ -41,7 +41,6 @@ ContenTypeMap["pdf"] = "application/pdf";
ContenTypeMap["exe"] = "application/octet-stream"; ContenTypeMap["exe"] = "application/octet-stream";
ContenTypeMap["msi"] = "application/octet-stream"; ContenTypeMap["msi"] = "application/octet-stream";
ContenTypeMap["woff"] = "application/font-woff"; ContenTypeMap["woff"] = "application/font-woff";
ContenTypeMap[".js"] = "application/javascript";
ContenTypeMap["html"] = "text/html"; ContenTypeMap["html"] = "text/html";
ContenTypeMap["psd"] = "application/octet-stream"; ContenTypeMap["psd"] = "application/octet-stream";
global.HTTPCaller = {}; global.HTTPCaller = {};
@ -1358,7 +1357,11 @@ function SendWebFile(response, name?, StrCookie?, bParsing?) {
var type = name.substr(name.length - 4, 4); var type = name.substr(name.length - 4, 4);
if (type.substr(0, 1) === ".") if (type.substr(0, 1) === ".")
type = type.substr(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 (!fs.existsSync(Path)) {
if (type === "ico") { if (type === "ico") {
response.writeHead(404, { 'Content-Type': 'text/html' }); response.writeHead(404, { 'Content-Type': 'text/html' });
@ -1386,7 +1389,12 @@ function SendWebFile(response, name?, StrCookie?, bParsing?) {
data = GetFileHTMLWithParsing(Path); data = GetFileHTMLWithParsing(Path);
response.end(data); response.end(data);
return; return;
} else
if ("image/jpeg,image/vnd.microsoft.icon,image/svg+xml,image/png,application/javascript,text/css,text/html".indexOf(StrContentType) > - 1) {
response.end(GetFileSimpleBin(Path));
return;
} }
const stream = fs.createReadStream(Path); const stream = fs.createReadStream(Path);
setTimeout(function() { setTimeout(function() {
stream.close(); stream.close();
@ -1477,6 +1485,16 @@ function GetFileSimple(Path) {
return data; 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) { function SaveFileSimple(Path, Str) {
global.SendHTMLMap = {}; global.SendHTMLMap = {};
var Key = "GetFileSimple-" + Path; var Key = "GetFileSimple-" + Path;
@ -1490,6 +1508,13 @@ global.GetFileHTMLFromMarkdown = GetFileHTMLFromMarkdown;
global.GetFileSimple = GetFileSimple; global.GetFileSimple = GetFileSimple;
global.SaveFileSimple = SaveFileSimple; global.SaveFileSimple = SaveFileSimple;
function ReloaSenddBufer() {
global.SendHTMLMap = {};
};
setInterval(ReloaSenddBufer, 60 * 1000);
if (global.DEV_MODE)
setInterval(ReloaSenddBufer, 1 * 1000);
function GetStrTime(now) { function GetStrTime(now) {
if (!now) if (!now)
now = global.GetCurrentTime(0); now = global.GetCurrentTime(0);
@ -1752,6 +1777,7 @@ function GetEventArray(SmartNum, Context) {
return ArrRet; return ArrRet;
}; };
global.HTTPCaller.GetHashRate = function(ArrParams) { global.HTTPCaller.GetHashRate = function(ArrParams) {
var AllReadCount = 0;
var CurBlockNum = global.GetCurrentBlockNumByTime(); var CurBlockNum = global.GetCurrentBlockNumByTime();
var ResArr = []; var ResArr = [];
for (var i = 0; i < ArrParams.length; i++) { for (var i = 0; i < ArrParams.length; i++) {
@ -1774,9 +1800,7 @@ global.HTTPCaller.GetHashRate = function(ArrParams) {
var StepDelta = Math.floor(Delta / Count); var StepDelta = Math.floor(Delta / Count);
if (StepDelta < 1) if (StepDelta < 1)
StepDelta = 1; StepDelta = 1;
var CountAvg = 10; var CountAvg = 3;
if (i === ArrParams.length - 1)
CountAvg = 3;
var StepDeltaAvg = Math.floor(StepDelta / CountAvg); var StepDeltaAvg = Math.floor(StepDelta / CountAvg);
if (StepDeltaAvg < 1) if (StepDeltaAvg < 1)
StepDeltaAvg = 1; StepDeltaAvg = 1;
@ -1791,8 +1815,10 @@ global.HTTPCaller.GetHashRate = function(ArrParams) {
var Sum = 0; var Sum = 0;
var CountSum = 0; var CountSum = 0;
for (var d = 0; d < CountAvg; d++) { for (var d = 0; d < CountAvg; d++) {
var Block = global.SERVER.ReadBlockHeaderDB(Num + d); var Block = global.SERVER.ReadBlockHeaderFromMapDB(Num + d * StepDeltaAvg);
if (Block) { if (Block) {
if (!Block.FromMap)
AllReadCount++;
CountSum++; CountSum++;
Sum += global.GetPowPower(Block.PowHash); Sum += global.GetPowPower(Block.PowHash);
} }