diff --git a/Bin/Light/Tera-light.zip b/Bin/Light/Tera-light.zip index a169e51..9e1efe6 100644 Binary files a/Bin/Light/Tera-light.zip and b/Bin/Light/Tera-light.zip differ diff --git a/Bin/Light/tera_light_setup.exe b/Bin/Light/tera_light_setup.exe index f428207..0f204f3 100644 Binary files a/Bin/Light/tera_light_setup.exe and b/Bin/Light/tera_light_setup.exe differ diff --git a/README.md b/README.md index 2a6ef38..c987324 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/Source/core/constant.js b/Source/core/constant.js index 111f120..7202ce3 100644 --- a/Source/core/constant.js +++ b/Source/core/constant.js @@ -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; diff --git a/Source/core/rest-loader.js b/Source/core/rest-loader.js index 5105db7..7a12495 100644 --- a/Source/core/rest-loader.js +++ b/Source/core/rest-loader.js @@ -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); diff --git a/Source/core/rest_tables.js b/Source/core/rest_tables.js index b1520ac..7df51d3 100644 --- a/Source/core/rest_tables.js +++ b/Source/core/rest_tables.js @@ -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; diff --git a/Source/process/static-process.js b/Source/process/static-process.js index d933922..7383419 100644 --- a/Source/process/static-process.js +++ b/Source/process/static-process.js @@ -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++) {