Mon Aug 19 14:00:17 CST 2019 Source Update...
This commit is contained in:
parent
ea0bd38cae
commit
32b99633aa
@ -1991,3 +1991,17 @@ function DoNewSession()
|
||||
window.crypto.getRandomValues(arr);
|
||||
glSession = GetHexFromArr(arr);
|
||||
};
|
||||
|
||||
function GetStrFromDiagrArr(Arr)
|
||||
{
|
||||
var Arr2 = [];
|
||||
for(var i = 0; i < Arr.length; i++)
|
||||
{
|
||||
var obj = {};
|
||||
CopyObjKeys(obj, Arr[i]);
|
||||
if(obj.arr)
|
||||
delete obj.arr;
|
||||
Arr2.push(obj);
|
||||
}
|
||||
return JSON.stringify(Arr2);
|
||||
};
|
||||
|
@ -13,9 +13,9 @@ var MAX_SUM_CENT = 1e9;
|
||||
|
||||
function CHECKSUM(Coin)
|
||||
{
|
||||
if(typeof Coin.SumCOIN !== "number")
|
||||
if(!Coin.SumCOIN)
|
||||
Coin.SumCOIN = 0;
|
||||
if(typeof Coin.SumCENT !== "number")
|
||||
if(!Coin.SumCENT)
|
||||
Coin.SumCENT = 0;
|
||||
};
|
||||
|
||||
@ -117,5 +117,6 @@ if(typeof global === "object")
|
||||
global.ISZERO = ISZERO;
|
||||
global.FLOAT_FROM_COIN = FLOAT_FROM_COIN;
|
||||
global.COIN_FROM_FLOAT = COIN_FROM_FLOAT;
|
||||
global.COIN_FROM_FLOAT2 = COIN_FROM_FLOAT2;
|
||||
global.COIN_FROM_STRING = COIN_FROM_STRING;
|
||||
}
|
||||
|
@ -123,7 +123,8 @@ function SetNetConstJSON()
|
||||
{
|
||||
var Str = JSON.stringify(Data, "", 2);
|
||||
document.getElementById("idDevService").value = Str;
|
||||
var Data = {MaxTrasactionLimit:CONFIG_DATA.MAX_TRANSACTION_LIMIT};
|
||||
var Data = {MaxTrasactionLimit:CONFIG_DATA.MAX_TRANSACTION_LIMIT, ProtocolVer:CONFIG_DATA.PROTOCOL_VER, ProtocolMode:CONFIG_DATA.PROTOCOL_MODE,
|
||||
MaxLevel:CONFIG_DATA.MAX_LEVEL, };
|
||||
var Str = JSON.stringify(Data, "", 2);
|
||||
document.getElementById("idDevService").value = Str;
|
||||
};
|
||||
|
@ -591,8 +591,9 @@
|
||||
//glDebugPath="./dapp-smart/OnlineStore.html";
|
||||
//glDebugPath="./dapp-smart/BTC-coin.html";
|
||||
//glDebugPath="./dapp-smart/static/miner-list.html";
|
||||
//glDebugPath="./dapp-smart/acc-control/RescueMoney2.html";
|
||||
//glDebugPath="./dapp-smart/acc-control/RescueMoney.html";
|
||||
//glDebugPath="./dapp-smart/airdrop/page.html";
|
||||
//{"HTMLBlock":8653023,"HTMLTr":0}
|
||||
//glDebugPath="./dapp-smart/ambassador/page.html";
|
||||
//{"HTMLBlock":2303846,"HTMLTr":0}
|
||||
</script>
|
||||
|
||||
|
@ -475,7 +475,7 @@
|
||||
element2.innerHTML="";
|
||||
|
||||
Item.Delete=1;
|
||||
localStorage["DiagramArr"]=JSON.stringify(DiagramArr);
|
||||
localStorage["DiagramArr"]=GetStrFromDiagrArr(DiagramArr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -492,7 +492,7 @@
|
||||
AddDiagramToArr(DiagramArr,Item);
|
||||
SetHTMLDiagramItem(Item,1100);
|
||||
|
||||
localStorage["DiagramArr"]=JSON.stringify(DiagramArr);
|
||||
localStorage["DiagramArr"]=GetStrFromDiagrArr(DiagramArr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,7 +145,7 @@
|
||||
|
||||
AddDiagramToArr(DiagramArr,Item);
|
||||
|
||||
localStorage["DiagramArr"]=JSON.stringify(DiagramArr)
|
||||
localStorage["DiagramArr"]=GetStrFromDiagrArr(DiagramArr);
|
||||
localStorage["ExternSetDiagramArr"]=1;
|
||||
|
||||
}
|
||||
|
@ -1889,6 +1889,7 @@
|
||||
<th id="GetHexFromArr(Item.TreeHash)" class="hash">Data Hash</th>
|
||||
<th id="GetHexFromArr(Item.PowHash)" class="hash">PowHash</th>
|
||||
<th id="GetHexFromArr(Item.Hash)" class="hash">Block Hash</th>
|
||||
<!--<th id="GetHexFromArr(Item.PrevHash)" class="hash">PrevHash</th>-->
|
||||
<!--<th id="GetHexFromArr(Item.SumHash)" class="hash">SumHash</th>-->
|
||||
<th id="Item.TrDataLen" class="num">Bytes</th>
|
||||
<th id="Item.Power" class="num">Pow</th>
|
||||
|
@ -38,7 +38,7 @@ var FORMAT_DATA_TRANSFER = "{\
|
||||
NoSendTx:uint,\
|
||||
}";
|
||||
const WorkStructSend = {};
|
||||
module.exports = class CConsensus extends require("./block-loader")
|
||||
module.exports = class CConsensus extends require("./block-exchange2")
|
||||
{
|
||||
constructor(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)
|
||||
{
|
||||
@ -72,7 +72,7 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
}, DeltaForStart)
|
||||
}
|
||||
}
|
||||
OnStartSecond()
|
||||
OnStartSecond0()
|
||||
{
|
||||
PrepareStatEverySecond()
|
||||
this.AddStatOnTimer()
|
||||
@ -87,7 +87,6 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
Context.LevelsTransfer = []
|
||||
Context.ErrRun = ""
|
||||
Context.PowTxTree = new RBTree(CompareItemTimePow)
|
||||
Context.PowTicketTree = new RBTree(CompareItemTimePow)
|
||||
Context.bSave = false
|
||||
Context.PrevHash = undefined
|
||||
Context.TreeHash = undefined
|
||||
@ -203,30 +202,6 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
var Res = this.AddTrToBlockQuote(Block, Tr);
|
||||
if(Res === 1)
|
||||
WasNewAdd = 1
|
||||
if(global.USE_CHECK_SENDING && Res > 0)
|
||||
{
|
||||
var Tt = Block.PowTxTree.find(Tr);
|
||||
if(Tt)
|
||||
{
|
||||
if(!Tt.NodesList)
|
||||
Tt.NodesList = []
|
||||
Tt.NodesList.push(Node)
|
||||
Tt.TreeLevel = Transfer.TreeLevel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(var i = 0; i < Data.TicketArray.length; i++)
|
||||
{
|
||||
var Tr = this.AddTicketToBlockQuote(Block, Data.TicketArray[i]);
|
||||
if(Tr)
|
||||
{
|
||||
if(!Tr.NodesList)
|
||||
Tr.NodesList = []
|
||||
Tr.NodesList.push(Node)
|
||||
}
|
||||
}
|
||||
}
|
||||
ADD_TO_STAT_TIME("TRANSFER_MS", startTime)
|
||||
@ -244,12 +219,8 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
Block.TransferNodesCount = 0
|
||||
Block.TransferNodesCount++
|
||||
}
|
||||
DoTransfer()
|
||||
DoTransfer0()
|
||||
{
|
||||
if(glStopNode)
|
||||
return ;
|
||||
if(!CAN_START)
|
||||
return ;
|
||||
var MaxPOWList;
|
||||
var MaxSumList;
|
||||
var start = this.CurrentBlockNum - BLOCK_PROCESSING_LENGTH;
|
||||
@ -263,8 +234,6 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
continue;
|
||||
if(!Block.Active)
|
||||
continue;
|
||||
if(global.USE_TICKET)
|
||||
this.DoJobListTX(Block)
|
||||
if(Block.MLevelSend < 0)
|
||||
{
|
||||
this.CheckEndExchange(Block)
|
||||
@ -280,11 +249,7 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
MaxPOWList = this.GetMaxPOWList()
|
||||
MaxSumList = this.GetMaxSumList()
|
||||
}
|
||||
var ArrT;
|
||||
if(global.USE_TICKET)
|
||||
ArrT = this.GetArrayFromTicketTree(Block)
|
||||
else
|
||||
ArrT = this.GetArrayFromTxTree(Block)
|
||||
var ArrT = this.GetArrayFromTxTree(Block);
|
||||
this.SendDataTransfer(Transfer, ArrT, MaxPOWList, MaxSumList, Block)
|
||||
}
|
||||
Transfer.WasSend = true
|
||||
@ -311,7 +276,6 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
if(Block.MLevelSend === 0)
|
||||
{
|
||||
Block.EndExchangeTime = Date.now()
|
||||
if(!global.USE_TICKET)
|
||||
this.CheckEndExchange(Block)
|
||||
}
|
||||
Block.MLevelSend--
|
||||
@ -322,21 +286,7 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
{
|
||||
if(Block.EndExchange)
|
||||
return ;
|
||||
if(!global.USE_TICKET)
|
||||
{
|
||||
this.CreateTreeHash(Block)
|
||||
return ;
|
||||
}
|
||||
if(!Block.JobListTX || !Block.EndExchangeTime)
|
||||
return ;
|
||||
var CurTime = Date.now();
|
||||
var Delta = CurTime - Block.EndExchangeTime;
|
||||
if(Delta >= TX_DELTA_PROCESS_TIME * 2)
|
||||
{
|
||||
if(global.DoTxLog)
|
||||
ToLog("END:" + Block.BlockNum + " -> CreateTreeHash")
|
||||
this.CreateTreeHash(Block)
|
||||
}
|
||||
}
|
||||
SendDataTransfer(Transfer, ArrT, MaxPOWList, MaxSumList, Block)
|
||||
{
|
||||
@ -368,22 +318,7 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
arrSum.push(elem)
|
||||
}
|
||||
}
|
||||
var Arr;
|
||||
if(global.USE_CHECK_SENDING)
|
||||
Arr = this.FilterArrForSendNode(Block, Item.Node, ArrT, global.USE_TICKET)
|
||||
else
|
||||
Arr = ArrT
|
||||
if(global.USE_LEVEL_WAY)
|
||||
{
|
||||
var Arr2 = [];
|
||||
for(var t = 0; t < Arr.length; t++)
|
||||
{
|
||||
var Tr = Arr[t];
|
||||
if(Tr.TreeLevel !== Transfer.TreeLevel)
|
||||
Arr2.push(Tr)
|
||||
}
|
||||
Arr = Arr2
|
||||
}
|
||||
var Arr = ArrT;
|
||||
if(global.DoTxLog)
|
||||
ToLog("SEND TRANSFER BlockNum:" + Block.BlockNum + " Arr=" + Arr.length + " to " + NodeName(Item.Node))
|
||||
var BufData = this.CreateTransferBuffer(Arr, arrPow, arrSum, Block, Item.Node);
|
||||
@ -393,278 +328,10 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
Block.JobListTX.push({Node:Item.Node, TreeLevel:Item.TreeLevel, Time:Date.now()})
|
||||
}
|
||||
}
|
||||
TRANSFERTX(Info, CurTime)
|
||||
{
|
||||
var Data = this.DataFromF(Info);
|
||||
var Node = Info.Node;
|
||||
var Block = this.GetBlockContext(Data.BlockNum);
|
||||
if(!Block)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if(global.DoTxLog)
|
||||
ToLog("TRANSFERTX BlockNum:" + Block.BlockNum + " Array=" + Data.Array.length + " from " + NodeName(Node))
|
||||
for(var i = 0; i < Data.Array.length; i++)
|
||||
{
|
||||
this.AddTrToBlockQuote(Block, Data.Array[i], 1)
|
||||
}
|
||||
}
|
||||
static
|
||||
TRANSFERTX_F()
|
||||
{
|
||||
return "{BlockNum:uint, Array:[{body:tr}]}";
|
||||
}
|
||||
static
|
||||
GETTRANSFERTX_F()
|
||||
{
|
||||
return "{BlockNum:uint, TicketArray:[{HashTicket:arr10}]}";
|
||||
}
|
||||
GETTRANSFERTX(Info, CurTime)
|
||||
{
|
||||
return ;
|
||||
var Data = this.DataFromF(Info);
|
||||
var Node = Info.Node;
|
||||
var Block = this.GetBlockContext(Data.BlockNum);
|
||||
if(!Block)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
this.SendTrByTickets(Info, Node, Block, Data.TicketArray, 10)
|
||||
}
|
||||
CanSendTest()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
SendTrByTickets(Info, Node, Block, ArrTT, CountTrySend)
|
||||
{
|
||||
if(!Block.PowTxTree)
|
||||
return ;
|
||||
var Arr = [];
|
||||
var bFindTT = 0;
|
||||
var BufLength = 0;
|
||||
for(var i = 0; i < ArrTT.length; i++)
|
||||
{
|
||||
var Tr = ArrTT[i];
|
||||
this.CheckCreateTicketObject(Tr, Block.BlockNum)
|
||||
var Tr0 = Block.PowTxTree.find(Tr);
|
||||
if(Tr0)
|
||||
{
|
||||
if(Tr0.IsTx)
|
||||
{
|
||||
if(this.CanSendTest())
|
||||
Arr.push(Tr0)
|
||||
BufLength += Tr0.body.length
|
||||
if(BufLength > MAX_BLOCK_SIZE)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
bFindTT = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
if(bFindTT && CountTrySend)
|
||||
{
|
||||
let SELF = this;
|
||||
setTimeout(function ()
|
||||
{
|
||||
SELF.SendTrByTickets(Info, Node, Block, ArrTT, CountTrySend - 1)
|
||||
}, 100)
|
||||
return ;
|
||||
}
|
||||
if(!Arr.length)
|
||||
return ;
|
||||
var SendData = {"Method":"RETTRANSFERTX", "Context":Info.Context, "Data":{BlockNum:Block.BlockNum, Array:Arr, }};
|
||||
this.SendF(Node, SendData, global.MAX_BLOCK_SIZE + 1000)
|
||||
}
|
||||
static
|
||||
RETTRANSFERTX_F()
|
||||
{
|
||||
return "{BlockNum:uint,Array:[{body:tr}]}";
|
||||
}
|
||||
RETTRANSFERTX(Info, CurTime)
|
||||
{
|
||||
return ;
|
||||
var Data = this.DataFromF(Info);
|
||||
var Node = Info.Node;
|
||||
Node.TransferBlockNum = Data.BlockNum
|
||||
var Block = this.GetBlockContext(Data.BlockNum);
|
||||
if(!Block || !Block.PowTxTree)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if(global.DoTxLog)
|
||||
ToLog("RETTRANSFERTX BlockNum:" + Block.BlockNum + " Array=" + Data.Array.length + " from " + NodeName(Node))
|
||||
for(var i = 0; i < Data.Array.length; i++)
|
||||
{
|
||||
var Tr = Data.Array[i];
|
||||
this.CheckCreateTransactionObject(Tr)
|
||||
var Tr0 = Block.PowTxTree.find(Tr);
|
||||
if(Tr0)
|
||||
{
|
||||
if(!Tr0.IsTx)
|
||||
{
|
||||
Tr0.IsTx = 1
|
||||
Tr0.body = Tr.body
|
||||
Tr0.HASH = Tr.HASH
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DoJobListTX(Block)
|
||||
{
|
||||
if(Block.EndExchange || !Block.JobListTX || !Block.PowTicketTree)
|
||||
return ;
|
||||
var ArrTx;
|
||||
var CurTime = Date.now();
|
||||
for(var i = 0; i < Block.JobListTX.length; i++)
|
||||
{
|
||||
var JobItem = Block.JobListTX[i];
|
||||
var Delta = CurTime - JobItem.Time;
|
||||
if(!JobItem.WasSend && Delta >= TX_DELTA_PROCESS_TIME)
|
||||
{
|
||||
JobItem.WasSend = 1
|
||||
if(!ArrTx)
|
||||
ArrTx = this.GetArrayFromTxTree(Block)
|
||||
var Arr = this.FilterArrForSendNode(Block, JobItem.Node, ArrTx);
|
||||
if(!Arr.length)
|
||||
return ;
|
||||
if(global.DoTxLog)
|
||||
ToLog("DoJobListTX BlockNum:" + Block.BlockNum + " Arr=" + Arr.length + " to " + NodeName(JobItem.Node))
|
||||
var SendData = {"Method":"TRANSFERTX", "Context":{}, "Data":{BlockNum:Block.BlockNum, Array:Arr, }};
|
||||
this.SendF(JobItem.Node, SendData, global.MAX_BLOCK_SIZE + 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
FindNodeTicket(Block, Tr, Node, bTt)
|
||||
{
|
||||
var Ticket;
|
||||
if(bTt)
|
||||
Ticket = Tr
|
||||
else
|
||||
Ticket = Block.PowTicketTree.find(Tr)
|
||||
if(Ticket && Ticket.NodesList)
|
||||
{
|
||||
for(var n = 0; n < Ticket.NodesList.length; n++)
|
||||
{
|
||||
var NodeItem = Ticket.NodesList[n];
|
||||
if(NodeItem === Node)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
FilterArrForSendNode(Block, Node, ArrTx, bTt)
|
||||
{
|
||||
var Arr = [];
|
||||
for(var t = 0; t < ArrTx.length; t++)
|
||||
{
|
||||
var Tr = ArrTx[t];
|
||||
if(this.FindNodeTicket(Block, Tr, Node, bTt))
|
||||
continue;
|
||||
Arr.push(Tr)
|
||||
}
|
||||
return Arr;
|
||||
}
|
||||
CheckEndExchange00(Block)
|
||||
{
|
||||
if(Block.EndExchange)
|
||||
return ;
|
||||
var CurTime = Date.now();
|
||||
var CanEnd = 1;
|
||||
var bSend = 0;
|
||||
var it = Block.PowTxTree.iterator(), Tr;
|
||||
while((Tr = it.next()) !== null)
|
||||
{
|
||||
if(!Tr.IsTx)
|
||||
{
|
||||
if(!Tr.LastProcessTime)
|
||||
throw "!Tr.LastProcessTime";
|
||||
var Delta = CurTime - Tr.LastProcessTime;
|
||||
if(Delta < TX_PROCESS_TIME * 10)
|
||||
{
|
||||
bSend = 1
|
||||
CanEnd = 0
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
var Stop = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(CanEnd)
|
||||
{
|
||||
if(global.DoTxLog)
|
||||
ToLog("END:" + Block.BlockNum + " -> CreateTreeHash")
|
||||
this.CreateTreeHash(Block)
|
||||
}
|
||||
else
|
||||
if(bSend)
|
||||
{
|
||||
this.CheckTxExchange(Block, bSend)
|
||||
}
|
||||
}
|
||||
CheckTxExchange(Block)
|
||||
{
|
||||
return ;
|
||||
if(Block.EndExchange)
|
||||
return ;
|
||||
if(!Block.PowTxTree)
|
||||
return ;
|
||||
var CurTime = Date.now();
|
||||
var ArrNodesArr = [];
|
||||
var it = Block.PowTxTree.iterator(), Tr;
|
||||
while((Tr = it.next()) !== null)
|
||||
{
|
||||
if(!Tr.IsTx)
|
||||
{
|
||||
if(!Tr.LastProcessTime)
|
||||
throw "!Tr.LastProcessTime";
|
||||
var Delta = CurTime - Tr.LastProcessTime;
|
||||
if(Delta >= TX_PROCESS_TIME)
|
||||
{
|
||||
for(var i = 0; i < Tr.Nodes.length; i++)
|
||||
{
|
||||
var TrNode = Tr.Nodes[i];
|
||||
var LocDelta = CurTime - TrNode.Time;
|
||||
if(!TrNode.WasSend && LocDelta >= TX_PROCESS_TIME)
|
||||
{
|
||||
var FindArr = undefined;
|
||||
for(var n = 0; n < ArrNodesArr.length; n++)
|
||||
{
|
||||
var ElArr = ArrNodesArr[n];
|
||||
if(ElArr.Node === TrNode.Node)
|
||||
{
|
||||
FindArr = ElArr
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!FindArr)
|
||||
{
|
||||
FindArr = {Node:TrNode.Node, Arr:[]}
|
||||
ArrNodesArr.push(FindArr)
|
||||
}
|
||||
Tr.LastProcessTime = CurTime
|
||||
TrNode.WasSend = 1
|
||||
FindArr.Arr.push(Tr)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(var n = 0; n < ArrNodesArr.length; n++)
|
||||
{
|
||||
var ElArr = ArrNodesArr[n];
|
||||
if(global.DoTxLog)
|
||||
ToLog("CheckTxExchange BlockNum:" + Block.BlockNum + " Array=" + ElArr.Arr.length + " to " + NodeName(ElArr.Node))
|
||||
var SendData = {"Method":"GETTRANSFERTX", "Context":{}, "Data":{BlockNum:Block.BlockNum, TicketArray:ElArr.Arr, }};
|
||||
this.SendF(ElArr.Node, SendData, ElArr.Arr.length * global.TR_TICKET_HASH_LENGTH + 1000)
|
||||
}
|
||||
}
|
||||
GetMaxSumListFromID(Node, MaxSumID, BlockList)
|
||||
{
|
||||
var Str0 = "GETBL:" + Node.id;
|
||||
@ -719,19 +386,9 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
}
|
||||
MaxSumID.push({BlockNum:elem0.BlockNum, SumHash:elem0.SumHash, SumListID:ArrID})
|
||||
}
|
||||
var ArrTt, ArrTx;
|
||||
if(global.USE_TICKET)
|
||||
{
|
||||
ArrTt = ArrT
|
||||
ArrTx = []
|
||||
}
|
||||
else
|
||||
{
|
||||
ArrTt = []
|
||||
ArrTx = ArrT
|
||||
}
|
||||
var ArrTx = ArrT;
|
||||
Data = {"Version":5, "BlockNum":Block.BlockNum, "Reserv1":0, "MaxPOW":MaxPOWList, "Reserv2":0, "BaseBlockNum":this.CurrentBlockNum - Block.BlockNum,
|
||||
"MaxSumID":MaxSumID, "BlockList":BlockList, "TicketArray":ArrTt, "TxArray":ArrTx, "NoSendTx":Node.NoSendTx, }
|
||||
"MaxSumID":MaxSumID, "BlockList":BlockList, "TicketArray":[], "TxArray":ArrTx, "NoSendTx":Node.NoSendTx, }
|
||||
var BufWrite = BufLib.GetBufferFromObject(Data, FORMAT_DATA_TRANSFER, MAX_BLOCK_SIZE + 30000, WorkStructSend);
|
||||
return BufWrite;
|
||||
}
|
||||
@ -1003,18 +660,6 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
GetArrayFromTicketTree(Block)
|
||||
{
|
||||
if(!Block.PowTicketTree)
|
||||
return [];
|
||||
var arr = [];
|
||||
var it = Block.PowTicketTree.iterator(), Item;
|
||||
while((Item = it.next()) !== null)
|
||||
{
|
||||
arr.push(Item)
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
CheckPrioritetTx(Tr)
|
||||
{
|
||||
if(Tr.Prioritet === undefined)
|
||||
@ -1054,20 +699,6 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
AddTicketToBlockQuote(Block, Tr)
|
||||
{
|
||||
if(Block.PowTicketTree)
|
||||
{
|
||||
var Res = this.IsValidTicket(Tr, Block.BlockNum);
|
||||
if(Res >= 1)
|
||||
{
|
||||
Res = this.AddToQuote(Block.PowTicketTree, Tr)
|
||||
if(Res)
|
||||
return Block.PowTicketTree.find(Tr);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
AddTrToBlockQuote(Block, Tr, bTTAdd)
|
||||
{
|
||||
if(Block.PowTxTree)
|
||||
@ -1075,12 +706,6 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
var Res = this.IsValidTransaction(Tr, Block.BlockNum);
|
||||
if(Res >= 1)
|
||||
{
|
||||
if(bTTAdd)
|
||||
{
|
||||
Res = this.AddToQuote(Block.PowTicketTree, Tr)
|
||||
if(Res <= 0)
|
||||
return Res;
|
||||
}
|
||||
Res = this.AddToQuote(Block.PowTxTree, Tr)
|
||||
}
|
||||
return Res;
|
||||
|
146
Source/core/block-exchange2.js
Normal file
146
Source/core/block-exchange2.js
Normal file
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* @project: TERA
|
||||
* @version: Development (beta)
|
||||
* @license: MIT (not for evil)
|
||||
* @copyright: Yuriy Ivanov (Vtools) 2017-2019 [progr76@gmail.com]
|
||||
* Web: https://terafoundation.org
|
||||
* Twitter: https://twitter.com/terafoundation
|
||||
* Telegram: https://t.me/terafoundation
|
||||
*/
|
||||
|
||||
const OBJECT_FORMAT_TRANSFER2 = {Version:"uint16", TransferTx:[{BlockNum:"uint", TxArray:[{body:"tr"}]}], TransferPOW:[{BlockNum:"uint",
|
||||
Hash:[{SeqHash:"hash", AddrHash:"hash"}]}], Slots:{BlockNum:"uint", State:[{DeltaHeaderNum:"uint16", DeltaBlockNum:"uint16"}],
|
||||
Hash:[{Num:"byte", SeqHash:"hash", AddrHash:"hash"}], HistoryHeads:[{Num:"byte", BlockNum:"uint", SeqHash:"hash", AddrHash:"hash"}],
|
||||
HistoryBits:[{Num:"byte", BlockNum:"uint", Bits:["byte"]}], HistoryTxs:[{BlockNum:"uint", TxArray:[{body:"tr"}]}], }};
|
||||
var FORMAT_DATA_TRANSFER2 = BufLib.GetFormatFromObject(OBJECT_FORMAT_TRANSFER2);
|
||||
module.exports = class CConsensus2 extends require("./block-loader")
|
||||
{
|
||||
constructor(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)
|
||||
{
|
||||
super(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)
|
||||
}
|
||||
OnStartSecond()
|
||||
{
|
||||
PrepareStatEverySecond()
|
||||
this.AddStatOnTimer()
|
||||
if(global.PROTOCOL_VER === 2)
|
||||
{
|
||||
this.DoBlockChain()
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DoBlockChain()
|
||||
}
|
||||
}
|
||||
DoTransfer()
|
||||
{
|
||||
if(glStopNode)
|
||||
return ;
|
||||
if(!CAN_START)
|
||||
return ;
|
||||
if(global.PROTOCOL_VER === 2)
|
||||
{
|
||||
this.DoTransfer2()
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DoTransfer0()
|
||||
}
|
||||
}
|
||||
DoBlockChain2()
|
||||
{
|
||||
if(glStopNode)
|
||||
return ;
|
||||
if(!CAN_START)
|
||||
return ;
|
||||
this.StartConsensus()
|
||||
var CURRENTBLOCKNUM = this.CurrentBlockNum;
|
||||
if(GrayConnect())
|
||||
{
|
||||
if(!this.LoadHistoryMode)
|
||||
this.StartSyncBlockchain(undefined, 1)
|
||||
return ;
|
||||
}
|
||||
if(this.LoadHistoryMode)
|
||||
return ;
|
||||
var bWasSave = false;
|
||||
var LoadBlockNum;
|
||||
var LoadHash;
|
||||
var start_save = CURRENTBLOCKNUM + TIME_START_SAVE;
|
||||
for(var BlockNum = CURRENTBLOCKNUM - BLOCK_PROCESSING_LENGTH2; BlockNum > BLOCK_PROCESSING_LENGTH2 && BlockNum < CURRENTBLOCKNUM; BlockNum++)
|
||||
{
|
||||
var Block = this.GetBlock(BlockNum);
|
||||
}
|
||||
}
|
||||
TRANSFER2(Info, CurTime)
|
||||
{
|
||||
}
|
||||
static
|
||||
TRANSFER2_F()
|
||||
{
|
||||
return FORMAT_DATA_TRANSFER2;
|
||||
}
|
||||
DoTransfer2()
|
||||
{
|
||||
var MaxPOWList;
|
||||
var MaxSumList;
|
||||
var start = this.CurrentBlockNum - BLOCK_PROCESSING_LENGTH;
|
||||
var finish = this.GetLastCorrectBlockNum();
|
||||
for(var b = start; b <= finish; b++)
|
||||
{
|
||||
var Block = this.GetBlock(b);
|
||||
if(!Block)
|
||||
continue;
|
||||
if(Block.StartLevel === undefined || Block.MLevelSend === undefined)
|
||||
continue;
|
||||
if(!Block.Active)
|
||||
continue;
|
||||
if(Block.MLevelSend < 0)
|
||||
{
|
||||
this.CheckEndExchange(Block)
|
||||
continue;
|
||||
}
|
||||
if(Block.EndExchange)
|
||||
continue;
|
||||
var Transfer = Block.LevelsTransfer[Block.MLevelSend];
|
||||
if(!Transfer.WasSend)
|
||||
{
|
||||
if(!MaxPOWList)
|
||||
{
|
||||
MaxPOWList = this.GetMaxPOWList()
|
||||
MaxSumList = this.GetMaxSumList()
|
||||
}
|
||||
var ArrT = this.GetArrayFromTxTree(Block);
|
||||
this.SendDataTransfer(Transfer, ArrT, MaxPOWList, MaxSumList, Block)
|
||||
}
|
||||
Transfer.WasSend = true
|
||||
var bNext = Transfer.WasGet;
|
||||
if(!bNext)
|
||||
{
|
||||
var CurTimeNum = GetCurrentTime(Block.DELTA_CURRENT_TIME) - 0;
|
||||
var DeltaTime = CurTimeNum - Block.StartTimeNum;
|
||||
if(DeltaTime > Transfer.MustDeltaTime)
|
||||
{
|
||||
bNext = true
|
||||
Block.ErrRun = "" + Transfer.LocalLevel + " " + Block.ErrRun
|
||||
for(var Addr in Transfer.TransferNodes)
|
||||
{
|
||||
var Item = Transfer.TransferNodes[Addr];
|
||||
ADD_TO_STAT("TRANSFER_TIME_OUT")
|
||||
this.AddCheckErrCount(Item.Node, 1, "TRANSFER_TIME_OUT")
|
||||
}
|
||||
ADD_TO_STAT("TimeOutLevel")
|
||||
}
|
||||
}
|
||||
if(bNext)
|
||||
{
|
||||
if(Block.MLevelSend === 0)
|
||||
{
|
||||
Block.EndExchangeTime = Date.now()
|
||||
this.CheckEndExchange(Block)
|
||||
}
|
||||
Block.MLevelSend--
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
@ -1137,7 +1137,7 @@ module.exports = class CBlock extends require("./rest-loader.js")
|
||||
this.SetBlockNOSendToNode(Block, Info.Node, "BAD CMP TreeHash")
|
||||
return ;
|
||||
}
|
||||
if(arrContent.length > 0 && Data.BlockNum % PERIOD_ACCOUNT_HASH === 0)
|
||||
if(Data.BlockNum >= START_BAD_ACCOUNT_CONTROL && arrContent.length > 0 && Data.BlockNum % PERIOD_ACCOUNT_HASH === 0)
|
||||
{
|
||||
var TR = arrContent[0];
|
||||
if(TR[0] === TYPE_TRANSACTION_ACC_HASH)
|
||||
|
@ -8,14 +8,16 @@
|
||||
* Telegram: https://t.me/terafoundation
|
||||
*/
|
||||
|
||||
module.exports.GetNewBuffer = GetNewBuffer;
|
||||
module.exports.GetReadBuffer = GetReadBuffer;
|
||||
module.exports.alloc = GetNewBuffer;
|
||||
module.exports.from = GetReadBuffer;
|
||||
module.exports.Write = Write;
|
||||
module.exports.Read = Read;
|
||||
module.exports.GetObjectFromBuffer = GetObjectFromBuffer;
|
||||
module.exports.GetBufferFromObject = GetBufferFromObject;
|
||||
var exports = module.exports;
|
||||
exports.GetNewBuffer = GetNewBuffer;
|
||||
exports.GetReadBuffer = GetReadBuffer;
|
||||
exports.alloc = GetNewBuffer;
|
||||
exports.from = GetReadBuffer;
|
||||
exports.Write = Write;
|
||||
exports.Read = Read;
|
||||
exports.GetObjectFromBuffer = GetObjectFromBuffer;
|
||||
exports.GetBufferFromObject = GetBufferFromObject;
|
||||
exports.GetFormatFromObject = GetFormatFromObject;
|
||||
|
||||
function Write(buf,data,StringFormat,ParamValue,WorkStruct)
|
||||
{
|
||||
@ -570,6 +572,47 @@ function GetBufferFromObject(data,format,size,WorkStruct,bNotSlice)
|
||||
return buf;
|
||||
};
|
||||
|
||||
function GetFormatFromObject(Obj)
|
||||
{
|
||||
var Str;
|
||||
var Type = typeof Obj;
|
||||
LType:
|
||||
switch(Type)
|
||||
{
|
||||
case "object":
|
||||
var bFirst = 1;
|
||||
for(var key in Obj)
|
||||
{
|
||||
if(!bFirst)
|
||||
Str += ",";
|
||||
else
|
||||
{
|
||||
if(key === "0")
|
||||
{
|
||||
Str = "[" + GetFormatFromObject(Obj[0]) + "]";
|
||||
break LType;
|
||||
}
|
||||
Str = "{";
|
||||
bFirst = 0;
|
||||
}
|
||||
Str += key + ":" + GetFormatFromObject(Obj[key]);
|
||||
}
|
||||
Str += "}";
|
||||
break;
|
||||
case "array":
|
||||
{
|
||||
if(Obj.length === 0)
|
||||
throw "Error format array length";
|
||||
Str = "[" + GetFormatFromObject(Obj[0]) + "]";
|
||||
break;
|
||||
}
|
||||
case "string":
|
||||
Str = Obj;
|
||||
break;
|
||||
}
|
||||
return Str;
|
||||
};
|
||||
|
||||
function GetMiddleString(Str)
|
||||
{
|
||||
return Str.substr(1, Str.length - 2);
|
||||
|
@ -16,8 +16,9 @@ global.CHECK_DELTA_TIME = {Num:0, bUse:0, StartBlockNum:0, EndBlockNum:0, bAddTi
|
||||
global.CHECK_POINT = {BlockNum:0, Hash:[], Sign:[]};
|
||||
global.CODE_VERSION = {BlockNum:0, addrArr:[], LevelUpdate:0, BlockPeriod:0, VersionNum:UPDATE_CODE_VERSION_NUM, Hash:[], Sign:[],
|
||||
StartLoadVersionNum:0};
|
||||
global.NET_CONSTANT = {Num:0, BlockNum:0, MaxTrasactionLimit:MAX_TRANSACTION_LIMIT, Reserv1:0, Reserv2:0, Reserv3:0, Reserv4:0,
|
||||
Reserv5:0, Hash:[], Sign:[]};
|
||||
global.NET_CONSTANT = {Num:0, BlockNum:0, MaxTrasactionLimit:MAX_TRANSACTION_LIMIT, ProtocolVer:global.PROTOCOL_VER, ProtocolMode:global.PROTOCOL_MODE,
|
||||
MaxLevel:global.MAX_LEVEL, Reserv1:[], Reserv2:0, Reserv3:0, Reserv4:0, Reserv5:0, Hash:[], Sign:[]};
|
||||
const FORMAT_NET_CONSTANT = "Num:uint,BlockNum:uint,MaxTrasactionLimit:uint,ProtocolVer:byte,ProtocolMode:byte,MaxLevel:byte, Reserv1:arr3, Reserv2:uint,Reserv3:uint,Reserv4:uint,Reserv5:uint";
|
||||
global.START_LOAD_CODE = {};
|
||||
const MAX_PERIOD_GETNODES = 120 * 1000;
|
||||
global.MIN_PERIOD_PING = 4 * 1000;
|
||||
@ -26,7 +27,7 @@ global.MAX_PING_FOR_CONNECT = 400;
|
||||
var MAX_TIME_CORRECT = 3 * 3600 * 1000;
|
||||
global.MAX_WAIT_PERIOD_FOR_HOT = 4 * CONSENSUS_PERIOD_TIME;
|
||||
const PERIOD_FOR_START_CHECK_TIME = 300;
|
||||
module.exports = class CConnect extends require("./transfer-msg")
|
||||
module.exports = class CConnect extends require("./connect2")
|
||||
{
|
||||
constructor(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)
|
||||
{
|
||||
@ -219,7 +220,7 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
CheckPoint:CHECK_POINT, Reserv3:[], Key:this.KeyToNode, Name:this.NameToNode, TrafficFree:this.SendTrafficFree, AccountBlockNum:BlockNumHash,
|
||||
AccountsHash:AccountsHash, MemoryUsage:Math.trunc(process.memoryUsage().heapTotal / 1024 / 1024), CheckDeltaTime:CHECK_DELTA_TIME,
|
||||
CodeVersion:CODE_VERSION, IsAddrList:global.ADDRLIST_MODE, CheckPointHashDB:CheckPointHashDB, PortWeb:HTTP_HOSTING_PORT, HashDB:HashDB,
|
||||
StopGetBlock:StopGetBlock, NetConstant:NET_CONSTANT, };
|
||||
StopGetBlock:StopGetBlock, NetConstant:NET_CONSTANT, LevelsBit:this.GetBitsByLevel(), };
|
||||
return Ret;
|
||||
}
|
||||
static
|
||||
@ -251,7 +252,8 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
PortWeb:uint16,\
|
||||
HashDB:hash,\
|
||||
StopGetBlock:uint,\
|
||||
NetConstant:{Num:uint,BlockNum:uint,MaxTrasactionLimit:uint,Reserv1:uint,Reserv2:uint,Reserv3:uint,Reserv4:uint,Reserv5:uint,Sign:arr64},\
|
||||
NetConstant:{" + FORMAT_NET_CONSTANT + ",Sign:arr64},\
|
||||
LevelsBit:uint32,\
|
||||
}";
|
||||
}
|
||||
static
|
||||
@ -287,6 +289,7 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
Node.NextConnectDelta = 1000
|
||||
Node.StopGetBlock = Data.StopGetBlock
|
||||
Node.portweb = Data.PortWeb
|
||||
Node.LevelsBit = Data.LevelsBit
|
||||
if(bCheckPoint)
|
||||
{
|
||||
this.CheckCheckPoint(Data, Info.Node)
|
||||
@ -451,6 +454,10 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
DoNetConst()
|
||||
{
|
||||
global.MAX_TRANSACTION_LIMIT = NET_CONSTANT.MaxTrasactionLimit
|
||||
global.PROTOCOL_VER = NET_CONSTANT.ProtocolVer
|
||||
global.PROTOCOL_MODE = NET_CONSTANT.ProtocolMode
|
||||
global.MAX_LEVEL = NET_CONSTANT.MaxLevel
|
||||
this.OnSetProtocolMode()
|
||||
}
|
||||
CheckCodeVersion(Data, Node)
|
||||
{
|
||||
@ -523,8 +530,7 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
}
|
||||
GetSignCheckNetConstant(Data)
|
||||
{
|
||||
var Buf = BufLib.GetBufferFromObject(Data, "{Num:uint,BlockNum:uint,MaxTrasactionLimit:uint,Reserv1:uint,Reserv2:uint,Reserv3:uint,Reserv4:uint,Reserv5:uint}",
|
||||
1000, {});
|
||||
var Buf = BufLib.GetBufferFromObject(Data, "{" + FORMAT_NET_CONSTANT + "}", 1000, {});
|
||||
return shaarr(Buf);
|
||||
}
|
||||
GetSignCheckDeltaTime(Data)
|
||||
@ -588,8 +594,9 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
port:uint16,\
|
||||
portweb:uint16,\
|
||||
LastTime:uint,\
|
||||
DeltaTime:uint,\
|
||||
Reserv:arr8\
|
||||
Reserv0:uint,\
|
||||
LevelsBit:uint32,\
|
||||
Reserv:arr4\
|
||||
}\
|
||||
],\
|
||||
IsAddrList:byte}";
|
||||
@ -663,7 +670,7 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
{
|
||||
var ret = [];
|
||||
var Value = {addrStr:this.addrStr, ip:this.ip, port:this.port, LastTime:0, DeltaTime:0, Hot:true, BlockProcessCount:0, portweb:HTTP_HOSTING_PORT,
|
||||
};
|
||||
LevelsBit:this.GetBitsByLevel(), };
|
||||
if(bGetAddrArr)
|
||||
Value.addrArr = GetArrFromHex(Value.addrStr)
|
||||
ret.push(Value)
|
||||
@ -705,7 +712,8 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
if(!GrayConnect() && Item.LastTime - 0 < CurTime - MaxDeltaTime)
|
||||
continue;
|
||||
var Value = {addrStr:Item.addrStr, ip:Item.ip, port:Item.port, FirstTime:Item.FirstTime, FirstTimeStr:Item.FirstTimeStr, LastTime:Item.LastTime - 0,
|
||||
DeltaTime:Item.DeltaTime, Hot:Item.Hot, BlockProcessCount:Item.BlockProcessCount, Name:Item.Name, portweb:Item.portweb, };
|
||||
DeltaTime:Item.DeltaTime, Hot:Item.Hot, BlockProcessCount:Item.BlockProcessCount, Name:Item.Name, portweb:Item.portweb, LevelsBit:Item.LevelsBit,
|
||||
};
|
||||
if(bGetAddrArr)
|
||||
Value.addrArr = GetArrFromHex(Value.addrStr)
|
||||
ret.push(Value)
|
||||
@ -753,10 +761,13 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
Node.Name = Item.Name
|
||||
if(Item.portweb)
|
||||
Node.portweb = Item.portweb
|
||||
if(Node.LastTime < Item.LastTime && Item.LastTime <= GetCurrentTime() - 0)
|
||||
Node.LevelsBit = Item.LevelsBit
|
||||
return Node;
|
||||
}
|
||||
NodesArrSort()
|
||||
{
|
||||
PrepareBlockProcessSort(this.NodesArr)
|
||||
this.NodesArr.sort(SortNodeBlockProcessCount)
|
||||
if((GrayConnect() || !this.LoadHistoryMode) && Date.now() - this.StartTime > 120 * 1000)
|
||||
{
|
||||
@ -768,15 +779,18 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
LoadNodesFromFile()
|
||||
{
|
||||
var arr = LoadParams(GetDataPath("nodes.lst"), []);
|
||||
PrepareBlockProcessSort(arr)
|
||||
arr.sort(SortNodeBlockProcessCount)
|
||||
for(var i = 0; i < arr.length; i++)
|
||||
{
|
||||
if(arr[i].LastTime)
|
||||
var Item = arr[i];
|
||||
if(Item.LastTime)
|
||||
{
|
||||
if(typeof arr[i].LastTime === "string")
|
||||
arr[i].LastTime = 0
|
||||
if(typeof Item.LastTime === "string")
|
||||
Item.LastTime = 0
|
||||
}
|
||||
this.AddToArrNodes(arr[i], true)
|
||||
Item.LevelsBit = 0
|
||||
this.AddToArrNodes(Item, true)
|
||||
}
|
||||
}
|
||||
GetLevelEnum(Node)
|
||||
@ -800,6 +814,7 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
}
|
||||
if(!bWas)
|
||||
arr.push(Node)
|
||||
PrepareBlockProcessSort(arr)
|
||||
arr.sort(SortNodeBlockProcessCount)
|
||||
for(var n = 0; n < arr.length; n++)
|
||||
{
|
||||
@ -924,11 +939,9 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
CheckDisconnectHot(Level)
|
||||
{
|
||||
var CurTime = GetCurrentTime() - 0;
|
||||
var MaxCountChilds;
|
||||
if(Level < 3)
|
||||
var MaxCountChilds = this.GetMaxConnectChilds();
|
||||
if(Level < 3 && MaxCountChilds > 4)
|
||||
MaxCountChilds = 4
|
||||
else
|
||||
MaxCountChilds = MAX_CONNECT_CHILD
|
||||
var arr = this.LevelNodes[Level];
|
||||
if(arr)
|
||||
{
|
||||
@ -944,6 +957,7 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
}
|
||||
}
|
||||
}
|
||||
PrepareBlockProcessSort(arr)
|
||||
arr.sort(SortNodeBlockProcessCount)
|
||||
var ChildCount = arr.length;
|
||||
for(var n = arr.length - 1; n >= MIN_CONNECT_CHILD; n--)
|
||||
@ -1416,7 +1430,7 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
ToLog("DETECT GRAY MODE")
|
||||
if(!global.NET_WORK_MODE)
|
||||
{
|
||||
global.NET_WORK_MODE = {ip:"", port:"30000"}
|
||||
global.NET_WORK_MODE = {ip:"", port:global.START_PORT_NUMBER}
|
||||
}
|
||||
global.NET_WORK_MODE.UseDirectIP = 0
|
||||
SAVE_CONST()
|
||||
@ -1427,7 +1441,14 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
var CountNodes = this.ActualNodes.size;
|
||||
if(CountNodes && !global.NET_WORK_MODE)
|
||||
{
|
||||
global.NET_WORK_MODE = {ip:"", port:"30000", NOT_RUN:0}
|
||||
if(global.LOCAL_RUN)
|
||||
{
|
||||
global.NET_WORK_MODE = {ip:global.LISTEN_IP, port:global.START_PORT_NUMBER, NOT_RUN:0}
|
||||
}
|
||||
else
|
||||
{
|
||||
global.NET_WORK_MODE = {ip:"", port:global.START_PORT_NUMBER, NOT_RUN:0}
|
||||
}
|
||||
global.NET_WORK_MODE.UseDirectIP = 1
|
||||
SAVE_CONST()
|
||||
}
|
||||
@ -1442,6 +1463,7 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
var MustCount = GetGrayServerConnections();
|
||||
if(this.ActualNodes.size < MustCount)
|
||||
{
|
||||
PrepareBlockProcessSort(this.NodesArr)
|
||||
this.NodesArr.sort(SortNodeBlockProcessCountGray)
|
||||
var WasDoConnect = 0;
|
||||
var arr = this.NodesArr;
|
||||
@ -1477,6 +1499,7 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
var arr = ArrTree[Level];
|
||||
if(!arr)
|
||||
continue;
|
||||
PrepareBlockProcessSort(arr)
|
||||
arr.sort(SortNodeBlockProcessCount)
|
||||
var WasDoConnect = 0;
|
||||
var WasDoHot = 0;
|
||||
@ -1564,10 +1587,28 @@ module.exports = class CConnect extends require("./transfer-msg")
|
||||
}
|
||||
};
|
||||
|
||||
function PrepareBlockProcessSort(Arr)
|
||||
{
|
||||
for(var i = 0; i < Arr.length; i++)
|
||||
{
|
||||
var Item = Arr[i];
|
||||
var BlockProcessCount = Item.BlockProcessCount;
|
||||
if(BlockProcessCount < 0)
|
||||
Item.BlockProcessCountLg = - 1;
|
||||
else
|
||||
if(BlockProcessCount === 0)
|
||||
Item.BlockProcessCountLg = 0;
|
||||
else
|
||||
Item.BlockProcessCountLg = 1 + Math.floor(Math.log10(BlockProcessCount));
|
||||
}
|
||||
};
|
||||
|
||||
function SortNodeBlockProcessCount(a,b)
|
||||
{
|
||||
if(b.BlockProcessCount !== a.BlockProcessCount)
|
||||
return b.BlockProcessCount - a.BlockProcessCount;
|
||||
var BlockProcessCount1 = a.BlockProcessCountLg;
|
||||
var BlockProcessCount2 = b.BlockProcessCountLg;
|
||||
if(BlockProcessCount2 !== BlockProcessCount1)
|
||||
return BlockProcessCount2 - BlockProcessCount1;
|
||||
if(a.DeltaTime !== b.DeltaTime)
|
||||
return a.DeltaTime - b.DeltaTime;
|
||||
return a.id - b.id;
|
||||
@ -1577,11 +1618,7 @@ function SortNodeBlockProcessCountGray(a,b)
|
||||
{
|
||||
if(a.StartFindList !== b.StartFindList)
|
||||
return a.StartFindList - b.StartFindList;
|
||||
if(b.BlockProcessCount !== a.BlockProcessCount)
|
||||
return b.BlockProcessCount - a.BlockProcessCount;
|
||||
if(a.DeltaTime !== b.DeltaTime)
|
||||
return a.DeltaTime - b.DeltaTime;
|
||||
return a.id - b.id;
|
||||
return SortNodeBlockProcessCount(a, b);
|
||||
};
|
||||
|
||||
function GetGrayServerConnections()
|
||||
@ -1592,4 +1629,3 @@ function GetGrayServerConnections()
|
||||
return Count;
|
||||
};
|
||||
global.GetGrayServerConnections = GetGrayServerConnections;
|
||||
global.SortNodeBlockProcessCount = SortNodeBlockProcessCount;
|
||||
|
51
Source/core/connect2.js
Normal file
51
Source/core/connect2.js
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* @project: TERA
|
||||
* @version: Development (beta)
|
||||
* @license: MIT (not for evil)
|
||||
* @copyright: Yuriy Ivanov (Vtools) 2017-2019 [progr76@gmail.com]
|
||||
* Web: https://terafoundation.org
|
||||
* Twitter: https://twitter.com/terafoundation
|
||||
* Telegram: https://t.me/terafoundation
|
||||
*/
|
||||
|
||||
module.exports = class CConnect2 extends require("./transfer-msg")
|
||||
{
|
||||
constructor(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)
|
||||
{
|
||||
super(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)
|
||||
}
|
||||
GetBitsByLevel()
|
||||
{
|
||||
var Maska = 0;
|
||||
for(var i = 0; i < this.LevelNodes.length; i++)
|
||||
{
|
||||
var arr = this.LevelNodes[i];
|
||||
if(arr && arr.length)
|
||||
Maska |= 1 << i
|
||||
}
|
||||
return Maska;
|
||||
}
|
||||
OnSetProtocolMode()
|
||||
{
|
||||
if(global.PROTOCOL_VER === 2)
|
||||
{
|
||||
global.MIN_CONNECT_CHILD = 1
|
||||
global.MAX_CONNECT_CHILD = 1
|
||||
}
|
||||
else
|
||||
{
|
||||
global.MIN_CONNECT_CHILD = 2
|
||||
global.MAX_CONNECT_CHILD = 7
|
||||
}
|
||||
}
|
||||
GetMaxConnectChilds()
|
||||
{
|
||||
var Count = global.MAX_CONNECT_CHILD;
|
||||
if(global.PROTOCOL_VER === 2)
|
||||
{
|
||||
if(this.NodesArr.length <= MIN_NODES_FOR_DOUBLE_MODE)
|
||||
Count++
|
||||
}
|
||||
return Count;
|
||||
}
|
||||
};
|
@ -8,7 +8,7 @@
|
||||
* Telegram: https://t.me/terafoundation
|
||||
*/
|
||||
|
||||
global.UPDATE_CODE_VERSION_NUM = 1171;
|
||||
global.UPDATE_CODE_VERSION_NUM = 1187;
|
||||
global.MIN_CODE_VERSION_NUM = 1114;
|
||||
global.MINING_VERSION_NUM = 0;
|
||||
global.InitParamsArg = InitParamsArg;
|
||||
@ -26,11 +26,9 @@ global.NODES_DELTA_CALC_HOUR = 4;
|
||||
global.USE_API_WALLET = 1;
|
||||
global.USE_API_V1 = 1;
|
||||
global.USE_HARD_API_V2 = 0;
|
||||
global.USE_TICKET = 0;
|
||||
global.USE_CHECK_SENDING = 1;
|
||||
global.USE_LEVEL_WAY = 0;
|
||||
global.TR_TICKET_HASH_LENGTH = 10;
|
||||
global.BLOCKNUM_TICKET_ALGO = 16070000;
|
||||
global.START_BAD_ACCOUNT_CONTROL = 200000;
|
||||
global.WATCHDOG_BADACCOUNT = 1;
|
||||
global.WATCHDOG_DEV = 0;
|
||||
global.RESYNC_CONDITION = {"OWN_BLOCKS":20, "K_POW":5};
|
||||
@ -81,6 +79,10 @@ global.ALL_VIEW_ROWS = 0;
|
||||
global.COUNT_BLOCK_PROOF = 300;
|
||||
global.MIN_POWER_POW_MSG = 2;
|
||||
global.MEM_POOL_MSG_COUNT = 1000;
|
||||
global.PROTOCOL_VER = 0;
|
||||
global.PROTOCOL_MODE = 0;
|
||||
global.MAX_LEVEL = 25;
|
||||
global.MIN_NODES_FOR_DOUBLE_MODE = 16;
|
||||
global.MAX_LEVEL_SPECIALIZATION = 24;
|
||||
global.MIN_CONNECT_CHILD = 2;
|
||||
global.MAX_CONNECT_CHILD = 7;
|
||||
@ -147,13 +149,11 @@ if(global.LOCAL_RUN)
|
||||
global.PERIOD_ACCOUNT_HASH = 10;
|
||||
global.START_BLOCK_ACCOUNT_HASH = 1;
|
||||
global.START_BLOCK_ACCOUNT_HASH3 = 1;
|
||||
global.BLOCKNUM_TICKET_ALGO = 1;
|
||||
global.SMART_BLOCKNUM_START = 0;
|
||||
global.START_MINING = 60;
|
||||
global.REF_PERIOD_END = 0;
|
||||
global.REF_PERIOD_MINING = 10;
|
||||
global.TEST_TRANSACTION_GENERATE = 0;
|
||||
global.MIN_POWER_POW_TR = 8;
|
||||
global.MIN_POWER_POW_ACC_CREATE = 8;
|
||||
global.NEW_ACCOUNT_INCREMENT = 1;
|
||||
global.NEW_BLOCK_REWARD1 = 1;
|
||||
@ -164,6 +164,11 @@ if(global.LOCAL_RUN)
|
||||
NETWORK = "LOCAL";
|
||||
global.ALL_VIEW_ROWS = 1;
|
||||
global.NEW_SIGN_TIME = 0;
|
||||
global.START_BAD_ACCOUNT_CONTROL = 0;
|
||||
global.BLOCKNUM_TICKET_ALGO = 0;
|
||||
global.MIN_POWER_POW_TR = 0;
|
||||
global.AUTO_CORRECT_TIME = 0;
|
||||
global.CHECK_GLOBAL_TIME = 0;
|
||||
}
|
||||
else
|
||||
if(global.TEST_NETWORK)
|
||||
@ -196,16 +201,10 @@ else
|
||||
global.NEW_SIGN_TIME = 1;
|
||||
global.MAX_LENGTH_SENDER_MAP = 100;
|
||||
global.DELTA_START_SENDER_MAP = 12;
|
||||
global.REST_START_COUNT = 0;
|
||||
global.LOAD_TO_BEGIN = 0;
|
||||
global.REST_START_COUNT = 10000;
|
||||
global.LOAD_TO_BEGIN = 2;
|
||||
global.START_BAD_ACCOUNT_CONTROL = 3105000;
|
||||
}
|
||||
if(global.LOCAL_RUN)
|
||||
{
|
||||
global.BLOCKNUM_TICKET_ALGO = 0;
|
||||
global.MIN_POWER_POW_TR = 0;
|
||||
global.AUTO_CORRECT_TIME = 0;
|
||||
global.CHECK_GLOBAL_TIME = 0;
|
||||
}
|
||||
global.GetNetworkName = function ()
|
||||
{
|
||||
return NETWORK + "-" + DEF_MAJOR_VERSION;
|
||||
@ -267,7 +266,9 @@ function InitParamsArg()
|
||||
global.DATA_PATH = str0.substr(5);
|
||||
else
|
||||
if(str.substr(0, 5) == "PORT:")
|
||||
{
|
||||
global.START_PORT_NUMBER = parseInt(str.substr(5));
|
||||
}
|
||||
else
|
||||
if(str.substr(0, 3) == "IP:")
|
||||
global.START_IP = str.substr(3);
|
||||
|
@ -602,17 +602,17 @@ HTTPCaller.GetWalletInfo = function (Params)
|
||||
if(StateTX)
|
||||
TXBlockNum = StateTX.BlockNum;
|
||||
var Ret = {result:1, WalletOpen:WALLET.WalletOpen, WalletIsOpen:(WALLET.WalletOpen !== false), WalletCanSign:(WALLET.WalletOpen !== false && WALLET.KeyPair.WasInit),
|
||||
CODE_VERSION:CODE_VERSION, MAX_TRANSACTION_LIMIT:MAX_TRANSACTION_LIMIT, VersionNum:global.UPDATE_CODE_VERSION_NUM, RelayMode:SERVER.RelayMode,
|
||||
BlockNumDB:SERVER.BlockNumDB, CurBlockNum:GetCurrentBlockNumByTime(), CurTime:Date.now(), IsDevelopAccount:IsDeveloperAccount(WALLET.PubKeyArr),
|
||||
AccountMap:WALLET.AccountMap, ArrLog:ArrLogClient, MaxAccID:DApps.Accounts.GetMaxAccount(), MaxActNum:DApps.Accounts.GetActsMaxNum(),
|
||||
MaxDappsID:DApps.Smart.GetMaxNum(), NeedRestart:global.NeedRestart, ip:SERVER.ip, port:SERVER.port, NET_WORK_MODE:global.NET_WORK_MODE,
|
||||
INTERNET_IP_FROM_STUN:global.INTERNET_IP_FROM_STUN, HistoryMaxNum:MaxHistory, DELTA_CURRENT_TIME:DELTA_CURRENT_TIME, FIRST_TIME_BLOCK:FIRST_TIME_BLOCK,
|
||||
CONSENSUS_PERIOD_TIME:CONSENSUS_PERIOD_TIME, NEW_SIGN_TIME:NEW_SIGN_TIME, DATA_PATH:(DATA_PATH.substr(1, 1) === ":" ? DATA_PATH : GetNormalPathString(process.cwd() + "/" + DATA_PATH)),
|
||||
NodeAddrStr:SERVER.addrStr, STAT_MODE:global.STAT_MODE, HTTPPort:global.HTTP_PORT_NUMBER, HTTPPassword:HTTP_PORT_PASSWORD,
|
||||
CONSTANTS:Constants, CheckPointBlockNum:CHECK_POINT.BlockNum, MiningAccount:global.GENERATE_BLOCK_ACCOUNT, CountMiningCPU:GetCountMiningCPU(),
|
||||
CountRunCPU:global.ArrMiningWrk.length, MiningPaused:global.MiningPaused, HashRate:HashRateOneSec, MIN_POWER_POW_TR:MIN_POWER_POW_TR,
|
||||
PRICE_DAO:PRICE_DAO(SERVER.BlockNumDB), NWMODE:global.NWMODE, PERIOD_ACCOUNT_HASH:PERIOD_ACCOUNT_HASH, MAX_ACCOUNT_HASH:DApps.Accounts.DBAccountsHash.GetMaxNum(),
|
||||
TXBlockNum:TXBlockNum, SpeedSignLib:global.SpeedSignLib, };
|
||||
CODE_VERSION:CODE_VERSION, MAX_TRANSACTION_LIMIT:MAX_TRANSACTION_LIMIT, PROTOCOL_VER:PROTOCOL_VER, PROTOCOL_MODE:PROTOCOL_MODE,
|
||||
MAX_LEVEL:MAX_LEVEL, VersionNum:global.UPDATE_CODE_VERSION_NUM, RelayMode:SERVER.RelayMode, BlockNumDB:SERVER.BlockNumDB, CurBlockNum:GetCurrentBlockNumByTime(),
|
||||
CurTime:Date.now(), IsDevelopAccount:IsDeveloperAccount(WALLET.PubKeyArr), AccountMap:WALLET.AccountMap, ArrLog:ArrLogClient,
|
||||
MaxAccID:DApps.Accounts.GetMaxAccount(), MaxActNum:DApps.Accounts.GetActsMaxNum(), MaxDappsID:DApps.Smart.GetMaxNum(), NeedRestart:global.NeedRestart,
|
||||
ip:SERVER.ip, port:SERVER.port, NET_WORK_MODE:global.NET_WORK_MODE, INTERNET_IP_FROM_STUN:global.INTERNET_IP_FROM_STUN, HistoryMaxNum:MaxHistory,
|
||||
DELTA_CURRENT_TIME:DELTA_CURRENT_TIME, FIRST_TIME_BLOCK:FIRST_TIME_BLOCK, CONSENSUS_PERIOD_TIME:CONSENSUS_PERIOD_TIME, NEW_SIGN_TIME:NEW_SIGN_TIME,
|
||||
DATA_PATH:(DATA_PATH.substr(1, 1) === ":" ? DATA_PATH : GetNormalPathString(process.cwd() + "/" + DATA_PATH)), NodeAddrStr:SERVER.addrStr,
|
||||
STAT_MODE:global.STAT_MODE, HTTPPort:global.HTTP_PORT_NUMBER, HTTPPassword:HTTP_PORT_PASSWORD, CONSTANTS:Constants, CheckPointBlockNum:CHECK_POINT.BlockNum,
|
||||
MiningAccount:global.GENERATE_BLOCK_ACCOUNT, CountMiningCPU:GetCountMiningCPU(), CountRunCPU:global.ArrMiningWrk.length, MiningPaused:global.MiningPaused,
|
||||
HashRate:HashRateOneSec, MIN_POWER_POW_TR:MIN_POWER_POW_TR, PRICE_DAO:PRICE_DAO(SERVER.BlockNumDB), NWMODE:global.NWMODE, PERIOD_ACCOUNT_HASH:PERIOD_ACCOUNT_HASH,
|
||||
MAX_ACCOUNT_HASH:DApps.Accounts.DBAccountsHash.GetMaxNum(), TXBlockNum:TXBlockNum, SpeedSignLib:global.SpeedSignLib, };
|
||||
if(Params.Account)
|
||||
Ret.PrivateKey = GetHexFromArr(WALLET.GetPrivateKey(WALLET.AccountMap[Params.Account]));
|
||||
else
|
||||
@ -1063,7 +1063,7 @@ function GetCopyNode(Node,BlockCounts)
|
||||
var GetTiming = 0;
|
||||
if(BlockCounts !== 0)
|
||||
GetTiming = Math.trunc(Node.GetTiming / BlockCounts) / 1000;
|
||||
var Item = {VersionNum:Node.VersionNum, NoSendTx:Node.NoSendTx, GetNoSendTx:Node.GetNoSendTx, DirectMAccount:Node.DirectMAccount,
|
||||
var Item = {VersionNum:Node.VersionNum, LevelsBit:Node.LevelsBit, NoSendTx:Node.NoSendTx, GetNoSendTx:Node.GetNoSendTx, DirectMAccount:Node.DirectMAccount,
|
||||
id:Node.id, ip:Node.ip, portweb:Node.portweb, port:Node.port, TransferCount:Node.TransferCount, GetTiming:GetTiming, ErrCountAll:Node.ErrCountAll,
|
||||
LevelCount:Node.LevelCount, LevelEnum:Node.LevelEnum, TimeTransfer:GetStrOnlyTimeUTC(new Date(Node.LastTimeTransfer)), BlockProcessCount:Node.BlockProcessCount,
|
||||
DeltaTime:Node.DeltaTime, DeltaTimeM:Node.DeltaTimeM, DeltaGlobTime:Node.DeltaGlobTime, PingNumber:Node.PingNumber, NextConnectDelta:Node.NextConnectDelta,
|
||||
|
@ -394,8 +394,7 @@ global.GetCurrentTime = function (Delta_Time)
|
||||
{
|
||||
if(Delta_Time === undefined)
|
||||
Delta_Time = GetDeltaCurrentTime();
|
||||
var curTime = new Date;
|
||||
var Time = new Date(curTime - ( - Delta_Time));
|
||||
var Time = new Date(Date.now() + Delta_Time);
|
||||
return Time;
|
||||
};
|
||||
|
||||
|
@ -44,6 +44,7 @@ module.exports = class CNode
|
||||
this.PrevInfo = ""
|
||||
this.StartTimeHot = 0
|
||||
this.NextHotDelta = 1000
|
||||
this.LevelsBit = 0
|
||||
this.ResetNode()
|
||||
}
|
||||
ResetNode()
|
||||
|
@ -102,7 +102,7 @@ module.exports = class CTransport extends require("./connect")
|
||||
MethodTiming:
|
||||
{
|
||||
Map["TRANSFER"] = {Period:700, Hot:1}
|
||||
Map["TRANSFERTX"] = {Period:700, Hot:1}
|
||||
Map["TRANSFER2"] = {Period:700, Hot:1}
|
||||
Map["TIME"] = {Period:2000, LowVersion:1, Hard:1, Immediately:1}
|
||||
Map["PING"] = {Period:4000, LowVersion:1, Hard:1, Immediately:1}
|
||||
Map["PONG"] = {Period:0, LowVersion:1, Immediately:1}
|
||||
@ -127,6 +127,12 @@ module.exports = class CTransport extends require("./connect")
|
||||
Map["GETSMART"] = {Period:1000, Hard:2, Process:global.STATIC_PROCESS}
|
||||
Map["RETSMART"] = {Period:0}
|
||||
}
|
||||
if(global.LOCAL_RUN)
|
||||
{
|
||||
this.ip = "127.0.0.1"
|
||||
global.LISTEN_IP = this.ip
|
||||
global.INTERNET_IP_FROM_STUN = this.ip
|
||||
}
|
||||
if(!this.VirtualMode)
|
||||
this.StartServer()
|
||||
this.CurrentTimeStart = 0
|
||||
|
@ -22,13 +22,13 @@ function RunOnUpdate()
|
||||
UpdateInfo.UPDATE_NUM_COMPLETE = UPDATE_CODE_VERSION_NUM;
|
||||
ToLog("UPDATER Start");
|
||||
SaveParams(fname, UpdateInfo);
|
||||
if(global.TEST_NETWORK || global.LOCAL_RUN)
|
||||
if(global.TEST_NETWORK)
|
||||
{
|
||||
if(CurNum < 1137)
|
||||
{
|
||||
SERVER.ClearDataBase();
|
||||
}
|
||||
if(CurNum < 1142)
|
||||
if(CurNum < 1184)
|
||||
{
|
||||
setTimeout(function ()
|
||||
{
|
||||
|
@ -33,6 +33,8 @@ WebApi2.CreateAccount = function (Params,response)
|
||||
Meta:Params.Meta, };
|
||||
var Str = JSON.stringify(Result);
|
||||
response.end(Str);
|
||||
if(typeof Params.F === "function")
|
||||
Params.F(Result);
|
||||
});
|
||||
return null;
|
||||
}
|
||||
@ -45,7 +47,7 @@ WebApi2.Send = function (Params,response,A,bJsonRet)
|
||||
return {result:0};
|
||||
var Coin;
|
||||
if(typeof Params.Amount === "number")
|
||||
Coin = COIN_FROM_FLOAT(Params.Amount);
|
||||
Coin = COIN_FROM_FLOAT2(Params.Amount);
|
||||
else
|
||||
Coin = Params.Amount;
|
||||
var FromNum = ParseNum(Params.FromID);
|
||||
@ -96,6 +98,8 @@ WebApi2.Send = function (Params,response,A,bJsonRet)
|
||||
Meta:Params.Meta, };
|
||||
var Str = JSON.stringify(Result);
|
||||
response.end(Str);
|
||||
if(typeof Params.F === "function")
|
||||
Params.F(Result);
|
||||
});
|
||||
return null;
|
||||
};
|
||||
|
@ -147,8 +147,8 @@ function AddTransactionFromWeb(Params)
|
||||
return text;
|
||||
};
|
||||
global.AddTransactionFromWeb = AddTransactionFromWeb;
|
||||
global.STATIC_PROCESS = {Name:"STATIC PROCESS", idInterval:0, idInterval1:0, idInterval2:0, LastAlive:Date.now(), Worker:undefined,
|
||||
Path:"./process/static-process.js", OnMessage:OnMessageStatic, PeriodAlive:50000};
|
||||
global.STATIC_PROCESS = {Name:"STATIC PROCESS", NodeOnly:1, idInterval:0, idInterval1:0, idInterval2:0, LastAlive:Date.now(),
|
||||
Worker:undefined, Path:"./process/static-process.js", OnMessage:OnMessageStatic, PeriodAlive:50000};
|
||||
ArrChildProcess.push(STATIC_PROCESS);
|
||||
|
||||
function OnMessageStatic(msg)
|
||||
@ -167,7 +167,7 @@ function OnMessageStatic(msg)
|
||||
}
|
||||
}
|
||||
};
|
||||
global.TX_PROCESS = {Name:"TX PROCESS", idInterval:0, idInterval1:0, idInterval2:0, LastAlive:Date.now(), Worker:undefined,
|
||||
global.TX_PROCESS = {Name:"TX PROCESS", NodeOnly:1, idInterval:0, idInterval1:0, idInterval2:0, LastAlive:Date.now(), Worker:undefined,
|
||||
Path:"./process/tx-process.js", OnMessage:OnMessageTX, PeriodAlive:100 * 1000};
|
||||
ArrChildProcess.push(TX_PROCESS);
|
||||
|
||||
@ -211,6 +211,10 @@ var GlobalRunMap = {};
|
||||
|
||||
function StartChildProcess(Item)
|
||||
{
|
||||
if(Item.NodeOnly && global.NET_WORK_MODE && NET_WORK_MODE.NOT_RUN)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
let ITEM = Item;
|
||||
ITEM.idInterval = setInterval(function ()
|
||||
{
|
||||
@ -732,7 +736,10 @@ function Fork(Path,ArrArgs)
|
||||
const child_process = require('child_process');
|
||||
ArrArgs = ArrArgs || [];
|
||||
if(global.LOCAL_RUN)
|
||||
{
|
||||
ArrArgs.push("LOCALRUN");
|
||||
ArrArgs.push("STARTNETWORK:" + global.START_NETWORK_DATE);
|
||||
}
|
||||
else
|
||||
if(global.TEST_NETWORK)
|
||||
ArrArgs.push("TESTRUN");
|
||||
|
@ -75,7 +75,7 @@ function DoTXProcess()
|
||||
if(bShowDetail)
|
||||
ToLog("BlockMin: " + BlockMin.BlockNum + " LastBlockNum=" + LastBlockNum);
|
||||
var CountTX = 0;
|
||||
for(var Num = BlockMin.BlockNum; Num < BlockMin.BlockNum + 200; Num++)
|
||||
for(var Num = BlockMin.BlockNum; Num < BlockMin.BlockNum + 1000; Num++)
|
||||
{
|
||||
var EndTime = Date.now();
|
||||
var Delta = EndTime - StartTime;
|
||||
|
@ -833,6 +833,8 @@ HostingCaller.GetHistoryTransactions = function (Params)
|
||||
};
|
||||
HostingCaller.GetSupply = function (Params)
|
||||
{
|
||||
if(HTTPS_HOSTING_DOMAIN === "terafoundation.org")
|
||||
return "" + (1000000000 - 411 * 1000000);
|
||||
var Data = DApps.Accounts.ReadState(0);
|
||||
if(!Data)
|
||||
return "";
|
||||
@ -898,3 +900,10 @@ global.LoadBlockFromNetwork = function (Params,F)
|
||||
F(Err, Block);
|
||||
});
|
||||
};
|
||||
if(global.LOCAL_RUN)
|
||||
{
|
||||
setTimeout(function ()
|
||||
{
|
||||
require("../UnitTest/new-tx.js");
|
||||
}, 1000);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ const os = require('os');
|
||||
if(!global.DATA_PATH || global.DATA_PATH==="")
|
||||
global.DATA_PATH="../DATA";
|
||||
global.CODE_PATH=process.cwd();
|
||||
global.HTTP_PORT_NUMBER = 8080;
|
||||
global.HTTP_PORT_NUMBER = 8000;
|
||||
if(global.LOCAL_RUN===undefined)
|
||||
global.LOCAL_RUN=0;
|
||||
|
||||
|
@ -420,9 +420,7 @@ class AccountApp extends require("./dapp")
|
||||
case TYPE_TRANSACTION_ACC_HASH:
|
||||
{
|
||||
Result = 1
|
||||
if(global.LOCAL_RUN || global.TEST_NETWORK);
|
||||
else
|
||||
if(BlockNum < START_BLOCK_ACCOUNT_HASH + 200000)
|
||||
if(BlockNum < START_BLOCK_ACCOUNT_HASH + START_BAD_ACCOUNT_CONTROL)
|
||||
break;
|
||||
var BlockNumHash = BlockNum - DELTA_BLOCK_ACCOUNT_HASH;
|
||||
if(!this.TRCheckAccountHash(Body, BlockNum, TrNum))
|
||||
@ -641,6 +639,10 @@ class AccountApp extends require("./dapp")
|
||||
{
|
||||
CheckMinPower = 0
|
||||
}
|
||||
if(global.LOCAL_RUN)
|
||||
{
|
||||
CheckMinPower = 0
|
||||
}
|
||||
if(CheckMinPower && BlockNum < 19600000)
|
||||
{
|
||||
var MinPower;
|
||||
@ -1466,8 +1468,10 @@ class AccountApp extends require("./dapp")
|
||||
var Item = TR.To[i];
|
||||
var DataTo = DApps.Accounts.ReadState(Item.ID);
|
||||
if(!DataTo)
|
||||
{
|
||||
return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
}
|
||||
for(var j = 0; j < 33; j++)
|
||||
Arr[Arr.length] = DataTo.PubKey[j]
|
||||
}
|
||||
|
@ -1142,7 +1142,7 @@ function $Move(FromID,ToID,CoinSum,Description)
|
||||
}
|
||||
if(FromData.Value.Smart !== RunContext.Smart.Num)
|
||||
{
|
||||
throw "The account smart does not belong to the smart-contract, access is denied";
|
||||
throw "The account: " + FromID + " does not belong to the smart-contract: " + RunContext.Smart.Num + ", access is denied";
|
||||
}
|
||||
if(typeof CoinSum === "number")
|
||||
{
|
||||
@ -1229,7 +1229,7 @@ function $WriteState(Obj,ID)
|
||||
var Smart = RunContext.Smart;
|
||||
if(Account.Value.Smart !== Smart.Num)
|
||||
{
|
||||
throw "The account does not belong to the smart-contract, access to change state is denied";
|
||||
throw "The account: " + ID + " does not belong to the smart-contract: " + Smart.Num + ", access to change state is denied";
|
||||
}
|
||||
Account.Value.Data = BufLib.GetBufferFromObject(Obj, Smart.StateFormat, 80, Smart.WorkStruct, 1);
|
||||
DApps.Accounts.WriteStateTR(Account, RunContext.TrNum);
|
||||
|
Loading…
Reference in New Issue
Block a user