feat: separate Server and Client

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2019-07-22 16:43:50 +08:00
parent 9c300cd191
commit da3afe1110
8 changed files with 186 additions and 177 deletions

View File

@@ -1353,14 +1353,14 @@ export default class CConsensus extends CBlock {
var BlockMining = this.GetBlock(msg.BlockNum);
if (!BlockMining) {
teraManager.SendToWebClient({
msg: msg,
BlockNum: msg.BlockNum,
error: '!BlockMining'
})
return;
}
if (!BlockMining.StartMining || BlockMining.bSave) {
teraManager.SendToWebClient({
msg: msg,
BlockNum: msg.BlockNum,
error: `!BlockMining.StartMining ${BlockMining.StartMining} || BlockMining.bSave ${BlockMining.bSave}`
})
return;
@@ -1414,7 +1414,7 @@ export default class CConsensus extends CBlock {
Object.assign(webmsg, {
HashCount,
Power,
Num: msg.NodeNum
NodeNum: msg.NodeNum
})
teraManager.SendToWebClient(webmsg)
}, 1)

View File

@@ -35,9 +35,9 @@ const WorkStructHeader2 = {};
const DEFAULT_DB_VERSION = 2;
import CCode from '../code'
export default class CDB extends CCode {
DBHeader100
BlockNumDB
BlockNumDBMin
DBHeader100: DBRow
BlockNumDB: number
BlockNumDBMin: number
CurrentBlockNum
CheckOnStartComplete
UseTruncateBlockDB
@@ -501,8 +501,7 @@ export default class CDB extends CCode {
bytesRead = fs.readSync(FileItem.fd, BufRead, 0, BufRead.length, Position)
Block = global.BufLib.GetObjectFromBuffer(BufRead, FORMAT_STREAM_HEADER, WorkStructStreamHeader)
if (Block.VersionDB !== global.DB_VERSION) {
throw ("ERROR Block.VersionDB");
return undefined;
throw (`ERROR Position: ${Position} Block.VersionDB: ${Block.VersionDB}`);
}
Block.FilePos = Position
Block.VersionDB = global.DB_VERSION

View File

@@ -381,11 +381,12 @@ global.CreateEval = CreateEval;
var CPU_Count = os.cpus().length;
function GetCountMiningCPU() {
if (global.COUNT_MINING_CPU)
return global.COUNT_MINING_CPU;
else {
return CPU_Count - 1;
}
return global.COUNT_MINING_CPU
// if (global.COUNT_MINING_CPU)
// return global.COUNT_MINING_CPU;
// else {
// return CPU_Count - 1;
// }
};
global.GetCountMiningCPU = GetCountMiningCPU;
var AddTrMap: any = {};