fix: compaile error

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2019-07-10 18:07:35 +08:00
parent f0d4952b27
commit 63536569cf
7 changed files with 34 additions and 40 deletions

View File

@ -10,19 +10,19 @@
import * as crypto from 'crypto' import * as crypto from 'crypto'
global.HTTPCaller.CreateAccount = function(Params, response) { global.HTTPCaller.CreateAccount = function(Params, response) {
if (typeof Params === "object" && Params.Name && Params.PubKey) { if (typeof Params === "object" && Params.Name && Params.PubKey) {
var TYPE_TRANSACTION_CREATE = 100; //var TYPE_TRANSACTION_CREATE = 100;
var TR = { var TR = {
Type: global.TYPE_TRANSACTION_CREATE, Type: global.TYPE_TRANSACTION_CREATE,
Currency: Params.Currency, Currency: Params.Currency,
PubKey: global.GetArrFromHex(Params.PubKey), Description: Params.Name, PubKey: global.GetArrFromHex(Params.PubKey), Description: Params.Name,
Smart: Params.Smart, Adviser: 0, Smart: Params.Smart, Adviser: 0,
}; };
var Body = global.BufLib.GetBufferFromObject(TR, global.FORMAT_CREATE, 1000, {}); global.BufLib.GetBufferFromObject(TR, global.FORMAT_CREATE, 1000, {});
return { result: 1 }; return { result: 1 };
} }
return { result: 0 }; return { result: 0 };
}; };
var MaxCountViewRows = global.HTTP_MAX_COUNT_ROWS; //var MaxCountViewRows = global.HTTP_MAX_COUNT_ROWS;
global.HTTPCaller.GetBalance = function(Params) { global.HTTPCaller.GetBalance = function(Params) {
if (typeof Params === "object") { if (typeof Params === "object") {
var arr = global.DApps.Accounts.GetRowsAccounts(global.ParseNum(Params.AccountID), 1); var arr = global.DApps.Accounts.GetRowsAccounts(global.ParseNum(Params.AccountID), 1);

View File

@ -10,7 +10,7 @@
"use strict"; "use strict";
import * as fs from 'fs' import * as fs from 'fs'
const FORMAT_EVAL_SEND = "{MaxBlockNum:uint,Code:str,Sign:arr64}"; // const FORMAT_EVAL_SEND = "{MaxBlockNum:uint,Code:str,Sign:arr64}";
module.exports = class CCode extends require("./base") module.exports = class CCode extends require("./base")
{ {
LastEvalCodeNum LastEvalCodeNum

View File

@ -664,11 +664,11 @@ module.exports = class CDB extends require("../code")
Block.Hash2 = Value.Hash2 Block.Hash2 = Value.Hash2
} }
if (Filter) { if (Filter) {
var Num = Block.BlockNum; // var Num = Block.BlockNum;
var Bytes = Block.TrDataLen; // var Bytes = Block.TrDataLen;
var Pow = Block.Power; // var Pow = Block.Power;
var Miner = Block.Miner; // var Miner = Block.Miner;
var Date = global.DateFromBlock(Block.BlockNum); // var Date = global.DateFromBlock(Block.BlockNum);
try { try {
if (!eval(Filter)) if (!eval(Filter))
continue; continue;
@ -828,7 +828,7 @@ module.exports = class CDB extends require("../code")
var ArrPowerMy = this.StatMap.ArrPowerMy; var ArrPowerMy = this.StatMap.ArrPowerMy;
var StartNumStat = this.StatMap.StartBlockNum; var StartNumStat = this.StatMap.StartBlockNum;
var FinishNumStat = this.StatMap.StartBlockNum + this.StatMap.Length - 1; var FinishNumStat = this.StatMap.StartBlockNum + this.StatMap.Length - 1;
var CountReadDB = 0; // var CountReadDB = 0;
var arr = new Array(MinLength); var arr = new Array(MinLength);
var arrmy = new Array(MinLength); var arrmy = new Array(MinLength);
for (var num = start; num < finish; num++) { for (var num = start; num < finish; num++) {
@ -839,7 +839,7 @@ module.exports = class CDB extends require("../code")
arrmy[i] = ArrPowerMy[i2] arrmy[i] = ArrPowerMy[i2]
} }
else { else {
CountReadDB++ // CountReadDB++
var Power = 0, PowerMy = 0; var Power = 0, PowerMy = 0;
if (num <= MaxNumBlockDB) { if (num <= MaxNumBlockDB) {
var Block = this.ReadBlockHeaderDB(num); var Block = this.ReadBlockHeaderDB(num);
@ -929,7 +929,7 @@ module.exports = class CDB extends require("../code")
BlockChainToBuf(WriteNum, StartNum, EndBlockNum) { BlockChainToBuf(WriteNum, StartNum, EndBlockNum) {
if (StartNum === undefined) if (StartNum === undefined)
return global.BufLib.GetNewBuffer(10); return global.BufLib.GetNewBuffer(10);
var GetLength = EndBlockNum - StartNum + 1; // var GetLength = EndBlockNum - StartNum + 1;
var arr = []; var arr = [];
var arr0 = this.PrevBlockChainArr; var arr0 = this.PrevBlockChainArr;
if (arr0 && arr0.length) { if (arr0 && arr0.length) {

View File

@ -17,9 +17,9 @@ module.exports = class CDBState extends require("./db")
private DataSize; private DataSize;
private Format; private Format;
private WorkStruct; private WorkStruct;
private FileNameFull; // private FileNameFull;
private LastHash; // private LastHash;
private WasUpdate; // private WasUpdate;
private BufMap; private BufMap;
private BufMapCount; private BufMapCount;
@ -29,10 +29,10 @@ module.exports = class CDBState extends require("./db")
this.DataSize = DataSize this.DataSize = DataSize
this.Format = Format this.Format = Format
this.WorkStruct = {} this.WorkStruct = {}
var FI = this.OpenDBFile(this.FileName, !bReadOnly); // var FI = this.OpenDBFile(this.FileName, !bReadOnly);
this.FileNameFull = FI.fname // this.FileNameFull = FI.fname
this.LastHash = undefined // this.LastHash = undefined
this.WasUpdate = 1 // this.WasUpdate = 1
this.BufMap = {} this.BufMap = {}
this.BufMapCount = 0 this.BufMapCount = 0
setInterval(this.CheckBufMap.bind(this), 1000) setInterval(this.CheckBufMap.bind(this), 1000)
@ -48,8 +48,8 @@ module.exports = class CDBState extends require("./db")
} }
Write(Data, RetBuf) { Write(Data, RetBuf) {
var startTime = process.hrtime(); var startTime = process.hrtime();
this.LastHash = undefined // this.LastHash = undefined
this.WasUpdate = 1 // this.WasUpdate = 1
this.CheckNewNum(Data) this.CheckNewNum(Data)
Data.Num = Math.trunc(Data.Num) Data.Num = Math.trunc(Data.Num)
this.DeleteMap(Data.Num) this.DeleteMap(Data.Num)
@ -118,8 +118,8 @@ module.exports = class CDBState extends require("./db")
Position = 0 Position = 0
var FI = this.OpenDBFile(this.FileName, 1); var FI = this.OpenDBFile(this.FileName, 1);
if (Position < FI.size) { if (Position < FI.size) {
this.LastHash = undefined // this.LastHash = undefined
this.WasUpdate = 1 // this.WasUpdate = 1
if (LastNum < 0) if (LastNum < 0)
global.ToLog("Truncate " + this.FileName + " from 0", 2) global.ToLog("Truncate " + this.FileName + " from 0", 2)
FI.size = Position FI.size = Position

View File

@ -13,8 +13,8 @@ import * as fs from 'fs'
module.exports = class { module.exports = class {
private DBMap; private DBMap;
private LastHash; // private LastHash;
private WasUpdate; // private WasUpdate;
private WasCheckPathDB; private WasCheckPathDB;
constructor() { constructor() {
@ -25,8 +25,8 @@ module.exports = class {
global.CheckCreateDir(Path) global.CheckCreateDir(Path)
} }
CloseDBFile(name, bdelete) { CloseDBFile(name, bdelete) {
this.LastHash = undefined // this.LastHash = undefined
this.WasUpdate = 1 // this.WasUpdate = 1
var Item = this.DBMap[name]; var Item = this.DBMap[name];
if (Item) { if (Item) {
let bDelete = bdelete; let bDelete = bdelete;
@ -55,8 +55,8 @@ module.exports = class {
} }
if (bWrite) if (bWrite)
CheckStartOneProcess(name + "-run") CheckStartOneProcess(name + "-run")
this.LastHash = undefined // this.LastHash = undefined
this.WasUpdate = 1 // this.WasUpdate = 1
var Item = this.DBMap[name]; var Item = this.DBMap[name];
if (Item === undefined) { if (Item === undefined) {
if (!this.WasCheckPathDB) { if (!this.WasCheckPathDB) {

View File

@ -9,11 +9,6 @@
*/ */
import * as fs from 'fs' import * as fs from 'fs'
let {
ToLog,
MAX_SIZE_LOG
} = global
function CheckSizeLogFile(file_name, file_name_prev) { function CheckSizeLogFile(file_name, file_name_prev) {
"use strict"; "use strict";
let FILE_NAME_LOG = file_name; let FILE_NAME_LOG = file_name;
@ -21,7 +16,7 @@ function CheckSizeLogFile(file_name, file_name_prev) {
setInterval(function() { setInterval(function() {
try { try {
var stat = fs.statSync(FILE_NAME_LOG); var stat = fs.statSync(FILE_NAME_LOG);
if (stat.size > MAX_SIZE_LOG) { if (stat.size > global.MAX_SIZE_LOG) {
if (fs.existsSync(FILE_NAME_LOG_PREV)) { if (fs.existsSync(FILE_NAME_LOG_PREV)) {
fs.unlinkSync(FILE_NAME_LOG_PREV); fs.unlinkSync(FILE_NAME_LOG_PREV);
} }

View File

@ -17,8 +17,7 @@ var TempArrayTr = new Uint8Array(MAX_MSG_SIZE);
const MESSAGE_START = 9; const MESSAGE_START = 9;
const MESSAGE_END = MAX_MSG_SIZE - 5; const MESSAGE_END = MAX_MSG_SIZE - 5;
require("./names"); require("./names");
class CApp extends require("./dapp") class CApp extends require("./dapp") {
{
Channels Channels
NamesMap NamesMap
constructor() { constructor() {
@ -105,9 +104,9 @@ class CApp extends require("./dapp")
}; };
function TestEncryptDecrypt() { function TestEncryptDecrypt() {
const CMessager = module.exports; // const CMessager = module.exports;
var Server = { KeyPair: global.GetKeyPairTest("Test"), DApp: { Names: { KeyValueMap: {} } }, }; // var Server = { KeyPair: global.GetKeyPairTest("Test"), DApp: { Names: { KeyValueMap: {} } }, };
var Test = new CMessager(Server); // var Test = new CMessager(Server);
var KeyPair2 = global.GetKeyPairTest("Test2"); var KeyPair2 = global.GetKeyPairTest("Test2");
var StrTest1 = global.GetArrFromStr("Test2", 32); var StrTest1 = global.GetArrFromStr("Test2", 32);
var StrKey = global.GetHexFromAddres(StrTest1); var StrKey = global.GetHexFromAddres(StrTest1);