0.1038
parent
93b3f900c4
commit
b40141387e
Binary file not shown.
Binary file not shown.
|
@ -170,8 +170,7 @@ pm2 start run-test.js
|
|||
* Consensus: PoW
|
||||
* Algorithm: Terahash (sha3 + Optimize RAM hashing)
|
||||
* Total suplay: 1 Bln
|
||||
* Reward for block (befor 30-40 mln blocks): 1-20 coins, depends on miner power (one billionth of the remainder of undistributed amount of coins and multiplied by the hundredth part of the square of the logarithm of the miner power)
|
||||
* Reward for block (after 40 mln blocks): <1 coins (one billionth of the remainder of undistributed amount of coins multiplied by constant)
|
||||
* Reward for block (befor 43 mln blocks): 1-20 coins, depends on network power (one billionth of the remainder of undistributed amount of coins and multiplied by the hundredth part of the square of the logarithm of the network power). With a block of 22.5 million, the power for the reward is limited to a constant of 43.
|
||||
* Block size 130 KB
|
||||
* Premine: 5%
|
||||
* Development fund: 1% of the mining amount
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* Telegram: https://t.me/terafoundation
|
||||
*/
|
||||
|
||||
global.UPDATE_CODE_VERSION_NUM = 1038;
|
||||
global.UPDATE_CODE_VERSION_NUM = 1041;
|
||||
global.MIN_CODE_VERSION_NUM = 1020;
|
||||
global.MINING_VERSION_NUM = 3;
|
||||
global.InitParamsArg = InitParamsArg;
|
||||
|
|
|
@ -51,7 +51,6 @@ module.exports = class CRest extends require("./db/block-db")
|
|||
LoopSyncRest()
|
||||
{
|
||||
let Context = this.LoadRestContext;
|
||||
var DeltaTime = Date.now() - Context.StartTimeHistory;
|
||||
switch(Context.Mode)
|
||||
{
|
||||
case 0:
|
||||
|
@ -60,29 +59,23 @@ module.exports = class CRest extends require("./db/block-db")
|
|||
{
|
||||
var Node = ArrNodes[i];
|
||||
if(!Node || Node.SendRestGetHeader)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Node.SendRestGetHeader = 1
|
||||
ToLog("Send rest get headers from " + Context.BlockNumProof + " to " + NodeName(Node), 2)
|
||||
this.SendF(Node, {"Method":"GETBLOCKHEADER", "Data":{Foward:1, BlockNum:Context.BlockNumProof, Hash:[]}, "Context":{F:this.RETBLOCKHEADER_REST.bind(this)},
|
||||
})
|
||||
Context.SendGetHeaderCount++
|
||||
if(Context.SendGetHeaderCount >= COUNT_NODE_PROOF * 2)
|
||||
{
|
||||
Context.Mode++
|
||||
ToLog("Next mode: " + Context.Mode + " Send:" + Context.SendGetHeaderCount, 2)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(Context.ReceiveHeaderCount >= COUNT_NODE_PROOF)
|
||||
{
|
||||
Context.Mode = 2
|
||||
ToLog("Next mode: " + Context.Mode + " Receive:" + Context.ReceiveHeaderCount + "/" + Context.SendGetHeaderCount, 2)
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(DeltaTime > 5000 || Context.ReceiveHeaderCount === Context.SendGetHeaderCount)
|
||||
{
|
||||
if(Context.ReceiveHeaderCount >= COUNT_NODE_PROOF)
|
||||
{
|
||||
Context.Mode++
|
||||
ToLog("Next mode: " + Context.Mode + " Receive:" + Context.ReceiveHeaderCount + "/" + Context.SendGetHeaderCount, 2)
|
||||
}
|
||||
}
|
||||
case 1000:
|
||||
break;
|
||||
case 2:
|
||||
var MapSumPower = {};
|
||||
|
@ -238,7 +231,7 @@ module.exports = class CRest extends require("./db/block-db")
|
|||
{
|
||||
let Task = Context.AccTaskList[i];
|
||||
var Delta = CurTime - Task.Time;
|
||||
if(Delta > 3 * 1000 && !Task.OK)
|
||||
if(Delta > 5 * 1000 && !Task.OK)
|
||||
{
|
||||
var Ret = this.GetNextNode(Task, "", 1);
|
||||
if(Ret.Result)
|
||||
|
@ -405,6 +398,9 @@ module.exports = class CRest extends require("./db/block-db")
|
|||
}
|
||||
RETBLOCKHEADER_REST(Info, CurTime)
|
||||
{
|
||||
if(Info.Node.SendRestGetHeader === 2)
|
||||
return ;
|
||||
Info.Node.SendRestGetHeader = 2
|
||||
var Context = this.LoadRestContext;
|
||||
var BufRead = BufLib.GetReadBuffer(Info.Data);
|
||||
var arr = this.GetBlockArrFromBuffer_Load(BufRead, Info);
|
||||
|
|
|
@ -55,7 +55,7 @@ function GetCurrentRestArr()
|
|||
var r = GetCurrentBlockNumByTime(), t = Math.floor(r / REST_BLOCK_SCALE), e = RestArrMap[t];
|
||||
if(void 0 === e)
|
||||
{
|
||||
RestArrMap = {}, e = GetRestArr(t);
|
||||
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;
|
||||
|
|
|
@ -208,7 +208,6 @@ function GETREST(msg)
|
|||
return ;
|
||||
if(IsZeroArr(Data.AccHash))
|
||||
{
|
||||
ToLog("Get Zero: AccHash");
|
||||
return ;
|
||||
}
|
||||
var BlockNumRest = Data.BlockNum;
|
||||
|
@ -243,8 +242,9 @@ 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));
|
||||
ToLog("Get bad rest acc hash: " + BlockNumRest + " = " + GetHexFromArr(Data.AccHash) + "/" + GetHexFromArr(Tree.Root), 2);
|
||||
ArrRest = [];
|
||||
nResult = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -253,10 +253,6 @@ function GETREST(msg)
|
|||
var RetProof = GetMerkleProof(Tree.LevelsHash, StartAccount, EndAccount);
|
||||
ProofArrL = RetProof.ArrL;
|
||||
ProofArrR = RetProof.ArrR;
|
||||
var ArrM = Tree.LevelsHash[0].slice(StartAccount, EndAccount + 1);
|
||||
var Hash2 = CheckMerkleProof(ProofArrL, ArrM, ProofArrR);
|
||||
if(CompareArr(Tree.Root, Hash2) !== 0)
|
||||
throw ("=========ERROR GETREST HASH PROOF==============");
|
||||
BufLength = 1000 + ArrRest.length * WorkFormatLength;
|
||||
BufLength += ProofArrL.length * 32 + ProofArrR.length * 32 + 32;
|
||||
}
|
||||
|
@ -378,7 +374,7 @@ function GetRestMerkleTree(BlockNumRest,RestIndexArr)
|
|||
var Time2 = process.hrtime(startTime);
|
||||
var deltaTime1 = (Time1[0] * 1000 + Time1[1] / 1e6) / 1000;
|
||||
var deltaTime2 = (Time2[0] * 1000 + Time2[1] / 1e6) / 1000;
|
||||
ToLog("Create delta time: " + deltaTime1 + "/" + deltaTime2 + " s", 2);
|
||||
ToLog("Create delta time: " + deltaTime1 + "/" + deltaTime2 + " s Tree.Root=" + GetHexFromArr(MerkleTree.Root), 2);
|
||||
var MapIndex = {};
|
||||
for(var i = 0; i < RestIndexArr.length; i++)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue