refactor: keep client online and optimiz code
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
@@ -8,15 +8,6 @@
|
||||
* 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;
|
||||
|
||||
function Write(buf, data, StringFormat?, ParamValue?, WorkStruct?) {
|
||||
if (buf.len >= buf.length) {
|
||||
return;
|
||||
@@ -497,7 +488,7 @@ function GetReadBuffer(buffer) {
|
||||
return buf;
|
||||
};
|
||||
|
||||
function GetObjectFromBuffer(buffer, format, WorkStruct, bDisableTime) {
|
||||
function GetObjectFromBuffer(buffer, format, WorkStruct, bDisableTime?) {
|
||||
var buf = Buffer.from(buffer);
|
||||
buf.len = 0;
|
||||
return Read(buf, format, undefined, WorkStruct, bDisableTime);
|
||||
@@ -596,3 +587,16 @@ function GetAttributes(Str) {
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
let alloc = GetNewBuffer;
|
||||
let from = GetReadBuffer;
|
||||
export {
|
||||
GetNewBuffer,
|
||||
GetReadBuffer,
|
||||
alloc,
|
||||
from,
|
||||
Write,
|
||||
Read,
|
||||
GetObjectFromBuffer,
|
||||
GetBufferFromObject,
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ if (global.USE_PARAM_JS) {
|
||||
}
|
||||
require('../HTML/JS/terahashlib.js');
|
||||
require("./crypto-library");
|
||||
global.BufLib = require("../core/buffer");
|
||||
import * as BufLib from '../core/buffer'
|
||||
global.BufLib = BufLib;
|
||||
require('../HTML/JS/sha3.js');
|
||||
require('../HTML/JS/coinlib.js');
|
||||
global.GetCurrentBlockNumByTime = function GetCurrentBlockNumByTime() {
|
||||
|
||||
@@ -236,7 +236,13 @@ export default class CRest extends CDB {
|
||||
global.ToLog("Send GETREST Num:" + Task.StartNum + "-" + Task.Count + " to " + global.NodeName(Ret.Node), 2)
|
||||
var SELF = this;
|
||||
this.SendF(Ret.Node, {
|
||||
"Method": "GETREST", "Data": { BlockNum: Context.BlockNumRest, AccNum: Task.StartNum, Count: Task.Count, AccHash: Context.TxProof.AccHash },
|
||||
"Method": "GETREST",
|
||||
"Data": {
|
||||
BlockNum: Context.BlockNumRest,
|
||||
AccNum: Task.StartNum,
|
||||
Count: Task.Count,
|
||||
AccHash: Context.TxProof.AccHash
|
||||
},
|
||||
"Context": {
|
||||
F: function(Info) {
|
||||
if (Task.OK)
|
||||
|
||||
@@ -644,8 +644,7 @@ export default class CTransport extends CConnect {
|
||||
Info.Context.ContextID = Info.ContextID
|
||||
}
|
||||
global.ContextPackets.SaveValue(Info.ContextID, Info.Context)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Info.ContextID = []
|
||||
}
|
||||
Node.SendPacketNum++
|
||||
|
||||
@@ -163,7 +163,7 @@ function ReWriteDBSmartWrite() {
|
||||
var Item = global.DApps.Smart.DBSmart.Read(num);
|
||||
if (!Item)
|
||||
break;
|
||||
var Body = global.GetArrFromHex(GetBufferFromObject(Item, DB_FORMAT.FORMAT_SMART_ROW, 20000, {}));
|
||||
var Body = global.GetArrFromHex(global.BufLib.GetBufferFromObject(Item, DB_FORMAT.FORMAT_SMART_ROW, 20000, {}));
|
||||
if (Body.length > 15000)
|
||||
global.ToLog("Smart " + Item.Num + ". " + Item.Name + " length=" + Body.length);
|
||||
global.DApps.Smart.DBSmartWrite(Item);
|
||||
|
||||
Reference in New Issue
Block a user