Sat Jul 20 14:20:10 CST 2019 Source Update...
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user