forked from circlecloud/tera
sync: sync upstream code
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
b05a00f87d
commit
a981ccbcae
@ -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;
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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":"选择",
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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"> </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,9 +668,6 @@
|
||||
</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>
|
||||
</html>
|
||||
|
||||
|
@ -327,7 +327,7 @@ export default class CDB extends CCode {
|
||||
WriteBlockHeaderToFile2(Block) {
|
||||
var BufWrite, FileItem, written;
|
||||
var BlockNum = Math.trunc(Block.BlockNum);
|
||||
this.ClearBufMap()
|
||||
this.TruncateBufMap(BlockNum)
|
||||
Block.VersionDB = global.DB_VERSION
|
||||
BufWrite = global.BufLib.GetBufferFromObject(Block, FORMAT_STREAM_HEADER, 200, WorkStructStreamHeader)
|
||||
FileItem = global.BlockDB.OpenDBFile(FILE_NAME_BODY, 1)
|
||||
@ -361,7 +361,7 @@ export default class CDB extends CCode {
|
||||
}
|
||||
WriteBufHeaderToFile1(BufWrite, BlockNum) {
|
||||
BlockNum = Math.trunc(BlockNum)
|
||||
this.ClearBufMap()
|
||||
this.TruncateBufMap(BlockNum)
|
||||
var FileItem = global.BlockDB.OpenDBFile(FILE_NAME_HEADER, 1);
|
||||
var Position = BlockNum * global.BLOCK_HEADER_SIZE;
|
||||
var written = fs.writeSync(FileItem.fd, BufWrite, 0, BufWrite.length, Position);
|
||||
@ -510,11 +510,23 @@ export default class CDB extends CCode {
|
||||
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];
|
||||
if (!Block) {
|
||||
Block = this.ReadBlockHeaderDB(BlockNum)
|
||||
this.MapHeader[BlockNum] = Block
|
||||
} else {
|
||||
Block.FromMap = 1
|
||||
}
|
||||
return Block;
|
||||
}
|
||||
@ -585,9 +597,6 @@ export default class CDB extends CCode {
|
||||
StartSyncBlockchain(Node?, bSilent?, bCheckPoint?) {
|
||||
// defiend in block-loader.ts(CBlock)
|
||||
}
|
||||
ClearBufMap() {
|
||||
this.MapHeader = {}
|
||||
}
|
||||
Close() {
|
||||
this.ClearBufMap()
|
||||
this.ReadStateTX()
|
||||
|
@ -28,9 +28,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";
|
||||
@ -41,7 +41,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 = {};
|
||||
@ -1358,7 +1357,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") {
|
||||
response.writeHead(404, { 'Content-Type': 'text/html' });
|
||||
@ -1386,7 +1389,12 @@ function SendWebFile(response, name?, StrCookie?, bParsing?) {
|
||||
data = GetFileHTMLWithParsing(Path);
|
||||
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) {
|
||||
response.end(GetFileSimpleBin(Path));
|
||||
return;
|
||||
}
|
||||
|
||||
const stream = fs.createReadStream(Path);
|
||||
setTimeout(function() {
|
||||
stream.close();
|
||||
@ -1477,6 +1485,16 @@ 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 = {};
|
||||
var Key = "GetFileSimple-" + Path;
|
||||
@ -1490,6 +1508,13 @@ 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)
|
||||
now = global.GetCurrentTime(0);
|
||||
@ -1752,6 +1777,7 @@ function GetEventArray(SmartNum, Context) {
|
||||
return ArrRet;
|
||||
};
|
||||
global.HTTPCaller.GetHashRate = function(ArrParams) {
|
||||
var AllReadCount = 0;
|
||||
var CurBlockNum = global.GetCurrentBlockNumByTime();
|
||||
var ResArr = [];
|
||||
for (var i = 0; i < ArrParams.length; i++) {
|
||||
@ -1774,9 +1800,7 @@ global.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;
|
||||
@ -1791,8 +1815,10 @@ global.HTTPCaller.GetHashRate = function(ArrParams) {
|
||||
var Sum = 0;
|
||||
var CountSum = 0;
|
||||
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.FromMap)
|
||||
AllReadCount++;
|
||||
CountSum++;
|
||||
Sum += global.GetPowPower(Block.PowHash);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user