forked from circlecloud/tera
feat: format code move type def
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
f8fcab7929
commit
92a1edb789
2
.gitignore
vendored
2
.gitignore
vendored
@ -38,4 +38,4 @@ screenshot
|
|||||||
.eslintcache
|
.eslintcache
|
||||||
|
|
||||||
build
|
build
|
||||||
DATA
|
DATA*
|
||||||
|
@ -100,7 +100,7 @@ export default class CConsensus extends CBlock {
|
|||||||
Context.TrDataLen = 0
|
Context.TrDataLen = 0
|
||||||
Context.Info = "Create at:" + global.GetStrOnlyTimeUTC()
|
Context.Info = "Create at:" + global.GetStrOnlyTimeUTC()
|
||||||
var Transfer;
|
var Transfer;
|
||||||
//var TransferM2;
|
var TransferM2;
|
||||||
var LocalLevel = 0;
|
var LocalLevel = 0;
|
||||||
var Levels = this.LevelNodes;
|
var Levels = this.LevelNodes;
|
||||||
for (let L = 0; L < Levels.length; L++) {
|
for (let L = 0; L < Levels.length; L++) {
|
||||||
@ -1282,13 +1282,11 @@ export default class CConsensus extends CBlock {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.OwnBlockCount = 0
|
this.OwnBlockCount = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Block.HasErr = 1
|
Block.HasErr = 1
|
||||||
if (!PrevBlock.bSave)
|
if (!PrevBlock.bSave)
|
||||||
global.AddInfoBlock(Block, "Prev block not saved")
|
global.AddInfoBlock(Block, "Prev block not saved")
|
||||||
|
@ -984,3 +984,57 @@ if (global.TEST_NETWORK || global.LOCAL_RUN) {
|
|||||||
global.DEVELOP_PUB_KEY_ARR = [global.DEVELOP_PUB_KEY0];
|
global.DEVELOP_PUB_KEY_ARR = [global.DEVELOP_PUB_KEY0];
|
||||||
global.DEVELOP_PUB_KEY = DEVELOP_PUB_KEY_ARR[0];
|
global.DEVELOP_PUB_KEY = DEVELOP_PUB_KEY_ARR[0];
|
||||||
}
|
}
|
||||||
|
declare global {
|
||||||
|
namespace NodeJS {
|
||||||
|
interface Global {
|
||||||
|
//#region dapp.ts
|
||||||
|
MAX_SUPER_VALUE_POW: number;
|
||||||
|
GetHexFromAddres: Function;
|
||||||
|
GetArr32FromHex: Function;
|
||||||
|
GetAddresFromHex: Function;
|
||||||
|
GetHexAddresFromPublicKey: Function;
|
||||||
|
GetHexFromArr: Function;
|
||||||
|
GetArrFromHex: Function;
|
||||||
|
GetHexFromArrBlock: Function;
|
||||||
|
GetPublicKeyFromAddres: Function;
|
||||||
|
CheckDevelopSign: Function;
|
||||||
|
CheckContextSecret: Function;
|
||||||
|
GetSignHash: Function;
|
||||||
|
GetVerifyHash: Function;
|
||||||
|
GetKeyPair: Function;
|
||||||
|
GetKeyPairTest: Function;
|
||||||
|
GetHashWithValues: Function;
|
||||||
|
CreateNoncePOWExtern: Function;
|
||||||
|
CreateNoncePOWExternMinPower: Function;
|
||||||
|
CreateNoncePOWInner: Function;
|
||||||
|
CreateAddrPOW: Function;
|
||||||
|
CalcMerkl3FromArray: Function;
|
||||||
|
CalcMerkl0FromArray: Function;
|
||||||
|
ClientHex: Function;
|
||||||
|
CalcHash3FromArray: Function;
|
||||||
|
CalcHashFromArray: Function;
|
||||||
|
CalcMerklFromArray: Function;
|
||||||
|
CalcTreeHashFromArrBody: Function;
|
||||||
|
UpdateMerklTree: Function;
|
||||||
|
GetMerkleProof: Function;
|
||||||
|
CheckMerkleProof: Function;
|
||||||
|
IsZeroArr: Function;
|
||||||
|
GetHashWithNonce: Function;
|
||||||
|
GetPowPower: Function;
|
||||||
|
GetArrFromValue: Function;
|
||||||
|
GetPowValue: Function;
|
||||||
|
Mesh: Function;
|
||||||
|
Encrypt: Function;
|
||||||
|
Decrypt: Function;
|
||||||
|
toUTF8Array: Function;
|
||||||
|
Utf8ArrayToStr: Function;
|
||||||
|
GetArrFromStr: Function;
|
||||||
|
IsDeveloperAccount: Function;
|
||||||
|
DEVELOP_PUB_KEY_ARR: Buffer[] | string[];
|
||||||
|
DEVELOP_PUB_KEY: any;
|
||||||
|
DEVELOP_PUB_KEY0: Buffer;
|
||||||
|
ARR_PUB_KEY: any;
|
||||||
|
//#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -58,8 +58,7 @@ function DoCommand(response, Type, Path, params, remoteAddress) {
|
|||||||
try {
|
try {
|
||||||
var Str = JSON.stringify(Ret);
|
var Str = JSON.stringify(Ret);
|
||||||
response.end(Str);
|
response.end(Str);
|
||||||
}
|
} catch (e) {
|
||||||
catch (e) {
|
|
||||||
global.ToLog("ERR PATH:" + Path);
|
global.ToLog("ERR PATH:" + Path);
|
||||||
global.ToLog(e);
|
global.ToLog(e);
|
||||||
response.end();
|
response.end();
|
||||||
@ -202,20 +201,19 @@ function SendBlockFile(response, BlockNum, TrNum) {
|
|||||||
if (Block && Block.arrContent) {
|
if (Block && Block.arrContent) {
|
||||||
SendToResponceFile(response, Block, TrNum);
|
SendToResponceFile(response, Block, TrNum);
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
if (!Block || !Block.TrDataPos) {
|
if (!Block || !Block.TrDataPos) {
|
||||||
global.LoadBlockFromNetwork({ BlockNum: BlockNum }, function(Err, Block) {
|
global.LoadBlockFromNetwork({ BlockNum: BlockNum }, function(Err, Block) {
|
||||||
if (Err) {
|
if (Err) {
|
||||||
SendToResponce404(response);
|
SendToResponce404(response);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SendToResponceFile(response, Block, TrNum);
|
SendToResponceFile(response, Block, TrNum);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
SendToResponce404(response);
|
SendToResponce404(response);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -230,8 +228,7 @@ function SendToResponceFile(response, Block, TrNum) {
|
|||||||
else
|
else
|
||||||
response.writeHead(200, { 'Content-Type': TR.ContentType });
|
response.writeHead(200, { 'Content-Type': TR.ContentType });
|
||||||
response.end(TR.Data);
|
response.end(TR.Data);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SendToResponce404(response);
|
SendToResponce404(response);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -250,20 +247,19 @@ HTTPCaller.DappBlockFile = function(Params, response) {
|
|||||||
if (Block && Block.arrContent) {
|
if (Block && Block.arrContent) {
|
||||||
SendToResponceDappFile(response, Block, Params.TrNum);
|
SendToResponceDappFile(response, Block, Params.TrNum);
|
||||||
return null;
|
return null;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
if (!Block || !Block.TrDataPos) {
|
if (!Block || !Block.TrDataPos) {
|
||||||
global.LoadBlockFromNetwork(Params, function(Err, Block) {
|
global.LoadBlockFromNetwork(Params, function(Err, Block) {
|
||||||
if (Err) {
|
if (Err) {
|
||||||
SendToResponceResult0(response);
|
SendToResponceResult0(response);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SendToResponceDappFile(response, Block, Params.TrNum);
|
SendToResponceDappFile(response, Block, Params.TrNum);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return { result: 0 };
|
return { result: 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -275,8 +271,7 @@ function SendToResponceDappFile(response, Block, TrNum) {
|
|||||||
if (Type === global.TYPE_TRANSACTION_FILE) {
|
if (Type === global.TYPE_TRANSACTION_FILE) {
|
||||||
var TR = global.DApps.File.GetObjectTransaction(Body);
|
var TR = global.DApps.File.GetObjectTransaction(Body);
|
||||||
Result = { result: 1, Type: Type, ContentType: TR.ContentType, Name: TR.Name, Body: TR.Data.toString('utf8') };
|
Result = { result: 1, Type: Type, ContentType: TR.ContentType, Name: TR.Name, Body: TR.Data.toString('utf8') };
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var App = global.DAppByType[Type];
|
var App = global.DAppByType[Type];
|
||||||
if (App) {
|
if (App) {
|
||||||
Body = JSON.parse(App.GetScriptTransaction(Body));
|
Body = JSON.parse(App.GetScriptTransaction(Body));
|
||||||
@ -306,8 +301,7 @@ HTTPCaller.DappStaticCall = function(Params, response) {
|
|||||||
var RetValue;
|
var RetValue;
|
||||||
try {
|
try {
|
||||||
RetValue = global.RunSmartMethod(glBlock0, Account.Value.Smart, Account, 0, 0, undefined, Params.MethodName, Params.Params, 1);
|
RetValue = global.RunSmartMethod(glBlock0, Account.Value.Smart, Account, 0, 0, undefined, Params.MethodName, Params.Params, 1);
|
||||||
}
|
} catch (e) {
|
||||||
catch (e) {
|
|
||||||
return { result: 0, RetValue: "" + e };
|
return { result: 0, RetValue: "" + e };
|
||||||
}
|
}
|
||||||
var Str = JSON.stringify({ result: 1, RetValue: RetValue });
|
var Str = JSON.stringify({ result: 1, RetValue: RetValue });
|
||||||
|
96
src/global.d.ts
vendored
96
src/global.d.ts
vendored
@ -279,54 +279,54 @@ declare global {
|
|||||||
NO_HISTORY_MODE: boolean;
|
NO_HISTORY_MODE: boolean;
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region crypto-library.ts
|
// //#region crypto-library.ts
|
||||||
MAX_SUPER_VALUE_POW: number;
|
// MAX_SUPER_VALUE_POW: number;
|
||||||
GetHexFromAddres: Function;
|
// GetHexFromAddres: Function;
|
||||||
GetArr32FromHex: Function;
|
// GetArr32FromHex: Function;
|
||||||
GetAddresFromHex: Function;
|
// GetAddresFromHex: Function;
|
||||||
GetHexAddresFromPublicKey: Function;
|
// GetHexAddresFromPublicKey: Function;
|
||||||
GetHexFromArr: Function;
|
// GetHexFromArr: Function;
|
||||||
GetArrFromHex: Function;
|
// GetArrFromHex: Function;
|
||||||
GetHexFromArrBlock: Function;
|
// GetHexFromArrBlock: Function;
|
||||||
GetPublicKeyFromAddres: Function;
|
// GetPublicKeyFromAddres: Function;
|
||||||
CheckDevelopSign: Function;
|
// CheckDevelopSign: Function;
|
||||||
CheckContextSecret: Function;
|
// CheckContextSecret: Function;
|
||||||
GetSignHash: Function;
|
// GetSignHash: Function;
|
||||||
GetVerifyHash: Function;
|
// GetVerifyHash: Function;
|
||||||
GetKeyPair: Function;
|
// GetKeyPair: Function;
|
||||||
GetKeyPairTest: Function;
|
// GetKeyPairTest: Function;
|
||||||
GetHashWithValues: Function;
|
// GetHashWithValues: Function;
|
||||||
CreateNoncePOWExtern: Function;
|
// CreateNoncePOWExtern: Function;
|
||||||
CreateNoncePOWExternMinPower: Function;
|
// CreateNoncePOWExternMinPower: Function;
|
||||||
CreateNoncePOWInner: Function;
|
// CreateNoncePOWInner: Function;
|
||||||
CreateAddrPOW: Function;
|
// CreateAddrPOW: Function;
|
||||||
CalcMerkl3FromArray: Function;
|
// CalcMerkl3FromArray: Function;
|
||||||
CalcMerkl0FromArray: Function;
|
// CalcMerkl0FromArray: Function;
|
||||||
ClientHex: Function;
|
// ClientHex: Function;
|
||||||
CalcHash3FromArray: Function;
|
// CalcHash3FromArray: Function;
|
||||||
CalcHashFromArray: Function;
|
// CalcHashFromArray: Function;
|
||||||
CalcMerklFromArray: Function;
|
// CalcMerklFromArray: Function;
|
||||||
CalcTreeHashFromArrBody: Function;
|
// CalcTreeHashFromArrBody: Function;
|
||||||
UpdateMerklTree: Function;
|
// UpdateMerklTree: Function;
|
||||||
GetMerkleProof: Function;
|
// GetMerkleProof: Function;
|
||||||
CheckMerkleProof: Function;
|
// CheckMerkleProof: Function;
|
||||||
IsZeroArr: Function;
|
// IsZeroArr: Function;
|
||||||
GetHashWithNonce: Function;
|
// GetHashWithNonce: Function;
|
||||||
GetPowPower: Function;
|
// GetPowPower: Function;
|
||||||
GetArrFromValue: Function;
|
// GetArrFromValue: Function;
|
||||||
GetPowValue: Function;
|
// GetPowValue: Function;
|
||||||
Mesh: Function;
|
// Mesh: Function;
|
||||||
Encrypt: Function;
|
// Encrypt: Function;
|
||||||
Decrypt: Function;
|
// Decrypt: Function;
|
||||||
toUTF8Array: Function;
|
// toUTF8Array: Function;
|
||||||
Utf8ArrayToStr: Function;
|
// Utf8ArrayToStr: Function;
|
||||||
GetArrFromStr: Function;
|
// GetArrFromStr: Function;
|
||||||
IsDeveloperAccount: Function;
|
// IsDeveloperAccount: Function;
|
||||||
DEVELOP_PUB_KEY_ARR: Buffer[] | string[];
|
// DEVELOP_PUB_KEY_ARR: Buffer[] | string[];
|
||||||
DEVELOP_PUB_KEY: any;
|
// DEVELOP_PUB_KEY: any;
|
||||||
DEVELOP_PUB_KEY0: Buffer;
|
// DEVELOP_PUB_KEY0: Buffer;
|
||||||
ARR_PUB_KEY: any;
|
// ARR_PUB_KEY: any;
|
||||||
//#endregion
|
// //#endregion
|
||||||
|
|
||||||
//#region log-strict.ts
|
//#region log-strict.ts
|
||||||
CheckSizeLogFile: Function;
|
CheckSizeLogFile: Function;
|
||||||
|
Loading…
Reference in New Issue
Block a user