1
0
forked from circlecloud/tera

feat: alpine 0.0.1 version complate

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2019-07-11 13:35:16 +08:00
parent 63536569cf
commit 13607ba157
38 changed files with 1376 additions and 1064 deletions

View File

@ -18,10 +18,13 @@
"clean": "npx rimraf dist",
"prebuild": "yarn clean",
"watch": "npx tsc --watch",
"postbuild": "cp src/HTML/* dist/HTML/ -rf",
"build": "npx tsc",
"start": "node dist/run-node.js"
},
"dependencies": {
"@types/bintrees": "^1.0.2",
"@types/secp256k1": "^3.5.0",
"bintrees": "^1.0.2",
"greenlock": "^2.6.7",
"ntp-client": "^0.5.3",
@ -36,4 +39,4 @@
"ts-node-dev": "^1.0.0-pre.40",
"typescript": "^3.5.3"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,7 +31,7 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
}(), $jscomp.initSymbolIterator = function() {
$jscomp.initSymbol();
var t = $jscomp.global.Symbol.iterator;
t || (t = $jscomp.global.Symbol.iterator = $jscomp.global.Symbol("iterator")), "function" != typeof Array.prototype[t] && $jscomp.defineProperty(Array.prototype,
t = t || ($jscomp.global.Symbol.iterator = $jscomp.global.Symbol("iterator")), "function" != typeof Array.prototype[t] && $jscomp.defineProperty(Array.prototype,
t, {
configurable: !0, writable: !0, value: function() {
return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this));
@ -41,7 +41,7 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
}, $jscomp.initSymbolAsyncIterator = function() {
$jscomp.initSymbol();
var t = $jscomp.global.Symbol.asyncIterator;
t || (t = $jscomp.global.Symbol.asyncIterator = $jscomp.global.Symbol("asyncIterator")), $jscomp.initSymbolAsyncIterator = function() {
t = t || ($jscomp.global.Symbol.asyncIterator = $jscomp.global.Symbol("asyncIterator")), $jscomp.initSymbolAsyncIterator = function() {
};
}, $jscomp.iteratorPrototype = function(t) {
return $jscomp.initSymbolIterator(), (t = { next: t })[$jscomp.global.Symbol.iterator] = function() {
@ -97,7 +97,7 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
}, r.fromByteArray = function(t) {
for (var e = t.length, r = e % 3, i = [], n = 0, s = e - r; n < s; n += 16383)
i.push(o(t, n, s < n + 16383 ? s : n + 16383));
return 1 === r ? (t = t[e - 1], i.push(h[t >> 2] + h[t << 4 & 63] + "==")) : 2 === r && (t = (t[e - 2] << 8) + t[e - 1], i.push(h[t >> 10] + h[t >> 4 & 63] + h[t << 2 & 63] + "=")),
return 1 == r ? (t = t[e - 1], i.push(h[t >> 2] + h[t << 4 & 63] + "==")) : 2 == r && (t = (t[e - 2] << 8) + t[e - 1], i.push(h[t >> 10] + h[t >> 4 & 63] + h[t << 2 & 63] + "=")),
i.join("");
};
var h = [], u = [], l = "undefined" != typeof Uint8Array ? Uint8Array : Array;
@ -322,7 +322,7 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
throw new RangeError("Index out of range");
};
function g(t, e, r, i, n, s) {
function g(t, e, r, i) {
if (r + i > t.length)
throw new RangeError("Index out of range");
if (r < 0)
@ -527,7 +527,7 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
return "";
if ((r >>>= 0) <= (e >>>= 0))
return "";
for (t || (t = "utf8"); ;)
for (t = t || "utf8"; ;)
switch (t) {
case "hex":
for (t = e, e = r, r = this.length, (!t || t < 0) && (t = 0), (!e || e < 0 || r < e) && (e = r), i = "", r = t; r < e; ++r)
@ -608,7 +608,7 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
var n = this.length - e;
if ((void 0 === r || n < r) && (r = n), 0 < t.length && (r < 0 || e < 0) || e > this.length)
throw new RangeError("Attempt to write outside buffer bounds");
for (i || (i = "utf8"), n = !1; ;)
for (i = i || "utf8", n = !1; ;)
switch (i) {
case "hex":
t:
@ -768,8 +768,7 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
}, h.prototype.copy = function(t, e, r, i) {
if (!h.isBuffer(t))
throw new TypeError("argument should be a Buffer");
if (r || (r = 0), i || 0 === i || (i = this.length), e >= t.length && (e = t.length), e || (e = 0), 0 < i && i < r && (i = r),
i === r || 0 === t.length || 0 === this.length)
if (r = r || 0, i || 0 === i || (i = this.length), e >= t.length && (e = t.length), e = e || 0, 0 < i && i < r && (i = r), i === r || 0 === t.length || 0 === this.length)
return 0;
if (e < 0)
throw new RangeError("targetStart out of bounds");
@ -805,7 +804,7 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
throw new RangeError("Out of range index");
if (r <= e)
return this;
if (e >>>= 0, r = void 0 === r ? this.length : r >>> 0, t || (t = 0), "number" == typeof t)
if (e >>>= 0, r = void 0 === r ? this.length : r >>> 0, "number" == typeof (t = t || 0))
for (i = e; i < r; ++i)
this[i] = t;
else {
@ -926,7 +925,8 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
return r;
};
var l = Object.create || function(t) {
var e = function() {
function e() {
};
return e.prototype = t, new e;
}, f = Object.keys || function(t) {
@ -1126,7 +1126,8 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
t.super_ = e, t.prototype = Object.create(e.prototype, { constructor: { value: t, enumerable: !1, writable: !0, configurable: !0 } });
} : function(t, e) {
t.super_ = e;
var r = function() {
function r() {
};
r.prototype = e.prototype, t.prototype = new r, t.prototype.constructor = t;
};
@ -1333,22 +1334,22 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
r(null, t);
};
}, { "./_stream_transform": 16, "core-util-is": 4, inherits: 7 }], 15: [function(L, k, t) {
(function(m, t) {
(function(p, t) {
function e(t, e) {
t = t || {};
var r = e instanceof (p = p || L("./_stream_duplex"));
var r = e instanceof (b = b || L("./_stream_duplex"));
this.objectMode = !!t.objectMode, r && (this.objectMode = this.objectMode || !!t.readableObjectMode);
var i = t.highWaterMark, n = t.readableHighWaterMark, s = this.objectMode ? 16 : 16384;
this.highWaterMark = i || 0 === i ? i : r && (n || 0 === n) ? n : s, this.highWaterMark = Math.floor(this.highWaterMark), this.buffer = new B,
this.length = 0, this.pipes = null, this.pipesCount = 0, this.flowing = null, this.reading = this.endEmitted = this.ended = !1,
this.sync = !0, this.destroyed = this.resumeScheduled = this.readableListening = this.emittedReadable = this.needReadable = !1,
this.defaultEncoding = t.defaultEncoding || "utf8", this.awaitDrain = 0, this.readingMore = !1, this.encoding = this.decoder = null,
t.encoding && (A || (A = L("string_decoder/").StringDecoder), this.decoder = new A(t.encoding), this.encoding = t.encoding);
t.encoding && (A = A || L("string_decoder/").StringDecoder, this.decoder = new A(t.encoding), this.encoding = t.encoding);
};
function r(t) {
if (p = p || L("./_stream_duplex"), !(this instanceof r))
if (b = b || L("./_stream_duplex"), !(this instanceof r))
return new r(t);
this._readableState = new e(t, this), this.readable = !0, t && ("function" == typeof t.read && (this._read = t.read), "function" == typeof t.destroy && (this._destroy = t.destroy)),
w.call(this);
@ -1368,14 +1369,14 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
a ? t.emit("error", a) : s.objectMode || e && 0 < e.length ? ("string" == typeof e || s.objectMode || Object.getPrototypeOf(e) === v.prototype || (e = v.from(e)),
i ? s.endEmitted ? t.emit("error", Error("stream.unshift() after end event")) : h(t, s, e, !0) : s.ended ? t.emit("error",
Error("stream.push() after EOF")) : (s.reading = !1, s.decoder && !r ? (e = s.decoder.write(e), s.objectMode || 0 !== e.length ? h(t,
s, e, !1) : s.readingMore || (s.readingMore = !0, b.nextTick(l, t, s))) : h(t, s, e, !1))) : i || (s.reading = !1);
s, e, !1) : s.readingMore || (s.readingMore = !0, g.nextTick(l, t, s))) : h(t, s, e, !1))) : i || (s.reading = !1);
}
return !s.ended && (s.needReadable || s.length < s.highWaterMark || 0 === s.length);
};
function h(t, e, r, i) {
e.flowing && 0 === e.length && !e.sync ? (t.emit("data", r), t.read(0)) : (e.length += e.objectMode ? 1 : r.length, i ? e.buffer.unshift(r) : e.buffer.push(r),
e.needReadable && u(t)), e.readingMore || (e.readingMore = !0, b.nextTick(l, t, e));
e.needReadable && u(t)), e.readingMore || (e.readingMore = !0, g.nextTick(l, t, e));
};
function s(t, e) {
@ -1394,11 +1395,11 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
function u(t) {
var e = t._readableState;
e.needReadable = !1, e.emittedReadable || (I("emitReadable", e.flowing), e.emittedReadable = !0, e.sync ? b.nextTick(i, t) : i(t));
e.needReadable = !1, e.emittedReadable || (I("emitReadable", e.flowing), e.emittedReadable = !0, e.sync ? g.nextTick(i, t) : i(t));
};
function i(t) {
I("emit readable"), t.emit("readable"), _(t);
I("emit readable"), t.emit("readable"), m(t);
};
function l(t, e) {
@ -1413,10 +1414,10 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
};
function a(t, e) {
e.reading || (I("resume read 0"), t.read(0)), e.resumeScheduled = !1, e.awaitDrain = 0, t.emit("resume"), _(t), e.flowing && !e.reading && t.read(0);
e.reading || (I("resume read 0"), t.read(0)), e.resumeScheduled = !1, e.awaitDrain = 0, t.emit("resume"), m(t), e.flowing && !e.reading && t.read(0);
};
function _(t) {
function m(t) {
var e = t._readableState;
for (I("flow", e.flowing); e.flowing && null !== t.read(););
};
@ -1471,22 +1472,22 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
var e = t._readableState;
if (0 < e.length)
throw Error('"endReadable()" called on non-empty stream');
e.endEmitted || (e.ended = !0, b.nextTick(d, e, t));
e.endEmitted || (e.ended = !0, g.nextTick(d, e, t));
};
function d(t, e) {
t.endEmitted || 0 !== t.length || (t.endEmitted = !0, e.readable = !1, e.emit("end"));
};
function g(t, e) {
function _(t, e) {
for (var r = 0, i = t.length; r < i; r++)
if (t[r] === e)
return r;
return - 1;
};
var b = L("process-nextick-args");
var g = L("process-nextick-args");
k.exports = r;
var p, y = L("isarray");
var b, y = L("isarray");
r.ReadableState = e, L("events");
var w = L("./internal/streams/stream"), v = L("safe-buffer").Buffer, M = t.Uint8Array || function() {
}, E = L("core-util-is");
@ -1517,7 +1518,7 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
}, r.prototype.isPaused = function() {
return !1 === this._readableState.flowing;
}, r.prototype.setEncoding = function(t) {
return A || (A = L("string_decoder/").StringDecoder), this._readableState.decoder = new A(t), this._readableState.encoding = t,
return A = A || L("string_decoder/").StringDecoder, this._readableState.decoder = new A(t), this._readableState.encoding = t,
this;
}, r.prototype.read = function(t) {
I("read", t), t = parseInt(t, 10);
@ -1541,8 +1542,8 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
};
function s(t) {
I("ondata"), (p = !1) !== i.write(t) || p || ((1 === f.pipesCount && f.pipes === i || 1 < f.pipesCount && - 1 !== g(f.pipes,
i)) && !d && (I("false write response, pause", l._readableState.awaitDrain), l._readableState.awaitDrain++ , p = !0), l.pause());
I("ondata"), (r = !1) !== i.write(t) || r || ((1 === f.pipesCount && f.pipes === i || 1 < f.pipesCount && - 1 !== _(f.pipes,
i)) && !d && (I("false write response, pause", l._readableState.awaitDrain), l._readableState.awaitDrain++ , r = !0), l.pause());
};
function o(t) {
@ -1572,19 +1573,21 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
f.pipes.push(i);
}
f.pipesCount += 1, I("pipe count=%d opts=%j", f.pipesCount, t);
var e = t && !1 === t.end || i === m.stdout || i === m.stderr ? u : n;
f.endEmitted ? b.nextTick(e) : l.once("end", e), i.on("unpipe", function t(e, r) {
var e = t && !1 === t.end || i === p.stdout || i === p.stderr ? u : n;
f.endEmitted ? g.nextTick(e) : l.once("end", e), i.on("unpipe", function t(e, r) {
I("onunpipe"), e === l && r && !1 === r.hasUnpiped && (r.hasUnpiped = !0, I("cleanup"), i.removeListener("close", a), i.removeListener("finish",
h), i.removeListener("drain", c), i.removeListener("error", o), i.removeListener("unpipe", t), l.removeListener("end", n),
l.removeListener("end", u), l.removeListener("data", s), d = !0, !f.awaitDrain || i._writableState && !i._writableState.needDrain || c());
});
var r, c = (r = l, function() {
var t = r._readableState;
I("pipeOnDrain", t.awaitDrain), t.awaitDrain && t.awaitDrain-- , 0 === t.awaitDrain && r.listeners("data").length && (t.flowing = !0,
_(r));
});
var c = function(e) {
return function() {
var t = e._readableState;
I("pipeOnDrain", t.awaitDrain), t.awaitDrain && t.awaitDrain-- , 0 === t.awaitDrain && e.listeners("data").length && (t.flowing = !0,
m(e));
};
}(l);
i.on("drain", c);
var d = !1, p = !1;
var d = !1, r = !1;
return l.on("data", s), function(t, e, r) {
if ("function" == typeof t.prependListener)
return t.prependListener(e, r);
@ -1596,10 +1599,10 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
if (0 === e.pipesCount)
return this;
if (1 === e.pipesCount)
return t && t !== e.pipes || (t || (t = e.pipes), e.pipes = null, e.pipesCount = 0, e.flowing = !1, t && t.emit("unpipe", this,
return t && t !== e.pipes || (t = t || e.pipes, e.pipes = null, e.pipesCount = 0, e.flowing = !1, t && t.emit("unpipe", this,
r)), this;
if (t)
return - 1 === (i = g(e.pipes, t)) || (e.pipes.splice(i, 1), --e.pipesCount, 1 === e.pipesCount && (e.pipes = e.pipes[0]),
return - 1 === (i = _(e.pipes, t)) || (e.pipes.splice(i, 1), --e.pipesCount, 1 === e.pipesCount && (e.pipes = e.pipes[0]),
t.emit("unpipe", this, r)), this;
t = e.pipes;
var i = e.pipesCount;
@ -1613,13 +1616,13 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
else
if ("readable" === t) {
var i = this._readableState;
i.endEmitted || i.readableListening || (i.readableListening = i.needReadable = !0, i.emittedReadable = !1, i.reading ? i.length && u(this) : b.nextTick(o,
i.endEmitted || i.readableListening || (i.readableListening = i.needReadable = !0, i.emittedReadable = !1, i.reading ? i.length && u(this) : g.nextTick(o,
this));
}
return r;
}, r.prototype.resume = function() {
var t = this._readableState;
return t.flowing || (I("resume"), t.flowing = !0, t.resumeScheduled || (t.resumeScheduled = !0, b.nextTick(a, this, t))), this;
return t.flowing || (I("resume"), t.flowing = !0, t.resumeScheduled || (t.resumeScheduled = !0, g.nextTick(a, this, t))), this;
}, r.prototype.pause = function() {
return I("call pause flowing=%j", this._readableState.flowing), !1 !== this._readableState.flowing && (I("pause"), this._readableState.flowing = !1,
this.emit("pause")), this;
@ -1830,7 +1833,7 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
}, n.prototype.write = function(t, e, r) {
var i, n = this._writableState, s = !1;
if ((i = !n.objectMode) && (i = t, i = b.isBuffer(i) || i instanceof y), i && !b.isBuffer(t) && (t = b.from(t)), "function" == typeof e && (r = e,
e = null), i ? e = "buffer" : e || (e = n.defaultEncoding), "function" != typeof r && (r = l), n.ended)
e = null), e = i ? "buffer" : e || n.defaultEncoding, "function" != typeof r && (r = l), n.ended)
n = r, r = Error("write after end"), this.emit("error", r), d.nextTick(n, r);
else {
var o;
@ -1882,41 +1885,39 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
inherits: 7, "process-nextick-args": 10, "safe-buffer": 25, timers: 28, "util-deprecate": 29
}], 18: [function(t, e, r) {
var i = t("safe-buffer").Buffer, n = t("util");
e.exports = function() {
function t() {
if (!(this instanceof t))
throw new TypeError("Cannot call a class as a function");
this.tail = this.head = null, this.length = 0;
};
return t.prototype.push = function(t) {
t = { data: t, next: null }, 0 < this.length ? this.tail.next = t : this.head = t, this.tail = t, ++this.length;
}, t.prototype.unshift = function(t) {
t = { data: t, next: this.head }, 0 === this.length && (this.tail = t), this.head = t, ++this.length;
}, t.prototype.shift = function() {
if (0 !== this.length) {
var t = this.head.data;
return this.head = 1 === this.length ? this.tail = null : this.head.next, --this.length, t;
}
}, t.prototype.clear = function() {
this.head = this.tail = null, this.length = 0;
}, t.prototype.join = function(t) {
if (0 === this.length)
return "";
for (var e = this.head, r = "" + e.data; e = e.next;)
r += t + e.data;
return r;
}, t.prototype.concat = function(t) {
if (0 === this.length)
return i.alloc(0);
if (1 === this.length)
return this.head.data;
t = i.allocUnsafe(t >>> 0);
for (var e = this.head, r = 0; e;)
e.data.copy(t, r), r += e.data.length, e = e.next;
return t;
}, t;
}(), n && n.inspect && n.inspect.custom && (e.exports.prototype[n.inspect.custom] = function() {
function s() {
if (!(this instanceof s))
throw new TypeError("Cannot call a class as a function");
this.tail = this.head = null, this.length = 0;
};
e.exports = (s.prototype.push = function(t) {
t = { data: t, next: null }, 0 < this.length ? this.tail.next = t : this.head = t, this.tail = t, ++this.length;
}, s.prototype.unshift = function(t) {
t = { data: t, next: this.head }, 0 === this.length && (this.tail = t), this.head = t, ++this.length;
}, s.prototype.shift = function() {
if (0 !== this.length) {
var t = this.head.data;
return this.head = 1 === this.length ? this.tail = null : this.head.next, --this.length, t;
}
}, s.prototype.clear = function() {
this.head = this.tail = null, this.length = 0;
}, s.prototype.join = function(t) {
if (0 === this.length)
return "";
for (var e = this.head, r = "" + e.data; e = e.next;)
r += t + e.data;
return r;
}, s.prototype.concat = function(t) {
if (0 === this.length)
return i.alloc(0);
if (1 === this.length)
return this.head.data;
t = i.allocUnsafe(t >>> 0);
for (var e = this.head, r = 0; e;)
e.data.copy(t, r), r += e.data.length, e = e.next;
return t;
}, s), n && n.inspect && n.inspect.custom && (e.exports.prototype[n.inspect.custom] = function() {
var t = n.inspect({ length: this.length });
return this.constructor.name + " " + t;
});
@ -2119,7 +2120,7 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
function h(t, e) {
var r = (t.length - e) % 3;
return 0 === r ? t.toString("base64", e) : (this.lastNeed = 3 - r, this.lastTotal = 3, 1 === r ? this.lastChar[0] = t[t.length - 1] : (this.lastChar[0] = t[t.length - 2],
return 0 == r ? t.toString("base64", e) : (this.lastNeed = 3 - r, this.lastTotal = 3, 1 == r ? this.lastChar[0] = t[t.length - 1] : (this.lastChar[0] = t[t.length - 2],
this.lastChar[1] = t[t.length - 1]), t.toString("base64", e, t.length - r));
};
@ -2683,7 +2684,7 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
return r.words = [0], r.length = 1, r;
for (var i = 0, n = 0; i < t.length; ++i)
n = t.words[i] * e + n, r.words[i] = 67108863 & n, n = n / 67108864 | 0;
return r.length = 0 < n ? (r.words[i] = n, t.length + 1) : t.length, r;
return 0 < n ? (r.words[i] = n, r.length = t.length + 1) : r.length = t.length, r;
}, l.prototype.umul = function(t) {
var e = new l;
return e.words = Array(this.length + t.length), 10 === this.length && 10 === t.length ? l.umulTo10x10(this, t, e) : 1 === this.length ? l.umulnTo(t,
@ -2841,95 +2842,95 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
N = 8191 & U;
var D = U >>> 13, q = 0 | n[8];
U = 8191 & q;
var K = q >>> 13, V = 8191 & (n = 0 | n[9]), Y = n >>> 13;
var K = q >>> 13, V = 8191 & (n = 0 | n[9]), z = n >>> 13;
r.length = 19;
var z = Math.imul(o, I);
var Y = Math.imul(o, I);
n = Math.imul(o, A);
var $ = t + z + ((8191 & (n += Math.imul(a, I))) << 13);
t = (q = Math.imul(a, A)) + (n >>> 13) + ($ >>> 26), $ &= 67108863, z = Math.imul(s, I), n = Math.imul(s, A), n += Math.imul(u,
I), q = Math.imul(u, A), z += Math.imul(o, S), n += Math.imul(o, x);
var W = t + z + ((8191 & (n += Math.imul(a, S))) << 13);
t = (q += Math.imul(a, x)) + (n >>> 13) + (W >>> 26), W &= 67108863, z = Math.imul(h, I), n = Math.imul(h, A), n += Math.imul(f,
I), q = Math.imul(f, A), z += Math.imul(s, S), n += Math.imul(s, x), n += Math.imul(u, S), q += Math.imul(u, x), z += Math.imul(o,
var $ = t + Y + ((8191 & (n += Math.imul(a, I))) << 13);
t = (q = Math.imul(a, A)) + (n >>> 13) + ($ >>> 26), $ &= 67108863, Y = Math.imul(s, I), n = Math.imul(s, A), n += Math.imul(u,
I), q = Math.imul(u, A), Y += Math.imul(o, S), n += Math.imul(o, x);
var W = t + Y + ((8191 & (n += Math.imul(a, S))) << 13);
t = (q += Math.imul(a, x)) + (n >>> 13) + (W >>> 26), W &= 67108863, Y = Math.imul(h, I), n = Math.imul(h, A), n += Math.imul(f,
I), q = Math.imul(f, A), Y += Math.imul(s, S), n += Math.imul(s, x), n += Math.imul(u, S), q += Math.imul(u, x), Y += Math.imul(o,
B), n += Math.imul(o, k);
var Z = t + z + ((8191 & (n += Math.imul(a, B))) << 13);
t = (q += Math.imul(a, k)) + (n >>> 13) + (Z >>> 26), Z &= 67108863, z = Math.imul(l, I), n = Math.imul(l, A), n += Math.imul(d,
I), q = Math.imul(d, A), z += Math.imul(h, S), n += Math.imul(h, x), n += Math.imul(f, S), q += Math.imul(f, x), z += Math.imul(s,
B), n += Math.imul(s, k), n += Math.imul(u, B), q += Math.imul(u, k), z += Math.imul(o, L), n += Math.imul(o, C);
var G = t + z + ((8191 & (n += Math.imul(a, L))) << 13);
t = (q += Math.imul(a, C)) + (n >>> 13) + (G >>> 26), G &= 67108863, z = Math.imul(c, I), n = Math.imul(c, A), n += Math.imul(m,
I), q = Math.imul(m, A), z += Math.imul(l, S), n += Math.imul(l, x), n += Math.imul(d, S), q += Math.imul(d, x), z += Math.imul(h,
B), n += Math.imul(h, k), n += Math.imul(f, B), q += Math.imul(f, k), z += Math.imul(s, L), n += Math.imul(s, C), n += Math.imul(u,
L), q += Math.imul(u, C), z += Math.imul(o, T), n += Math.imul(o, j);
var H = t + z + ((8191 & (n += Math.imul(a, T))) << 13);
t = (q += Math.imul(a, j)) + (n >>> 13) + (H >>> 26), H &= 67108863, z = Math.imul(p, I), n = Math.imul(p, A), n += Math.imul(g,
I), q = Math.imul(g, A), z += Math.imul(c, S), n += Math.imul(c, x), n += Math.imul(m, S), q += Math.imul(m, x), z += Math.imul(l,
B), n += Math.imul(l, k), n += Math.imul(d, B), q += Math.imul(d, k), z += Math.imul(h, L), n += Math.imul(h, C), n += Math.imul(f,
L), q += Math.imul(f, C), z += Math.imul(s, T), n += Math.imul(s, j), n += Math.imul(u, T), q += Math.imul(u, j), z += Math.imul(o,
var Z = t + Y + ((8191 & (n += Math.imul(a, B))) << 13);
t = (q += Math.imul(a, k)) + (n >>> 13) + (Z >>> 26), Z &= 67108863, Y = Math.imul(l, I), n = Math.imul(l, A), n += Math.imul(d,
I), q = Math.imul(d, A), Y += Math.imul(h, S), n += Math.imul(h, x), n += Math.imul(f, S), q += Math.imul(f, x), Y += Math.imul(s,
B), n += Math.imul(s, k), n += Math.imul(u, B), q += Math.imul(u, k), Y += Math.imul(o, L), n += Math.imul(o, C);
var G = t + Y + ((8191 & (n += Math.imul(a, L))) << 13);
t = (q += Math.imul(a, C)) + (n >>> 13) + (G >>> 26), G &= 67108863, Y = Math.imul(c, I), n = Math.imul(c, A), n += Math.imul(m,
I), q = Math.imul(m, A), Y += Math.imul(l, S), n += Math.imul(l, x), n += Math.imul(d, S), q += Math.imul(d, x), Y += Math.imul(h,
B), n += Math.imul(h, k), n += Math.imul(f, B), q += Math.imul(f, k), Y += Math.imul(s, L), n += Math.imul(s, C), n += Math.imul(u,
L), q += Math.imul(u, C), Y += Math.imul(o, T), n += Math.imul(o, j);
var H = t + Y + ((8191 & (n += Math.imul(a, T))) << 13);
t = (q += Math.imul(a, j)) + (n >>> 13) + (H >>> 26), H &= 67108863, Y = Math.imul(p, I), n = Math.imul(p, A), n += Math.imul(g,
I), q = Math.imul(g, A), Y += Math.imul(c, S), n += Math.imul(c, x), n += Math.imul(m, S), q += Math.imul(m, x), Y += Math.imul(l,
B), n += Math.imul(l, k), n += Math.imul(d, B), q += Math.imul(d, k), Y += Math.imul(h, L), n += Math.imul(h, C), n += Math.imul(f,
L), q += Math.imul(f, C), Y += Math.imul(s, T), n += Math.imul(s, j), n += Math.imul(u, T), q += Math.imul(u, j), Y += Math.imul(o,
F), n += Math.imul(o, R);
var J = t + z + ((8191 & (n += Math.imul(a, F))) << 13);
t = (q += Math.imul(a, R)) + (n >>> 13) + (J >>> 26), J &= 67108863, z = Math.imul(_, I), n = Math.imul(_, A), n += Math.imul(y,
I), q = Math.imul(y, A), z += Math.imul(p, S), n += Math.imul(p, x), n += Math.imul(g, S), q += Math.imul(g, x), z += Math.imul(c,
B), n += Math.imul(c, k), n += Math.imul(m, B), q += Math.imul(m, k), z += Math.imul(l, L), n += Math.imul(l, C), n += Math.imul(d,
L), q += Math.imul(d, C), z += Math.imul(h, T), n += Math.imul(h, j), n += Math.imul(f, T), q += Math.imul(f, j), z += Math.imul(s,
F), n += Math.imul(s, R), n += Math.imul(u, F), q += Math.imul(u, R), z += Math.imul(o, O), n += Math.imul(o, P);
var X = t + z + ((8191 & (n += Math.imul(a, O))) << 13);
t = (q += Math.imul(a, P)) + (n >>> 13) + (X >>> 26), X &= 67108863, z = Math.imul(b, I), n = Math.imul(b, A), n += Math.imul(v,
I), q = Math.imul(v, A), z += Math.imul(_, S), n += Math.imul(_, x), n += Math.imul(y, S), q += Math.imul(y, x), z += Math.imul(p,
B), n += Math.imul(p, k), n += Math.imul(g, B), q += Math.imul(g, k), z += Math.imul(c, L), n += Math.imul(c, C), n += Math.imul(m,
L), q += Math.imul(m, C), z += Math.imul(l, T), n += Math.imul(l, j), n += Math.imul(d, T), q += Math.imul(d, j), z += Math.imul(h,
F), n += Math.imul(h, R), n += Math.imul(f, F), q += Math.imul(f, R), z += Math.imul(s, O), n += Math.imul(s, P), n += Math.imul(u,
O), q += Math.imul(u, P), z += Math.imul(o, N), n += Math.imul(o, D);
var Q = t + z + ((8191 & (n += Math.imul(a, N))) << 13);
t = (q += Math.imul(a, D)) + (n >>> 13) + (Q >>> 26), Q &= 67108863, z = Math.imul(w, I), n = Math.imul(w, A), n += Math.imul(M,
I), q = Math.imul(M, A), z += Math.imul(b, S), n += Math.imul(b, x), n += Math.imul(v, S), q += Math.imul(v, x), z += Math.imul(_,
B), n += Math.imul(_, k), n += Math.imul(y, B), q += Math.imul(y, k), z += Math.imul(p, L), n += Math.imul(p, C), n += Math.imul(g,
L), q += Math.imul(g, C), z += Math.imul(c, T), n += Math.imul(c, j), n += Math.imul(m, T), q += Math.imul(m, j), z += Math.imul(l,
F), n += Math.imul(l, R), n += Math.imul(d, F), q += Math.imul(d, R), z += Math.imul(h, O), n += Math.imul(h, P), n += Math.imul(f,
O), q += Math.imul(f, P), z += Math.imul(s, N), n += Math.imul(s, D), n += Math.imul(u, N), q += Math.imul(u, D), z += Math.imul(o,
var J = t + Y + ((8191 & (n += Math.imul(a, F))) << 13);
t = (q += Math.imul(a, R)) + (n >>> 13) + (J >>> 26), J &= 67108863, Y = Math.imul(_, I), n = Math.imul(_, A), n += Math.imul(y,
I), q = Math.imul(y, A), Y += Math.imul(p, S), n += Math.imul(p, x), n += Math.imul(g, S), q += Math.imul(g, x), Y += Math.imul(c,
B), n += Math.imul(c, k), n += Math.imul(m, B), q += Math.imul(m, k), Y += Math.imul(l, L), n += Math.imul(l, C), n += Math.imul(d,
L), q += Math.imul(d, C), Y += Math.imul(h, T), n += Math.imul(h, j), n += Math.imul(f, T), q += Math.imul(f, j), Y += Math.imul(s,
F), n += Math.imul(s, R), n += Math.imul(u, F), q += Math.imul(u, R), Y += Math.imul(o, O), n += Math.imul(o, P);
var X = t + Y + ((8191 & (n += Math.imul(a, O))) << 13);
t = (q += Math.imul(a, P)) + (n >>> 13) + (X >>> 26), X &= 67108863, Y = Math.imul(b, I), n = Math.imul(b, A), n += Math.imul(v,
I), q = Math.imul(v, A), Y += Math.imul(_, S), n += Math.imul(_, x), n += Math.imul(y, S), q += Math.imul(y, x), Y += Math.imul(p,
B), n += Math.imul(p, k), n += Math.imul(g, B), q += Math.imul(g, k), Y += Math.imul(c, L), n += Math.imul(c, C), n += Math.imul(m,
L), q += Math.imul(m, C), Y += Math.imul(l, T), n += Math.imul(l, j), n += Math.imul(d, T), q += Math.imul(d, j), Y += Math.imul(h,
F), n += Math.imul(h, R), n += Math.imul(f, F), q += Math.imul(f, R), Y += Math.imul(s, O), n += Math.imul(s, P), n += Math.imul(u,
O), q += Math.imul(u, P), Y += Math.imul(o, N), n += Math.imul(o, D);
var Q = t + Y + ((8191 & (n += Math.imul(a, N))) << 13);
t = (q += Math.imul(a, D)) + (n >>> 13) + (Q >>> 26), Q &= 67108863, Y = Math.imul(w, I), n = Math.imul(w, A), n += Math.imul(M,
I), q = Math.imul(M, A), Y += Math.imul(b, S), n += Math.imul(b, x), n += Math.imul(v, S), q += Math.imul(v, x), Y += Math.imul(_,
B), n += Math.imul(_, k), n += Math.imul(y, B), q += Math.imul(y, k), Y += Math.imul(p, L), n += Math.imul(p, C), n += Math.imul(g,
L), q += Math.imul(g, C), Y += Math.imul(c, T), n += Math.imul(c, j), n += Math.imul(m, T), q += Math.imul(m, j), Y += Math.imul(l,
F), n += Math.imul(l, R), n += Math.imul(d, F), q += Math.imul(d, R), Y += Math.imul(h, O), n += Math.imul(h, P), n += Math.imul(f,
O), q += Math.imul(f, P), Y += Math.imul(s, N), n += Math.imul(s, D), n += Math.imul(u, N), q += Math.imul(u, D), Y += Math.imul(o,
U), n += Math.imul(o, K);
var tt = t + z + ((8191 & (n += Math.imul(a, U))) << 13);
return t = (q += Math.imul(a, K)) + (n >>> 13) + (tt >>> 26), tt &= 67108863, z = Math.imul(i, I), n = Math.imul(i, A), n += Math.imul(E,
I), q = Math.imul(E, A), z += Math.imul(w, S), n += Math.imul(w, x), n += Math.imul(M, S), q += Math.imul(M, x), z += Math.imul(b,
B), n += Math.imul(b, k), n += Math.imul(v, B), q += Math.imul(v, k), z += Math.imul(_, L), n += Math.imul(_, C), n += Math.imul(y,
L), q += Math.imul(y, C), z += Math.imul(p, T), n += Math.imul(p, j), n += Math.imul(g, T), q += Math.imul(g, j), z += Math.imul(c,
F), n += Math.imul(c, R), n += Math.imul(m, F), q += Math.imul(m, R), z += Math.imul(l, O), n += Math.imul(l, P), n += Math.imul(d,
O), q += Math.imul(d, P), z += Math.imul(h, N), n += Math.imul(h, D), n += Math.imul(f, N), q += Math.imul(f, D), z += Math.imul(s,
U), n += Math.imul(s, K), n += Math.imul(u, U), q += Math.imul(u, K), z += Math.imul(o, V), n += Math.imul(o, Y), n += Math.imul(a,
V), t = (q += Math.imul(a, Y)) + (n >>> 13) + ((o = t + z + ((8191 & n) << 13)) >>> 26), o &= 67108863, z = Math.imul(i, S),
n = Math.imul(i, x), n += Math.imul(E, S), q = Math.imul(E, x), z += Math.imul(w, B), n += Math.imul(w, k), n += Math.imul(M,
B), q += Math.imul(M, k), z += Math.imul(b, L), n += Math.imul(b, C), n += Math.imul(v, L), q += Math.imul(v, C), z += Math.imul(_,
T), n += Math.imul(_, j), n += Math.imul(y, T), q += Math.imul(y, j), z += Math.imul(p, F), n += Math.imul(p, R), n += Math.imul(g,
F), q += Math.imul(g, R), z += Math.imul(c, O), n += Math.imul(c, P), n += Math.imul(m, O), q += Math.imul(m, P), z += Math.imul(l,
N), n += Math.imul(l, D), n += Math.imul(d, N), q += Math.imul(d, D), z += Math.imul(h, U), n += Math.imul(h, K), n += Math.imul(f,
U), q += Math.imul(f, K), z += Math.imul(s, V), n += Math.imul(s, Y), n += Math.imul(u, V), t = (q += Math.imul(u, Y)) + (n >>> 13) + ((s = t + z + ((8191 & n) << 13)) >>> 26),
s &= 67108863, z = Math.imul(i, B), n = Math.imul(i, k), n += Math.imul(E, B), q = Math.imul(E, k), z += Math.imul(w, L), n += Math.imul(w,
C), n += Math.imul(M, L), q += Math.imul(M, C), z += Math.imul(b, T), n += Math.imul(b, j), n += Math.imul(v, T), q += Math.imul(v,
j), z += Math.imul(_, F), n += Math.imul(_, R), n += Math.imul(y, F), q += Math.imul(y, R), z += Math.imul(p, O), n += Math.imul(p,
P), n += Math.imul(g, O), q += Math.imul(g, P), z += Math.imul(c, N), n += Math.imul(c, D), n += Math.imul(m, N), q += Math.imul(m,
D), z += Math.imul(l, U), n += Math.imul(l, K), n += Math.imul(d, U), q += Math.imul(d, K), z += Math.imul(h, V), n += Math.imul(h,
Y), n += Math.imul(f, V), t = (q += Math.imul(f, Y)) + (n >>> 13) + ((h = t + z + ((8191 & n) << 13)) >>> 26), h &= 67108863,
z = Math.imul(i, L), n = Math.imul(i, C), n += Math.imul(E, L), q = Math.imul(E, C), z += Math.imul(w, T), n += Math.imul(w,
j), n += Math.imul(M, T), q += Math.imul(M, j), z += Math.imul(b, F), n += Math.imul(b, R), n += Math.imul(v, F), q += Math.imul(v,
R), z += Math.imul(_, O), n += Math.imul(_, P), n += Math.imul(y, O), q += Math.imul(y, P), z += Math.imul(p, N), n += Math.imul(p,
D), n += Math.imul(g, N), q += Math.imul(g, D), z += Math.imul(c, U), n += Math.imul(c, K), n += Math.imul(m, U), q += Math.imul(m,
K), z += Math.imul(l, V), n += Math.imul(l, Y), n += Math.imul(d, V), t = (q += Math.imul(d, Y)) + (n >>> 13) + ((l = t + z + ((8191 & n) << 13)) >>> 26),
l &= 67108863, z = Math.imul(i, T), n = Math.imul(i, j), n += Math.imul(E, T), q = Math.imul(E, j), z += Math.imul(w, F), n += Math.imul(w,
R), n += Math.imul(M, F), q += Math.imul(M, R), z += Math.imul(b, O), n += Math.imul(b, P), n += Math.imul(v, O), q += Math.imul(v,
P), z += Math.imul(_, N), n += Math.imul(_, D), n += Math.imul(y, N), q += Math.imul(y, D), z += Math.imul(p, U), n += Math.imul(p,
K), n += Math.imul(g, U), q += Math.imul(g, K), z += Math.imul(c, V), n += Math.imul(c, Y), n += Math.imul(m, V), t = (q += Math.imul(m,
Y)) + (n >>> 13) + ((c = t + z + ((8191 & n) << 13)) >>> 26), c &= 67108863, z = Math.imul(i, F), n = Math.imul(i, R), n += Math.imul(E,
F), q = Math.imul(E, R), z += Math.imul(w, O), n += Math.imul(w, P), n += Math.imul(M, O), q += Math.imul(M, P), z += Math.imul(b,
N), n += Math.imul(b, D), n += Math.imul(v, N), q += Math.imul(v, D), z += Math.imul(_, U), n += Math.imul(_, K), n += Math.imul(y,
U), q += Math.imul(y, K), z += Math.imul(p, V), n += Math.imul(p, Y), n += Math.imul(g, V), t = (q += Math.imul(g, Y)) + (n >>> 13) + ((p = t + z + ((8191 & n) << 13)) >>> 26),
p &= 67108863, z = Math.imul(i, O), n = Math.imul(i, P), n += Math.imul(E, O), q = Math.imul(E, P), z += Math.imul(w, N), n += Math.imul(w,
D), n += Math.imul(M, N), q += Math.imul(M, D), z += Math.imul(b, U), n += Math.imul(b, K), n += Math.imul(v, U), q += Math.imul(v,
K), z += Math.imul(_, V), n += Math.imul(_, Y), n += Math.imul(y, V), t = (q += Math.imul(y, Y)) + (n >>> 13) + ((_ = t + z + ((8191 & n) << 13)) >>> 26),
_ &= 67108863, z = Math.imul(i, N), n = Math.imul(i, D), n += Math.imul(E, N), q = Math.imul(E, D), z += Math.imul(w, U), n += Math.imul(w,
K), n += Math.imul(M, U), q += Math.imul(M, K), z += Math.imul(b, V), n += Math.imul(b, Y), n += Math.imul(v, V), t = (q += Math.imul(v,
Y)) + (n >>> 13) + ((b = t + z + ((8191 & n) << 13)) >>> 26), b &= 67108863, z = Math.imul(i, U), n = Math.imul(i, K), n += Math.imul(E,
U), q = Math.imul(E, K), z += Math.imul(w, V), n += Math.imul(w, Y), n += Math.imul(M, V), t = (q += Math.imul(M, Y)) + (n >>> 13) + ((w = t + z + ((8191 & n) << 13)) >>> 26),
w &= 67108863, z = Math.imul(i, V), n = Math.imul(i, Y), n += Math.imul(E, V), t = (q = Math.imul(E, Y)) + (n >>> 13) + ((a = t + z + ((8191 & n) << 13)) >>> 26),
var tt = t + Y + ((8191 & (n += Math.imul(a, U))) << 13);
return t = (q += Math.imul(a, K)) + (n >>> 13) + (tt >>> 26), tt &= 67108863, Y = Math.imul(i, I), n = Math.imul(i, A), n += Math.imul(E,
I), q = Math.imul(E, A), Y += Math.imul(w, S), n += Math.imul(w, x), n += Math.imul(M, S), q += Math.imul(M, x), Y += Math.imul(b,
B), n += Math.imul(b, k), n += Math.imul(v, B), q += Math.imul(v, k), Y += Math.imul(_, L), n += Math.imul(_, C), n += Math.imul(y,
L), q += Math.imul(y, C), Y += Math.imul(p, T), n += Math.imul(p, j), n += Math.imul(g, T), q += Math.imul(g, j), Y += Math.imul(c,
F), n += Math.imul(c, R), n += Math.imul(m, F), q += Math.imul(m, R), Y += Math.imul(l, O), n += Math.imul(l, P), n += Math.imul(d,
O), q += Math.imul(d, P), Y += Math.imul(h, N), n += Math.imul(h, D), n += Math.imul(f, N), q += Math.imul(f, D), Y += Math.imul(s,
U), n += Math.imul(s, K), n += Math.imul(u, U), q += Math.imul(u, K), Y += Math.imul(o, V), n += Math.imul(o, z), n += Math.imul(a,
V), t = (q += Math.imul(a, z)) + (n >>> 13) + ((o = t + Y + ((8191 & n) << 13)) >>> 26), o &= 67108863, Y = Math.imul(i, S),
n = Math.imul(i, x), n += Math.imul(E, S), q = Math.imul(E, x), Y += Math.imul(w, B), n += Math.imul(w, k), n += Math.imul(M,
B), q += Math.imul(M, k), Y += Math.imul(b, L), n += Math.imul(b, C), n += Math.imul(v, L), q += Math.imul(v, C), Y += Math.imul(_,
T), n += Math.imul(_, j), n += Math.imul(y, T), q += Math.imul(y, j), Y += Math.imul(p, F), n += Math.imul(p, R), n += Math.imul(g,
F), q += Math.imul(g, R), Y += Math.imul(c, O), n += Math.imul(c, P), n += Math.imul(m, O), q += Math.imul(m, P), Y += Math.imul(l,
N), n += Math.imul(l, D), n += Math.imul(d, N), q += Math.imul(d, D), Y += Math.imul(h, U), n += Math.imul(h, K), n += Math.imul(f,
U), q += Math.imul(f, K), Y += Math.imul(s, V), n += Math.imul(s, z), n += Math.imul(u, V), t = (q += Math.imul(u, z)) + (n >>> 13) + ((s = t + Y + ((8191 & n) << 13)) >>> 26),
s &= 67108863, Y = Math.imul(i, B), n = Math.imul(i, k), n += Math.imul(E, B), q = Math.imul(E, k), Y += Math.imul(w, L), n += Math.imul(w,
C), n += Math.imul(M, L), q += Math.imul(M, C), Y += Math.imul(b, T), n += Math.imul(b, j), n += Math.imul(v, T), q += Math.imul(v,
j), Y += Math.imul(_, F), n += Math.imul(_, R), n += Math.imul(y, F), q += Math.imul(y, R), Y += Math.imul(p, O), n += Math.imul(p,
P), n += Math.imul(g, O), q += Math.imul(g, P), Y += Math.imul(c, N), n += Math.imul(c, D), n += Math.imul(m, N), q += Math.imul(m,
D), Y += Math.imul(l, U), n += Math.imul(l, K), n += Math.imul(d, U), q += Math.imul(d, K), Y += Math.imul(h, V), n += Math.imul(h,
z), n += Math.imul(f, V), t = (q += Math.imul(f, z)) + (n >>> 13) + ((h = t + Y + ((8191 & n) << 13)) >>> 26), h &= 67108863,
Y = Math.imul(i, L), n = Math.imul(i, C), n += Math.imul(E, L), q = Math.imul(E, C), Y += Math.imul(w, T), n += Math.imul(w,
j), n += Math.imul(M, T), q += Math.imul(M, j), Y += Math.imul(b, F), n += Math.imul(b, R), n += Math.imul(v, F), q += Math.imul(v,
R), Y += Math.imul(_, O), n += Math.imul(_, P), n += Math.imul(y, O), q += Math.imul(y, P), Y += Math.imul(p, N), n += Math.imul(p,
D), n += Math.imul(g, N), q += Math.imul(g, D), Y += Math.imul(c, U), n += Math.imul(c, K), n += Math.imul(m, U), q += Math.imul(m,
K), Y += Math.imul(l, V), n += Math.imul(l, z), n += Math.imul(d, V), t = (q += Math.imul(d, z)) + (n >>> 13) + ((l = t + Y + ((8191 & n) << 13)) >>> 26),
l &= 67108863, Y = Math.imul(i, T), n = Math.imul(i, j), n += Math.imul(E, T), q = Math.imul(E, j), Y += Math.imul(w, F), n += Math.imul(w,
R), n += Math.imul(M, F), q += Math.imul(M, R), Y += Math.imul(b, O), n += Math.imul(b, P), n += Math.imul(v, O), q += Math.imul(v,
P), Y += Math.imul(_, N), n += Math.imul(_, D), n += Math.imul(y, N), q += Math.imul(y, D), Y += Math.imul(p, U), n += Math.imul(p,
K), n += Math.imul(g, U), q += Math.imul(g, K), Y += Math.imul(c, V), n += Math.imul(c, z), n += Math.imul(m, V), t = (q += Math.imul(m,
z)) + (n >>> 13) + ((c = t + Y + ((8191 & n) << 13)) >>> 26), c &= 67108863, Y = Math.imul(i, F), n = Math.imul(i, R), n += Math.imul(E,
F), q = Math.imul(E, R), Y += Math.imul(w, O), n += Math.imul(w, P), n += Math.imul(M, O), q += Math.imul(M, P), Y += Math.imul(b,
N), n += Math.imul(b, D), n += Math.imul(v, N), q += Math.imul(v, D), Y += Math.imul(_, U), n += Math.imul(_, K), n += Math.imul(y,
U), q += Math.imul(y, K), Y += Math.imul(p, V), n += Math.imul(p, z), n += Math.imul(g, V), t = (q += Math.imul(g, z)) + (n >>> 13) + ((p = t + Y + ((8191 & n) << 13)) >>> 26),
p &= 67108863, Y = Math.imul(i, O), n = Math.imul(i, P), n += Math.imul(E, O), q = Math.imul(E, P), Y += Math.imul(w, N), n += Math.imul(w,
D), n += Math.imul(M, N), q += Math.imul(M, D), Y += Math.imul(b, U), n += Math.imul(b, K), n += Math.imul(v, U), q += Math.imul(v,
K), Y += Math.imul(_, V), n += Math.imul(_, z), n += Math.imul(y, V), t = (q += Math.imul(y, z)) + (n >>> 13) + ((_ = t + Y + ((8191 & n) << 13)) >>> 26),
_ &= 67108863, Y = Math.imul(i, N), n = Math.imul(i, D), n += Math.imul(E, N), q = Math.imul(E, D), Y += Math.imul(w, U), n += Math.imul(w,
K), n += Math.imul(M, U), q += Math.imul(M, K), Y += Math.imul(b, V), n += Math.imul(b, z), n += Math.imul(v, V), t = (q += Math.imul(v,
z)) + (n >>> 13) + ((b = t + Y + ((8191 & n) << 13)) >>> 26), b &= 67108863, Y = Math.imul(i, U), n = Math.imul(i, K), n += Math.imul(E,
U), q = Math.imul(E, K), Y += Math.imul(w, V), n += Math.imul(w, z), n += Math.imul(M, V), t = (q += Math.imul(M, z)) + (n >>> 13) + ((w = t + Y + ((8191 & n) << 13)) >>> 26),
w &= 67108863, Y = Math.imul(i, V), n = Math.imul(i, z), n += Math.imul(E, V), t = (q = Math.imul(E, z)) + (n >>> 13) + ((a = t + Y + ((8191 & n) << 13)) >>> 26),
e[0] = $, e[1] = W, e[2] = Z, e[3] = G, e[4] = H, e[5] = J, e[6] = X, e[7] = Q, e[8] = tt, e[9] = o, e[10] = s, e[11] = h,
e[12] = l, e[13] = c, e[14] = p, e[15] = _, e[16] = b, e[17] = w, e[18] = 67108863 & a, 0 !== t && (e[19] = t, r.length++),
r;
@ -2937,7 +2938,8 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
}, {}], 45: [function(t, e, r) {
function a(t, e, r) {
this.z = null === t && null === e && null === r ? (this.y = this.x = a.one, a.zero) : (this.x = t, this.y = e, r), this.zOne = this.z === a.one;
null === t && null === e && null === r ? (this.y = this.x = a.one, this.z = a.zero) : (this.x = t, this.y = e, this.z = r),
this.zOne = this.z === a.one;
};
t = t("./bn"), a.zero = t.fromNumber(0), a.one = t.fromNumber(1), a.prototype.neg = function() {
return this.inf ? this : new a(this.x, this.y.redNeg(), this.z);
@ -2991,7 +2993,7 @@ $jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) {
}, { "./bn": 43 }], 46: [function(t, e, r) {
function s(t, e) {
this.inf = null === t && null === e ? (this.x = this.y = null, !0) : (this.x = t, this.y = e, !1);
null === t && null === e ? (this.x = this.y = null, this.inf = !0) : (this.x = t, this.y = e, this.inf = !1);
};
var i = t("safe-buffer").Buffer, n = t("./bn"), o = t("./ecjpoint");
s.fromPublicKey = function(t) {

File diff suppressed because it is too large Load Diff

View File

@ -16,12 +16,12 @@ import * as crypto from 'crypto';
import * as os from 'os'
global.glStopNode = false;
//const MAX_TIME_NETWORK_TRANSPORT = 1 * 1000;
const MAX_TIME_NETWORK_TRANSPORT = 1 * 1000;
var GlSumUser;
var GlSumSys;
var GlSumIdle;
global.CountAllNode = 0;
module.exports = class CCommon {
export default class CCommon {
VirtualMode
KeyPair
PubKeyType
@ -34,8 +34,6 @@ module.exports = class CCommon {
CheckName
NodesArr
CurrentBlockNum
ReadBlockHeaderDB
GetActualNodes
BlockNumDB
constructor(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual) {
global.SERVER = this
@ -48,6 +46,18 @@ module.exports = class CCommon {
this.HashDBArr = global.shaarr2(this.KeyPair.getPrivateKey(), [0, 0, 0, 0, 0, 0, 0, 1])
this.ServerSign = []
}
SendF(Node, Info, Length?) {
// defiend in server.ts
}
AddCheckErrCount(Node, Count, StrErr) {
// defiend in server.ts
}
GetActualNodes(): any {
// defiend in server.ts
}
ReadBlockHeaderDB(BlockNum): any {
// defiend in block-db.ts(CDB)
}
AddStatOnTimer() {
var CountAll = 0;
var CurTime = global.GetCurrentTime() - 0;
@ -204,7 +214,7 @@ module.exports = class CCommon {
return crypto.randomBytes(32);
}
};
export class SMemBuffer {
class SMemBuffer {
MetaMap1
MetaMap2
CheckName

View File

@ -9,6 +9,7 @@
*/
"use strict";
import CBlock from './block-loader'
require('./library');
require('./crypto-library');
const TX_PROCESS_TIME = 100;
@ -38,14 +39,14 @@ var FORMAT_DATA_TRANSFER = "{\
NoSendTx:uint,\
}";
const WorkStructSend = {};
module.exports = class CConsensus extends require("./block-loader")
{
export default class CConsensus extends CBlock {
CurrentBlockNum
SendBlockID
RelayMode
TreeSendPacket
idBlockChainTimer
OwnBlockCount
LevelNodes
constructor(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual) {
super(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)
this.CurrentBlockNum = 0
@ -175,9 +176,9 @@ module.exports = class CConsensus extends require("./block-loader")
}
Transfer.WasGet = true
if (global.DoTxLog && Data.TicketArray.length)
global.ToLog("TRANSFER BlockNum:" + Block.BlockNum + " TicketArray=" + Data.TicketArray.length + " from " + NodeName(Node))
global.ToLog("TRANSFER BlockNum:" + Block.BlockNum + " TicketArray=" + Data.TicketArray.length + " from " + global.NodeName(Node))
if (global.DoTxLog && Data.TxArray.length)
global.ToLog("TRANSFER BlockNum:" + Block.BlockNum + " TxArray=" + Data.TxArray.length + " from " + NodeName(Node))
global.ToLog("TRANSFER BlockNum:" + Block.BlockNum + " TxArray=" + Data.TxArray.length + " from " + global.NodeName(Node))
this.ToMaxPOWList(Data.MaxPOW)
this.ToMaxSumList(this.GetMaxSumListFromID(Node, Data.MaxSumID, Data.BlockList))
//var WasNewAdd = 0;
@ -343,7 +344,7 @@ module.exports = class CConsensus extends require("./block-loader")
Arr = Arr2
}
if (global.DoTxLog)
global.ToLog("SEND TRANSFER BlockNum:" + Block.BlockNum + " Arr=" + Arr.length + " to " + NodeName(Item.Node))
global.ToLog("SEND TRANSFER BlockNum:" + Block.BlockNum + " Arr=" + Arr.length + " to " + global.NodeName(Item.Node))
var BufData = this.CreateTransferBuffer(Arr, arrPow, arrSum, Block, Item.Node);
this.Send(Item.Node, { "Method": "TRANSFER", "Context": {}, "Data": BufData }, 1)
if (!Block.JobListTX)
@ -351,6 +352,9 @@ module.exports = class CConsensus extends require("./block-loader")
Block.JobListTX.push({ Node: Item.Node, TreeLevel: Item.TreeLevel, Time: Date.now() })
}
}
Send(Node, Info, TypeData?) {
// defiend in server.ts
}
TRANSFERTX(Info, CurTime) {
var Data = this.DataFromF(Info);
var Node = Info.Node;
@ -359,7 +363,7 @@ module.exports = class CConsensus extends require("./block-loader")
return;
}
if (global.DoTxLog)
global.ToLog("TRANSFERTX BlockNum:" + Block.BlockNum + " Array=" + Data.Array.length + " from " + NodeName(Node))
global.ToLog("TRANSFERTX BlockNum:" + Block.BlockNum + " Array=" + Data.Array.length + " from " + global.NodeName(Node))
for (var i = 0; i < Data.Array.length; i++) {
this.AddTrToBlockQuote(Block, Data.Array[i], 1)
}
@ -434,7 +438,7 @@ module.exports = class CConsensus extends require("./block-loader")
return;
}
if (global.DoTxLog)
global.ToLog("RETTRANSFERTX BlockNum:" + Block.BlockNum + " Array=" + Data.Array.length + " from " + NodeName(Node))
global.ToLog("RETTRANSFERTX BlockNum:" + Block.BlockNum + " Array=" + Data.Array.length + " from " + global.NodeName(Node))
for (var i = 0; i < Data.Array.length; i++) {
var Tr = Data.Array[i];
this.CheckCreateTransactionObject(Tr)
@ -464,7 +468,7 @@ module.exports = class CConsensus extends require("./block-loader")
if (!Arr.length)
return;
if (global.DoTxLog)
global.ToLog("DoJobListTX BlockNum:" + Block.BlockNum + " Arr=" + Arr.length + " to " + NodeName(JobItem.Node))
global.ToLog("DoJobListTX BlockNum:" + Block.BlockNum + " Arr=" + Arr.length + " to " + global.NodeName(JobItem.Node))
var SendData = { "Method": "TRANSFERTX", "Context": {}, "Data": { BlockNum: Block.BlockNum, Array: Arr, } };
this.SendF(JobItem.Node, SendData, global.MAX_BLOCK_SIZE + 1000)
}
@ -570,7 +574,7 @@ module.exports = class CConsensus extends require("./block-loader")
for (var n = 0; n < ArrNodesArr.length; n++) {
var ElArr = ArrNodesArr[n];
if (global.DoTxLog)
global.ToLog("CheckTxExchange BlockNum:" + Block.BlockNum + " Array=" + ElArr.Arr.length + " to " + NodeName(ElArr.Node))
global.ToLog("CheckTxExchange BlockNum:" + Block.BlockNum + " Array=" + ElArr.Arr.length + " to " + global.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)
}
@ -865,7 +869,25 @@ module.exports = class CConsensus extends require("./block-loader")
}
return arr;
}
CheckPrioritetTx(Tr) {
if (Tr.Prioritet === undefined) {
var Body = Tr.body;
Tr.Prioritet = global.MAX_LENGTH_SENDER_MAP
var App = global.DAppByType[Body[0]];
if (App) {
Tr.SenderNum = App.GetSenderNum(Tr.num, Body)
if (Tr.SenderNum && Tr.SenderNum > 0) {
Tr.Prioritet = this.GetSenderPrioritet(Tr.num, Tr.SenderNum)
Tr.TimePow = Tr.Prioritet + Tr.power
}
}
}
}
GetSenderPrioritet(BlockNum, SenderNum) {
//defiend in transaction-validator.ts(CSmartContract)
}
AddToQuote(Tree, Tr) {
this.CheckPrioritetTx(Tr)
var Tr0 = Tree.find(Tr);
if (Tr0) {
return 3;
@ -881,6 +903,15 @@ module.exports = class CConsensus extends require("./block-loader")
return 1;
}
}
IsValidTicket(Tr, BlockNum): any {
// defiend in transaction-validator.ts(CSmartContract)
}
IsValidTransaction(Tr, BlockNum): any {
// defiend in transaction-validator.ts(CSmartContract)
}
AddDAppTransactions(BlockNum, Arr) {
// defiend in transaction-validator.ts(CSmartContract)
}
AddTicketToBlockQuote(Block, Tr) {
if (Block.PowTicketTree) {
var Res = this.IsValidTicket(Tr, Block.BlockNum);
@ -1267,14 +1298,14 @@ module.exports = class CConsensus extends require("./block-loader")
}
}
var MaxNumBlockDB = this.GetMaxNumBlockDB();
if (CURRENTBLOCKNUM + global.BLOCK_PROCESSING_LENGTH2 > MaxNumBlockDB)
if (CURRENTBLOCKNUM + global.BLOCK_PROCESSING_LENGTH2 > MaxNumBlockDB && CURRENTBLOCKNUM - global.BLOCK_PROCESSING_LENGTH2 < MaxNumBlockDB)
for (var BlockNum = CURRENTBLOCKNUM - global.BLOCK_PROCESSING_LENGTH2; BlockNum > global.BLOCK_PROCESSING_LENGTH2 && BlockNum < start_save; BlockNum++) {
var Block = this.GetBlock(BlockNum);
if (Block && !Block.bSave && Block.TrCount && Block.TreeHash && !global.IsZeroArr(Block.TreeHash) && !Block.WasSaveDataTree) {
this.PreSaveDataTreeToDB(Block)
Block.WasSaveDataTree = 1
global.AddInfoBlock(Block, "*PRESAVE DATA TREE*")
global.ToLog("PRESAVE DATA: " + Block.BlockNum)
global.ToLog("PRESAVE DATA: " + Block.BlockNum, 2)
}
}
this.RelayMode = !bWasSave

View File

@ -9,12 +9,12 @@
*/
"use strict";
//const fs = require("fs");
import * as fs from 'fs'
import CRest from './rest-loader'
//import * as crypto from 'crypto';
require('./block-loader-const');
const STAT_BLOCK_LOAD_PERIOD = global.CONSENSUS_PERIOD_TIME / 5;
module.exports = class CBlock extends require("./rest-loader")
{
export default class CBlock extends CRest {
MapMapLoaded
BlockChain
ChainID
@ -32,6 +32,7 @@ module.exports = class CBlock extends require("./rest-loader")
LoadHistoryContext
LoadBlockStatNum
BADHashCount
ActualNodes
constructor(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual) {
super(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)
this.MapMapLoaded = {}
@ -594,7 +595,7 @@ module.exports = class CBlock extends require("./rest-loader")
}
if (chain.LoadCountDB >= global.COUNT_BLOCKS_FOR_CHECK_POW) {
if (chain.LoadSumDB - chain.LoadSum > global.MAX_DELTA_COUNT_SUM_FOR_LOAD) {
var Str = "ERR LOADED SUM POW chains: SumDB > Sum loaded from: " + NodeInfo(Info.Node);
var Str = "ERR LOADED SUM POW chains: SumDB > Sum loaded from: " + global.NodeInfo(Info.Node);
chain.StopSend = true
chain.AddInfo(Str)
}
@ -764,7 +765,7 @@ module.exports = class CBlock extends require("./rest-loader")
return;
}
}
var Res = 0;
var Res: any = 0;
if (Block.TreeEq) {
this.ReadBlockBodyDB(Block)
Res = this.WriteBlockDBFinaly(Block)
@ -804,6 +805,9 @@ module.exports = class CBlock extends require("./rest-loader")
this.FREE_ALL_MEM_CHAINS()
global.ADD_TO_STAT_TIME("WRITECHAIN_TO_DB_TIME", startTime)
}
SetNoPOW(BlockNumFrom, bReload, RefBlockNum) {
//defiend in block-exchange.js
}
CopyBlock(Block, BlockDst) {
BlockDst.BlockNum = Block.BlockNum
BlockDst.TreeHash = Block.TreeHash
@ -830,6 +834,9 @@ module.exports = class CBlock extends require("./rest-loader")
}
this.AddToStatBlockConfirmation(Block)
}
RecreateMaxPOW(Block) {
//defiend in block-exchange.js
}
ClearMaxInBlock(Block) {
Block.MaxPOW = {}
var POW = Block.MaxPOW;
@ -947,7 +954,7 @@ module.exports = class CBlock extends require("./rest-loader")
FreeGet -= Node.CanGetBlocks
Node.SendBlockCount = 0
Node.LoadBlockCount = 0
global.ADD_TO_STAT("NODE_CAN_GET:" + NodeName(Node), Node.CanGetBlocks, 1)
global.ADD_TO_STAT("NODE_CAN_GET:" + global.NodeName(Node), Node.CanGetBlocks, 1)
}
}
static
@ -974,7 +981,7 @@ module.exports = class CBlock extends require("./rest-loader")
var arrContent = Data.arrContent;
var TreeHash = global.CalcTreeHashFromArrBody(Block.BlockNum, arrContent);
if (global.CompareArr(Block.TreeHash, TreeHash) !== 0) {
global.ToLog("2. BAD CMP TreeHash block=" + Block.BlockNum + " from:" + NodeName(Info.Node) + " TreeHash=" + global.GetHexFromArr(TreeHash) + " BlockTreeHash=" + global.GetHexFromArr(Block.TreeHash))
global.ToLog("2. BAD CMP TreeHash block=" + Block.BlockNum + " from:" + global.NodeName(Info.Node) + " TreeHash=" + global.GetHexFromArr(TreeHash) + " BlockTreeHash=" + global.GetHexFromArr(Block.TreeHash))
this.SetBlockNOSendToNode(Block, Info.Node, "BAD CMP TreeHash")
return;
}
@ -982,10 +989,11 @@ module.exports = class CBlock extends require("./rest-loader")
var TR = arrContent[0];
if (TR[0] === global.TYPE_TRANSACTION_ACC_HASH) {
if (!global.DApps.Accounts.TRCheckAccountHash(TR, Data.BlockNum)) {
global.ToLog(`global.DApps.Accounts.TRCheckAccountHash(TR, Data.BlockNum) ${JSON.stringify(TR)}, ${Data.BlockNum}`)
if (!this.BADHashCount)
this.BADHashCount = 0
this.BADHashCount++
global.ToLog("**** BAD ACCOUNT Hash in block=" + Block.BlockNum + " from:" + NodeName(Info.Node) + " ****")
global.ToLog("**** BAD ACCOUNT Hash in block=" + Block.BlockNum + " from:" + global.NodeName(Info.Node) + " ****")
global.ToLog("May be need to Rewrite transactions from: " + (Block.BlockNum - 2 * global.DELTA_BLOCK_ACCOUNT_HASH))
this.SetBlockNOSendToNode(Block, Info.Node, "BAD CMP ACC HASH")
if (global.WATCHDOG_BADACCOUNT && this.BADHashCount > 60) {
@ -1046,6 +1054,9 @@ module.exports = class CBlock extends require("./rest-loader")
Info.Node.LoadBlockCount++
}
}
DataFromF(Info, bSendFormat?): any {
//defiend in server.js
}
SetBlockNOSendToNode(Block, Node, Str) {
var Str = global.GetHexFromArr(Block.TreeHash);
var Str2 = this.GetStrFromHashShort(Block.TreeHash);
@ -1276,11 +1287,11 @@ global.LoadBlockFromNetwork = function(Params, F) {
var Block = global.BufLib.GetObjectFromBuffer(Info.Data, global.FORMAT_BLOCK_TRANSFER, global.WRK_BLOCK_TRANSFER);
Info.Data = undefined;
if (!Block.BlockNum || Block.BlockNum !== Params.BlockNum) {
global.ToLog("Error get BlockNum:" + Params.BlockNum + " from " + NodeName(Info.Node), 2);
global.ToLog("Error get BlockNum:" + Params.BlockNum + " from " + global.NodeName(Info.Node), 2);
F(1);
return;
}
global.ToLog("Got BlockFromNetwork:" + Params.BlockNum + " from " + NodeName(Info.Node), 2);
global.ToLog("Got BlockFromNetwork:" + Params.BlockNum + " from " + global.NodeName(Info.Node), 2);
var ResError;
if (!Block.arrContent || Block.arrContent.length === 0) {
ResError = 1;

View File

@ -10,9 +10,9 @@
"use strict";
import * as fs from 'fs'
import CCommon from './base'
// const FORMAT_EVAL_SEND = "{MaxBlockNum:uint,Code:str,Sign:arr64}";
module.exports = class CCode extends require("./base")
{
export default class CCode extends CCommon {
LastEvalCodeNum
constructor(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual) {
super(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)

View File

@ -10,7 +10,8 @@
"use strict";
// import * as crypto from 'crypto';
const CNode = require("./node");
import CNode from './node'
import CMessages from './transfer-msg'
global.PERIOD_FOR_RECONNECT = 3600 * 1000;
global.CHECK_DELTA_TIME = { Num: 0, bUse: 0, StartBlockNum: 0, EndBlockNum: 0, bAddTime: 0, DeltaTime: 0, Sign: [] };
global.CHECK_POINT = { BlockNum: 0, Hash: [], Sign: [] };
@ -30,8 +31,9 @@ global.MAX_PING_FOR_CONNECT = 400;
var MAX_TIME_CORRECT = 3 * 3600 * 1000;
global.MAX_WAIT_PERIOD_FOR_HOT = 4 * global.CONSENSUS_PERIOD_TIME;
const PERIOD_FOR_START_CHECK_TIME = 300;
module.exports = class CConnect extends require("./transfer-msg")
{
export default class CConnect extends CMessages {
ip
port
StartTime
WasNodesSort
LevelNodes
@ -50,6 +52,9 @@ module.exports = class CConnect extends require("./transfer-msg")
StopDetectGrayMode
LastNotZeroNodesTime
TransferTree
СтатБлок
BusyLevel
SendTrafficFree
constructor(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual) {
super(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)
this.StartTime = Date.now()
@ -103,7 +108,7 @@ module.exports = class CConnect extends require("./transfer-msg")
StartConnectTry(Node) {
var Delta = Date.now() - Node.StartTimeConnect;
if (Delta >= Node.NextConnectDelta && this.IsCanConnect(Node)) {
if (!GetSocketStatus(Node.Socket)) {
if (!global.GetSocketStatus(Node.Socket)) {
Node.StartTimeConnect = Date.now()
if (Delta < 60 * 1000)
Node.NextConnectDelta = Node.NextConnectDelta * 2
@ -312,7 +317,7 @@ module.exports = class CConnect extends require("./transfer-msg")
this.CheckCodeVersion(Data, Info.Node)
if (!global.CAN_START) {
if (DeltaTime > global.MAX_PING_FOR_CONNECT)
global.ToLog("DeltaTime=" + DeltaTime + ">" + global.MAX_PING_FOR_CONNECT + " ms - " + NodeInfo(Node), 2)
global.ToLog("DeltaTime=" + DeltaTime + ">" + global.MAX_PING_FOR_CONNECT + " ms - " + global.NodeInfo(Node), 2)
}
var Times;
if (DeltaTime <= global.MAX_PING_FOR_CONNECT) {
@ -367,7 +372,7 @@ module.exports = class CConnect extends require("./transfer-msg")
}
else {
Node.NextConnectDelta = 60 * 1000
global.ToLog("Error Sign CheckPoint=" + Data.CheckPoint.BlockNum + " from " + NodeInfo(Node))
global.ToLog("Error Sign CheckPoint=" + Data.CheckPoint.BlockNum + " from " + global.NodeInfo(Node))
this.AddCheckErrCount(Node, 10, "Error Sign CheckPoint")
}
}
@ -382,7 +387,7 @@ module.exports = class CConnect extends require("./transfer-msg")
}
else {
Node.NextConnectDelta = 60 * 1000
global.ToLog("Error Sign CheckDeltaTime Num=" + Data.CheckDeltaTime.Num + " from " + NodeInfo(Node))
global.ToLog("Error Sign CheckDeltaTime Num=" + Data.CheckDeltaTime.Num + " from " + global.NodeInfo(Node))
this.AddCheckErrCount(Node, 10, "Error Sign CheckDeltaTime")
}
}
@ -409,7 +414,7 @@ module.exports = class CConnect extends require("./transfer-msg")
}
else {
Node.NextConnectDelta = 60 * 1000
global.ToLog("Error Sign CheckNetConstant Num=" + Data.NetConstant.Num + " from " + NodeInfo(Node))
global.ToLog("Error Sign CheckNetConstant Num=" + Data.NetConstant.Num + " from " + global.NodeInfo(Node))
this.AddCheckErrCount(Node, 10, "Error Sign CheckNetConstant")
}
}
@ -462,7 +467,7 @@ module.exports = class CConnect extends require("./transfer-msg")
}
}
else {
global.ToLog("Error Sign CodeVersion=" + CodeVersion.VersionNum + " from " + NodeInfo(Node) + " HASH:" + global.GetHexFromArr(CodeVersion.Hash).substr(0,
global.ToLog("Error Sign CodeVersion=" + CodeVersion.VersionNum + " from " + global.NodeInfo(Node) + " HASH:" + global.GetHexFromArr(CodeVersion.Hash).substr(0,
20))
global.ToLog(JSON.stringify(CodeVersion))
this.AddCheckErrCount(Node, 10, "Error Sign CodeVersion")
@ -592,6 +597,9 @@ module.exports = class CConnect extends require("./transfer-msg")
return false;
return true;
}
NodeInBan(Node) {
//defiend in
}
GetDirectNodesArray(bAll, bWebPort?, bGetAddrArr?) {
var ret = [];
var Value: any = {
@ -802,6 +810,9 @@ module.exports = class CConnect extends require("./transfer-msg")
}
Info.Node.LevelCount = Data.Count
}
AddCheckErrCount(Node, Count, StrErr?) {
//defiend in server.ts
}
DeleteBadConnectingByTimer() {
if (global.glStopNode)
return;
@ -809,7 +820,7 @@ module.exports = class CConnect extends require("./transfer-msg")
var arr = global.SERVER.NodesArr;
for (var i = 0; i < arr.length; i++) {
var Node = arr[i];
var Status = GetSocketStatus(Node.Socket);
var Status = global.GetSocketStatus(Node.Socket);
if (Node.Active && Status < 100) {
var Delta = CurTime - Node.LastTime;
if (Delta > global.MAX_WAIT_PERIOD_FOR_STATUS) {
@ -882,7 +893,7 @@ module.exports = class CConnect extends require("./transfer-msg")
this.SignCurrentTimeDev = global.GetArrFromValue(global.SHA3BUF(SignArr), global.WALLET.KeyPair.getPrivateKey('')).signature
}
var Time = global.GetCurrentTime() - 0;
global.ToLog("Send time: " + Time + " to " + NodeInfo(Node))
global.ToLog("Send time: " + Time + " to " + global.NodeInfo(Node))
this.SendF(Node, { "Method": "TIME", "Data": { Time: Time, Sign: this.SignCurrentTimeDev } })
return 1;
}
@ -907,7 +918,7 @@ module.exports = class CConnect extends require("./transfer-msg")
}
else {
Node.NextConnectDelta = 60 * 1000
global.ToLog("Error Sign TIME from " + NodeInfo(Node))
global.ToLog("Error Sign TIME from " + global.NodeInfo(Node))
this.AddCheckErrCount(Node, 10, "Error Sign TIME")
}
}

View File

@ -9,7 +9,7 @@
*/
global.UPDATE_CODE_VERSION_NUM = 1127;
global.MIN_CODE_VERSION_NUM = 1094;
global.MIN_CODE_VERSION_NUM = 1114;
global.MINING_VERSION_NUM = 0;
global.InitParamsArg = InitParamsArg;
global.CONST_NAME_ARR = [

View File

@ -10,9 +10,10 @@
"use strict";
import * as fs from 'fs'
const DBLib = require("./db");
const DBRow = require("./db-row");
global.BlockDB = new DBLib();
import Db from './db'
import DBRow from './db-row'
import CCode from '../code'
global.BlockDB = new Db();
global.BLOCK_HEADER_SIZE = 150;
const FILE_NAME_HEADER = "block-header";
const FILE_NAME_BODY = "block-body";
@ -33,8 +34,7 @@ const FORMAT_HEADER_VERSION2 = "{FilePos:uint}";
const FILE_NAME_HEADER2 = "block-header2";
const WorkStructHeader2 = {};
const DEFAULT_DB_VERSION = 2;
module.exports = class CDB extends require("../code")
{
export default class CDB extends CCode {
DBHeader100
BlockNumDB
BlockNumDBMin
@ -70,6 +70,9 @@ module.exports = class CDB extends require("../code")
this.BlockNumDBMin = StateTX.BlockNumMin
}
}
GetBlock(num, bToMem, bReadBody): any {
//defiend in block-loader.ts(CBlock)
}
LoadMemBlocksOnStart() {
this.CurrentBlockNum = global.GetCurrentBlockNumByTime()
for (var i = this.BlockNumDB - global.BLOCK_COUNT_IN_MEMORY; i <= this.BlockNumDB; i++)
@ -223,6 +226,9 @@ module.exports = class CDB extends require("../code")
}
return Ret;
}
OnWriteBlock(Block) {
//defiend in transaction-validator.ts(CSmartContract)
}
PreSaveDataTreeToDB(Block) {
var Ret = this.WriteBodyDB(Block);
if (Ret) {
@ -290,6 +296,9 @@ module.exports = class CDB extends require("../code")
Block.TrDataLen = TrDataLen
return true;
}
CheckSeqHashDB(Block, StrError): any {
//defiend in block-loader.ts(CBlock)
}
WriteBlockHeaderDB(Block, bPreSave?) {
if (!bPreSave && Block.BlockNum > this.BlockNumDBMin + global.BLOCK_PROCESSING_LENGTH2) {
if (global.USE_CHECK_SAVE_DB)
@ -570,6 +579,12 @@ module.exports = class CDB extends require("../code")
this.CreateGenesisBlocks()
this.StartSyncBlockchain()
}
CreateGenesisBlocks() {
// defiend in block-loader.ts(CBlock)
}
StartSyncBlockchain(Node?, bSilent?, bCheckPoint?) {
// defiend in block-loader.ts(CBlock)
}
ClearBufMap() {
this.MapHeader = {}
}
@ -888,7 +903,7 @@ module.exports = class CDB extends require("../code")
var SeqHash = global.CalcHashFromArray(arr, true);
return SeqHash;
}
CheckCreateTicketObject(Tr, BlockNum, SetTxID) {
CheckCreateTicketObject(Tr, BlockNum?, SetTxID?) {
if (!Tr.HashPow && Tr.HashTicket) {
Tr.num = BlockNum
var FullHashTicket = [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];
@ -902,7 +917,7 @@ module.exports = class CDB extends require("../code")
Tr.TxID = global.GetHexFromArr(FullHashTicket.slice(0, global.TR_TICKET_HASH_LENGTH + 6))
}
}
CheckCreateTransactionObject(Tr, SetTxID, NotPrioritet?) {
CheckCreateTransactionObject(Tr, SetTxID?, NotPrioritet?) {
if (!Tr.HashPow) {
var Body = Tr.body;
Tr.IsTx = 1
@ -913,17 +928,6 @@ module.exports = class CDB extends require("../code")
Tr.HASH = global.shaarr(Body)
Tr.HashTicket = Tr.HASH.slice(0, global.TR_TICKET_HASH_LENGTH)
this.CheckCreateTicketObject(Tr, Tr.num, SetTxID)
Tr.Prioritet = global.MAX_LENGTH_SENDER_MAP
if (!NotPrioritet && this.GetSenderPrioritet) {
var App = global.DAppByType[Body[0]];
if (App) {
Tr.SenderNum = App.GetSenderNum(Tr.num, Body)
if (Tr.SenderNum && Tr.SenderNum > 0) {
Tr.Prioritet = this.GetSenderPrioritet(Tr.num, Tr.SenderNum)
Tr.TimePow = Tr.Prioritet + Tr.power
}
}
}
}
}
BlockChainToBuf(WriteNum, StartNum, EndBlockNum) {
@ -1033,3 +1037,19 @@ global.GetNodeStrPort = function(Node) {
return "" + arr[2] + "." + arr[3];
}
};
declare global {
namespace NodeJS {
interface Global {
//#region block-db.ts
BlockDB: any;
BLOCK_HEADER_SIZE: number;
BLOCK_HEADER_SIZE2: number;
DB_VERSION: number;
AddInfoChain: Function;
AddInfoBlock: Function;
GetNodeStrPort: Function;
NO_CHECK_BLOCKNUM_ONSTART: number;
//#endregion
}
}
}

View File

@ -10,18 +10,18 @@
"use strict";
import * as fs from 'fs'
import Db from './db'
module.exports = class CDBState extends require("./db")
{
private FileName;
private DataSize;
private Format;
private WorkStruct;
// private FileNameFull;
// private LastHash;
// private WasUpdate;
private BufMap;
private BufMapCount;
class DBRow extends Db {
FileName;
DataSize;
Format;
WorkStruct;
FileNameFull;
LastHash;
WasUpdate;
BufMap;
BufMapCount;
constructor(FileName, DataSize, Format, bReadOnly) {
super()
@ -29,10 +29,10 @@ module.exports = class CDBState extends require("./db")
this.DataSize = DataSize
this.Format = Format
this.WorkStruct = {}
// var FI = this.OpenDBFile(this.FileName, !bReadOnly);
// this.FileNameFull = FI.fname
// this.LastHash = undefined
// this.WasUpdate = 1
var FI = this.OpenDBFile(this.FileName, !bReadOnly);
this.FileNameFull = FI.fname
this.LastHash = undefined
this.WasUpdate = 1
this.BufMap = {}
this.BufMapCount = 0
setInterval(this.CheckBufMap.bind(this), 1000)
@ -48,8 +48,8 @@ module.exports = class CDBState extends require("./db")
}
Write(Data, RetBuf) {
var startTime = process.hrtime();
// this.LastHash = undefined
// this.WasUpdate = 1
this.LastHash = undefined
this.WasUpdate = 1
this.CheckNewNum(Data)
Data.Num = Math.trunc(Data.Num)
this.DeleteMap(Data.Num)
@ -118,8 +118,8 @@ module.exports = class CDBState extends require("./db")
Position = 0
var FI = this.OpenDBFile(this.FileName, 1);
if (Position < FI.size) {
// this.LastHash = undefined
// this.WasUpdate = 1
this.LastHash = undefined
this.WasUpdate = 1
if (LastNum < 0)
global.ToLog("Truncate " + this.FileName + " from 0", 2)
FI.size = Position
@ -227,3 +227,5 @@ module.exports = class CDBState extends require("./db")
this.CloseDBFile(this.FileName)
}
};
export default DBRow

View File

@ -11,11 +11,11 @@
"use strict";
import * as fs from 'fs'
module.exports = class {
private DBMap;
// private LastHash;
// private WasUpdate;
private WasCheckPathDB;
class Db {
DBMap;
LastHash;
WasUpdate;
WasCheckPathDB;
constructor() {
this.DBMap = {}
@ -24,9 +24,9 @@ module.exports = class {
var Path = global.GetDataPath("DB");
global.CheckCreateDir(Path)
}
CloseDBFile(name, bdelete) {
// this.LastHash = undefined
// this.WasUpdate = 1
CloseDBFile(name, bdelete?) {
this.LastHash = undefined
this.WasUpdate = 1
var Item = this.DBMap[name];
if (Item) {
let bDelete = bdelete;
@ -40,23 +40,23 @@ module.exports = class {
global.ToLog(err)
})
}
}
else {
} else {
global.ToLog(err)
}
})
delete this.DBMap[name]
}
}
OpenDBFile(name, bWrite, bExist) {
OpenDBFile(name, bWrite?, bExist?) {
if (bWrite && global.READ_ONLY_DB) {
global.ToLogTrace("CANNOT WRITE - DB IN READ_ONLY MODE!!!")
process.exit()
}
if (bWrite)
if (bWrite) {
CheckStartOneProcess(name + "-run")
// this.LastHash = undefined
// this.WasUpdate = 1
}
this.LastHash = undefined
this.WasUpdate = 1
var Item = this.DBMap[name];
if (Item === undefined) {
if (!this.WasCheckPathDB) {
@ -82,7 +82,7 @@ module.exports = class {
}
};
var MapCheckProcess = {};
var BlockDB = new module.exports();
var BlockDB = new Db();
function CheckStartOneProcess(Name) {
if (global.UpdateMode)
@ -96,11 +96,21 @@ function CheckStartOneProcess(Name) {
}
try {
BlockDB.OpenDBFile(Name);
}
catch (e) {
} catch (e) {
global.ToLog("****** DETECT START ANOTHER PROCESS for: " + Name);
global.ToLogTrace("EXIT");
process.exit();
}
};
global.CheckStartOneProcess = CheckStartOneProcess;
declare global {
namespace NodeJS {
interface Global {
//#region dapp.ts
CheckStartOneProcess: Function;
//#endregion
}
}
}
export default Db;

View File

@ -64,7 +64,7 @@ function Init() {
if (a) {
0;
var u = r[10];
u || (u = r[7]), u || (u = r[5]), MapNames[a] = u;
u = (u = u || r[7]) || r[5], MapNames[a] = u;
}
}
}

View File

@ -305,7 +305,7 @@ HTTPCaller.DappStaticCall = function(Params, response) {
glBlock0 = global.SERVER.ReadBlockHeaderDB(0);
var RetValue;
try {
RetValue = 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) {
return { result: 0, RetValue: "" + e };
@ -651,7 +651,7 @@ HTTPCaller.SendECode = function(Param) {
}
return { result: 1, text: "Sent to " + arr.length + " nodes" };
}
var Node = FindNodeByAddr(Param.Addr, 1);
var Node = global.FindNodeByAddr(Param.Addr, 1);
if (Node === undefined)
return { result: 0, text: "Node not found" };
if (Node === false)
@ -1574,19 +1574,19 @@ if (global.ELECTRON) {
});
}
exports.SendData = OnGetData;
// function RunConsole(StrRun) {
// var Str = fs.readFileSync("./EXPERIMENTAL/!run-console.js", { encoding: "utf8" });
// if (StrRun)
// Str += "\n" + StrRun;
// try {
// var ret = eval(Str);
// }
// catch (e) {
// ret = e.message + "\n" + e.stack;
// }
// return ret;
// };
//@ts-ignore
function RunConsole(StrRun) {
var Str = fs.readFileSync("./EXPERIMENTAL/_run-console.js", { encoding: "utf8" });
if (StrRun)
Str += "\n" + StrRun;
try {
var ret = eval(Str);
}
catch (e) {
ret = e.message + "\n" + e.stack;
}
return ret;
};
var WebWalletUser = {};
function GetUserContext(Params) {

View File

@ -9,6 +9,11 @@
*/
import * as fs from 'fs'
import * as os from 'os'
import { RBTree } from 'bintrees'
import * as secp256k1 from 'secp256k1';
import * as ntpClient from 'ntp-client'
import * as stun from 'stun'
import * as zip from 'zip'
import './constant'
import './log'
@ -27,14 +32,20 @@ String.prototype.right = function(count) {
else
return this.substr(0, this.length);
};
global.RBTree = require('bintrees').RBTree;
global.ntpClient = require('ntp-client');
global.Stun = require('stun');
global.ZIP = require("zip");
// var strOS = os.platform() + "_" + os.arch();
if (!global.secp256k1) {
global.secp256k1 = require('secp256k1');
global.RBTree = RBTree;
global.ntpClient = ntpClient;
global.Stun = stun;
global.ZIP = zip;
global.secp256k1 = secp256k1;
export {
RBTree,
ntpClient,
stun,
zip,
secp256k1
}
require('../HTML/JS/terahashlib.js');
require("./crypto-library");
if (global.USE_PARAM_JS) {

View File

@ -33,7 +33,7 @@ function ToLogFile(e, t, r?) {
function ToLogClient(e, t, r) {
let ArrLogClient = global.ArrLogClient;
e && (ToLogFile(file_name_log, e), t || (t = ""), ArrLogClient.push({ text: global.GetStrOnlyTime() + " " + e, key: t, final: r }), 13 < ArrLogClient.length && ArrLogClient.shift());
e && (ToLogFile(file_name_log, e), t = t || "", ArrLogClient.push({ text: global.GetStrOnlyTime() + " " + e, key: t, final: r }), 13 < ArrLogClient.length && ArrLogClient.shift());
};
global.CheckSizeLogFile(file_name_error, file_name_errorPrev), global.ToLog = function(e, t) {
void 0 === t && (t = 1), t && t > global.LOG_LEVEL || (global.ALL_LOG_TO_CLIENT ? ToLogClient(e, void 0, void 0) : ToLogFile(file_name_log,
@ -103,7 +103,7 @@ function CalcInterval(e, t, r) {
function AddToStatContext(e, t, r?) {
void 0 === r && (r = 1);
var o = e.Total[t];
o || (o = 0), "MAX:" === t.substr(0, 4) ? o = Math.max(o, r) : o += r, e.Total[t] = o, StartStatTime || (StartStatTime = global.GetStrOnlyTime(0));
o = o || 0, "MAX:" === t.substr(0, 4) ? o = Math.max(o, r) : o += r, e.Total[t] = o, StartStatTime = StartStatTime || global.GetCurrentTime(0);
};
function CopyStatInterval(e, t) {
@ -153,7 +153,7 @@ global.HASH_RATE = 0, global.ADD_HASH_RATE = function(e) {
}
global.GET_STAT = function(e) {
var t = CONTEXT_STATS.Total[e];
return t || (t = 0), t;
return t = t || 0;
}
global.ADD_TO_STAT_TIME = function(e, t, r) {
if (global.STAT_MODE) {
@ -230,13 +230,13 @@ global.GetStrOnlyTime = function(e) {
if (!global.GetCurrentTime)
return ":::";
e || (e = global.GetCurrentTime());
var t = "" + e.getHours().toStringZ(2);
var t = "" + (e = e || global.GetCurrentTime()).getHours().toStringZ(2);
return t = (t = (t = t + ":" + e.getMinutes().toStringZ(2)) + ":" + e.getSeconds().toStringZ(2)) + "." + e.getMilliseconds().toStringZ(3);
}
global.GetStrTime = function(e) {
if (!global.GetCurrentTime)
return ":::";
e || (e = global.GetCurrentTime());
var t = "" + e.getDate().toStringZ(2);
var t = "" + (e = e || global.GetCurrentTime()).getDate().toStringZ(2);
return t = (t = (t = (t = (t = (t = t + "." + (1 + e.getMonth()).toStringZ(2)) + "." + e.getFullYear()) + " " + e.getHours().toStringZ(2)) + ":" + e.getMinutes().toStringZ(2)) + ":" + e.getSeconds().toStringZ(2)) + "." + e.getMilliseconds().toStringZ(3);
};

View File

@ -9,10 +9,10 @@
*/
"use strict";
require("./library");
const net = require("net");
import "./library"
import net = require("net");
var ConnectIDCount = 1;
module.exports = class CNode {
export default class CNode {
addrStr
ip
port

View File

@ -9,13 +9,14 @@
*/
"use strict";
module.exports = class CRest extends require("./db/block-db")
{
import CDB from './db/block-db'
export default class CRest extends CDB {
LoadRestContext
BlockNumDB
BlockNumDBMin
UseTruncateBlockDB
ContextSendLoadToBegin
LoadHistoryContext
constructor(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual) {
super(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)
}
@ -47,6 +48,15 @@ module.exports = class CRest extends require("./db/block-db")
this.LoadRestContext = undefined
}
}
GetNextNode(task, keyid, checktime?, BlockNum?): any {
//defiend in block-loader.ts(CBlock)
}
DataFromF(Info, bSendFormat?): any {
//defiend in block-loader.ts(CBlock)
}
AddToBan(Node, Str) {
//defiend in server.ts(CTransport)
}
LoopSyncRest() {
let Context = this.LoadRestContext;
switch (Context.Mode) {
@ -58,7 +68,7 @@ module.exports = class CRest extends require("./db/block-db")
continue;
}
Node.SendRestGetHeader = 1
global.ToLog("Send rest get headers from " + Context.BlockNumProof + " to " + NodeName(Node), 2)
global.ToLog("Send rest get headers from " + Context.BlockNumProof + " to " + global.NodeName(Node), 2)
this.SendF(Node, {
"Method": "GETBLOCKHEADER", "Data": { Foward: 1, BlockNum: Context.BlockNumProof, Hash: [] }, "Context": { F: this.RETBLOCKHEADER_REST.bind(this) },
})
@ -96,7 +106,7 @@ module.exports = class CRest extends require("./db/block-db")
var Item = Context.ArrProof[i];
if (Item.SumPower !== MaxPow) {
var Str = "BAD SumPower: " + Item.SumPower + "/" + MaxPow;
global.ToLog(Str + " from: " + NodeName(Item.Node), 2)
global.ToLog(Str + " from: " + global.NodeName(Item.Node), 2)
}
else
if (Item.SumPower && Item.arr.length >= Context.CountProof) {
@ -116,6 +126,7 @@ module.exports = class CRest extends require("./db/block-db")
this.BlockNumDBMin = Block.BlockNum
this.WriteBlockHeaderDB(Block)
this.UseTruncateBlockDB = undefined
global.ToLog("Start run TXPrepareLoadRest", 2)
global.TX_PROCESS.RunRPC("TXPrepareLoadRest", Block.BlockNum, function(Err, Params) {
Context.Mode++
global.ToLog("Next mode: " + Context.Mode, 2)
@ -132,7 +143,7 @@ module.exports = class CRest extends require("./db/block-db")
let Item = Context.ArrProof[i];
if (Item.OK) {
SendCount++
global.ToLog("Send rest get block proof:" + BlockProof.BlockNum + " to " + NodeName(Item.Node), 2)
global.ToLog("Send rest get block proof:" + BlockProof.BlockNum + " to " + global.NodeName(Item.Node), 2)
this.SendF(Item.Node, {
"Method": "GETBLOCK", "Data": { BlockNum: BlockProof.BlockNum, TreeHash: BlockProof.TreeHash }, "Context": {
F: function(Info) {
@ -141,15 +152,15 @@ module.exports = class CRest extends require("./db/block-db")
var Data = global.BufLib.GetObjectFromBuffer(Info.Data, global.FORMAT_BLOCK_TRANSFER, global.WRK_BLOCK_TRANSFER);
Info.Data = undefined
if (Data.BlockNum !== BlockProof.BlockNum || global.CompareArr(Data.TreeHash, BlockProof.TreeHash) !== 0) {
global.ToLog("Error get proof block from " + NodeName(Item.Node), 2)
global.ToLog("Error get proof block from " + global.NodeName(Item.Node), 2)
return;
}
var TreeHash = global.CalcTreeHashFromArrBody(Data.BlockNum, Data.arrContent);
if (global.CompareArr(BlockProof.TreeHash, TreeHash) !== 0) {
global.ToLog("Error TreeHash in proof block from " + NodeName(Item.Node), 2)
global.ToLog("Error TreeHash in proof block from " + global.NodeName(Item.Node), 2)
return;
}
global.ToLog("GET BLOCK proof from " + NodeName(Item.Node), 2)
global.ToLog("GET BLOCK proof from " + global.NodeName(Item.Node), 2)
var FindTx = undefined;
for (var n = 0; n < Data.arrContent.length; n++) {
var Body = Data.arrContent[n];
@ -211,7 +222,7 @@ module.exports = class CRest extends require("./db/block-db")
if (Delta > 5 * 1000 && !Task.OK) {
var Ret = this.GetNextNode(Task, "", 1);
if (Ret.Result) {
global.ToLog("Send GETREST Num:" + Task.StartNum + "-" + Task.Count + " to " + NodeName(Ret.Node), 2)
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 },
@ -223,11 +234,11 @@ module.exports = class CRest extends require("./db/block-db")
if (!Data.Result)
return;
if (Data.Version !== 1) {
global.ToLog("ERROR Version Result GETREST Num:" + Task.StartNum + " from " + NodeName(Info.Node), 2)
global.ToLog("ERROR Version Result GETREST Num:" + Task.StartNum + " from " + global.NodeName(Info.Node), 2)
return;
}
if (global.CompareArrL(Data.ProofHash, Context.TxProof.AccHash) !== 0) {
global.ToLog("ERROR PROOF HASH Result GETREST Num:" + Task.StartNum + " Hash: " + global.GetHexFromArr(Data.ProofHash) + "/" + global.GetHexFromArr(Context.TxProof.AccHash) + " from " + NodeName(Info.Node),
global.ToLog("ERROR PROOF HASH Result GETREST Num:" + Task.StartNum + " Hash: " + global.GetHexFromArr(Data.ProofHash) + "/" + global.GetHexFromArr(Context.TxProof.AccHash) + " from " + global.NodeName(Info.Node),
2)
return;
}
@ -237,11 +248,11 @@ module.exports = class CRest extends require("./db/block-db")
}
var GetHash = global.CheckMerkleProof(Data.ProofArrL, ArrM, Data.ProofArrR);
if (global.CompareArrL(GetHash, Context.TxProof.AccHash) !== 0) {
global.ToLog("ERROR CALC PROOF HASH Result GETREST Num:" + Task.StartNum + " Hash: " + global.GetHexFromArr(GetHash) + "/" + global.GetHexFromArr(Context.TxProof.AccHash) + " from " + NodeName(Info.Node),
global.ToLog("ERROR CALC PROOF HASH Result GETREST Num:" + Task.StartNum + " Hash: " + global.GetHexFromArr(GetHash) + "/" + global.GetHexFromArr(Context.TxProof.AccHash) + " from " + global.NodeName(Info.Node),
2)
return;
}
global.ToLog("OK Result GETREST Num:" + Task.StartNum + " arr=" + Data.Arr.length + " from " + NodeName(Info.Node), 2)
global.ToLog("OK Result GETREST Num:" + Task.StartNum + " arr=" + Data.Arr.length + " from " + global.NodeName(Info.Node), 2)
if (!global.TX_PROCESS || !global.TX_PROCESS.RunRPC) {
global.ToLog("ERROR global.TX_PROCESS")
return;
@ -272,7 +283,7 @@ module.exports = class CRest extends require("./db/block-db")
if (Delta > 3 * 1000 && !Task.OK) {
var Ret = this.GetNextNode(Task, "", 1);
if (Ret.Result) {
global.ToLog("Send GETSMART Num:" + Task.StartNum + "-" + Task.Count + " to " + NodeName(Ret.Node), 2)
global.ToLog("Send GETSMART Num:" + Task.StartNum + "-" + Task.Count + " to " + global.NodeName(Ret.Node), 2)
var SELF = this;
this.SendF(Ret.Node, {
"Method": "GETSMART", "Data": { BlockNum: Context.BlockNumRest, SmartNum: Task.StartNum, Count: Task.Count },
@ -283,7 +294,7 @@ module.exports = class CRest extends require("./db/block-db")
var Data = SELF.DataFromF(Info);
if (!Data.Result)
return;
global.ToLog("Result GETSMART Num:" + Task.StartNum + " arr=" + Data.Arr.length + " from " + NodeName(Info.Node), 2)
global.ToLog("Result GETSMART Num:" + Task.StartNum + " arr=" + Data.Arr.length + " from " + global.NodeName(Info.Node), 2)
Task.Node = Info.Node
if (!global.TX_PROCESS || !global.TX_PROCESS.RunRPC)
return;
@ -358,6 +369,9 @@ module.exports = class CRest extends require("./db/block-db")
global.ToLog("Error state!")
break;
}
}
GetBlockArrFromBuffer_Load(BufRead, Info?): any {
}
RETBLOCKHEADER_REST(Info, CurTime) {
if (Info.Node.SendRestGetHeader === 2)
@ -366,7 +380,7 @@ module.exports = class CRest extends require("./db/block-db")
var Context = this.LoadRestContext;
var BufRead = global.BufLib.GetReadBuffer(Info.Data);
var arr = this.GetBlockArrFromBuffer_Load(BufRead, Info);
global.ToLog("RETBLOCKHEADER_FOWARD SyncRest from " + NodeName(Info.Node) + " arr=" + arr.length, 2)
global.ToLog("RETBLOCKHEADER_FOWARD SyncRest from " + global.NodeName(Info.Node) + " arr=" + arr.length, 2)
Context.ReceiveHeaderCount++
var MinSumPow = 10 * Context.CountProof;
var SumPower = 0;
@ -420,13 +434,13 @@ module.exports = class CRest extends require("./db/block-db")
var Ret = this.GetNextNode(Context, Context.BlockNum, 1);
if (Ret.Result) {
var Node = Ret.Node;
global.ToLog("LOAD_TO_BEGIN - from: " + BlockDB.BlockNum + " to " + NodeName(Node), 2)
global.ToLog("LOAD_TO_BEGIN - from: " + BlockDB.BlockNum + " to " + global.NodeName(Node), 2)
Context.Time = CurTime
this.SendF(Node, {
"Method": "GETBLOCKHEADER", "Data": { Foward: 0, BlockNum: Context.BlockNum, Hash: BlockDB.Hash, IsSum: 0, Count: global.COUNT_HISTORY_BLOCKS_FOR_LOAD },
"Context": {
F: function(Info) {
global.ToLog("GET LOAD_TO_BEGIN from " + NodeName(Info.Node) + " Length=" + Info.Data.length, 2)
global.ToLog("GET LOAD_TO_BEGIN from " + global.NodeName(Info.Node) + " Length=" + Info.Data.length, 2)
}
}
})

View File

@ -14,6 +14,7 @@ import net = require("net");
import * as crypto from 'crypto';
import "./library"
import "./crypto-library"
import CConnect from './connect'
const HARD_PACKET_PERIOD = 20;
global.BUF_TYPE = 1;
global.STR_TYPE = 2;
@ -57,12 +58,9 @@ const FORMAT_PACKET_SEND_TCP = "{\
Hash:hash,\
Data:data,\
}";
export default class CTransport extends require("./connect")
{
export default class CTransport extends CConnect {
UseRNDHeader
BAN_IP
ip
port
CanSend
SendFormatMap
ActualNodes
@ -233,7 +231,7 @@ export default class CTransport extends require("./connect")
this.SendTrafficFree -= Node.SendTrafficLimit
}
Node.SendTrafficCurrent = 0
global.ADD_TO_STAT("MAX:NODE_TRAFFIC_LIMIT:" + NodeName(Node), 1000 / global.STAT_PERIOD * Node.SendTrafficLimit / 1024, 1)
global.ADD_TO_STAT("MAX:NODE_TRAFFIC_LIMIT:" + global.NodeName(Node), 1000 / global.STAT_PERIOD * Node.SendTrafficLimit / 1024, 1)
}
this.SendTrafficFree += TRAFIC_LIMIT_NODE
global.ADD_TO_STAT("SEND_TRAFFIC_FREE", this.SendTrafficFree / 1024)
@ -243,7 +241,7 @@ export default class CTransport extends require("./connect")
var Str = "";
if (Info.Data && Info.Data.Length)
Str = " LENGTH=" + Info.Data.Length
global.TO_DEBUG_LOG("GET:" + Info.Method + Str + " from: Node=" + NodeInfo(Info.Node))
global.TO_DEBUG_LOG("GET:" + Info.Method + Str + " from: Node=" + global.NodeInfo(Info.Node))
}
if (global.ADDRLIST_MODE) {
var StrOK = ",HAND,GETNODES,";
@ -269,7 +267,7 @@ export default class CTransport extends require("./connect")
var Arr = [];
var it = this.ActualNodes.iterator(), Item;
while ((Item = it.next()) !== null) {
if (GetSocketStatus(Item.Socket) >= 100)
if (global.GetSocketStatus(Item.Socket) >= 100)
Arr.push(Item)
else {
this.DeleteNodeFromActive(Item)
@ -467,7 +465,7 @@ export default class CTransport extends require("./connect")
return 0;
var startTime = process.hrtime();
global.ADD_TO_STAT("GETDATA(KB)", buf.length / 1024)
global.ADD_TO_STAT("GETDATA(KB):" + NodeName(Node), buf.length / 1024, 1)
global.ADD_TO_STAT("GETDATA(KB):" + global.NodeName(Node), buf.length / 1024, 1)
if (!Node.TransferSize)
Node.TransferSize = 0
Node.TransferSize += buf.length / 1024
@ -480,7 +478,7 @@ export default class CTransport extends require("./connect")
}
global.ADD_TO_STAT("GET:" + Buf.Method)
global.ADD_TO_STAT("GET:(KB)" + Buf.Method, buf.length / 1024)
global.ADD_TO_STAT("GET:" + Buf.Method + ":" + NodeName(Node), 1, 1)
global.ADD_TO_STAT("GET:" + Buf.Method + ":" + global.NodeName(Node), 1, 1)
var Param = this.MethodTiming[Buf.Method];
if (this.StopDoSendPacket(Param, Node, Buf.Method)) {
return 1;
@ -679,8 +677,8 @@ export default class CTransport extends require("./connect")
Info = Node.SendPacket.min()
if (!Info)
return 0;
global.ADD_TO_STAT("MAX:NODE_BUF_WRITE:" + NodeName(Node), Node.BufWrite.length / 1024, 1)
global.ADD_TO_STAT("MAX:NODE_SEND_BUF_PACKET_COUNT:" + NodeName(Node), Node.SendPacket.size, 1)
global.ADD_TO_STAT("MAX:NODE_BUF_WRITE:" + global.NodeName(Node), Node.BufWrite.length / 1024, 1)
global.ADD_TO_STAT("MAX:NODE_SEND_BUF_PACKET_COUNT:" + global.NodeName(Node), Node.SendPacket.size, 1)
if (Node.BufWrite.length > 2 * TRAFIC_LIMIT_1S) {
return 2;
}
@ -698,8 +696,8 @@ export default class CTransport extends require("./connect")
Node.BufWrite = Buffer.concat([Node.BufWrite, BufWrite])
global.ADD_TO_STAT("SEND:" + Info.Method)
global.ADD_TO_STAT("SEND:(KB)" + Info.Method, BufWrite.length / 1024)
global.ADD_TO_STAT("SEND:" + Info.Method + ":" + NodeName(Node), 1, 1)
global.TO_DEBUG_LOG("SEND " + Info.Method + " to " + NodeInfo(Node) + " LENGTH=" + BufWrite.length)
global.ADD_TO_STAT("SEND:" + Info.Method + ":" + global.NodeName(Node), 1, 1)
global.TO_DEBUG_LOG("SEND " + Info.Method + " to " + global.NodeInfo(Node) + " LENGTH=" + BufWrite.length)
return 1;
}
DoSendPacket() {
@ -728,7 +726,7 @@ export default class CTransport extends require("./connect")
var CanCountSend = Node.SendTrafficLimit - Node.SendTrafficCurrent;
if (CanCountSend < CountSend) {
if (this.SendTrafficFree < CountSend) {
global.ADD_TO_STAT("LIMIT_SENDDATA:" + NodeName(Node), Value, 1)
global.ADD_TO_STAT("LIMIT_SENDDATA:" + global.NodeName(Node), Value, 1)
continue NEXT_NODE;
}
this.SendTrafficFree -= CountSend
@ -739,7 +737,7 @@ export default class CTransport extends require("./connect")
Node.BufWrite = Node.BufWrite.slice(CountSend)
this.ADD_CURRENT_STAT_TIME("SEND_DATA", Value)
global.ADD_TO_STAT("SENDDATA(KB)", Value)
global.ADD_TO_STAT("SENDDATA(KB):" + NodeName(Node), Value, 1)
global.ADD_TO_STAT("SENDDATA(KB):" + global.NodeName(Node), Value, 1)
}
}
CheckPOWTicketConnect(Socket, data) {
@ -773,18 +771,18 @@ export default class CTransport extends require("./connect")
Node.NextConnectDelta = 1000
Node.WaitConnectFromServer = 0
Node.GrayConnect = 0
global.AddNodeInfo(Node, "3. SERVER OK CONNECT for client node " + SocketInfo(Socket))
global.AddNodeInfo(Node, "3. SERVER OK CONNECT for client node " + global.SocketInfo(Socket))
this.AddNodeToActive(Node)
Node.Socket = Socket
SetSocketStatus(Socket, 3)
SetSocketStatus(Socket, 100)
global.SetSocketStatus(Socket, 3)
global.SetSocketStatus(Socket, 100)
Socket.Node = Node
Socket.write(this.GetBufFromData("POW_CONNECT0", "OK", 2))
return;
}
else {
Node.NextConnectDelta = 60 * 1000
global.ToLog("Error Sign Node from " + NodeInfo(Node))
global.ToLog("Error Sign Node from " + global.NodeInfo(Node))
this.AddCheckErrCount(Node, 10, "Error Sign Node")
}
}
@ -820,7 +818,7 @@ export default class CTransport extends require("./connect")
this.AddToBanIP(Socket.remoteAddress, "ERROR_SIGN_CLIENT")
return;
}
global.AddNodeInfo(Node, "1. SERVER OK POW for client node " + SocketInfo(Socket))
global.AddNodeInfo(Node, "1. SERVER OK POW for client node " + global.SocketInfo(Socket))
Node.FromIP = Info.FromIP
Node.FromPort = Info.FromPort
Node.SecretForReconnect = crypto.randomBytes(20)
@ -829,11 +827,11 @@ export default class CTransport extends require("./connect")
Node.NextConnectDelta = 1000
Node.WaitConnectFromServer = 0
Node.GrayConnect = 1
global.AddNodeInfo(Node, "5. CLIENT OK GRAY CONNECT " + SocketInfo(Socket))
global.AddNodeInfo(Node, "5. CLIENT OK GRAY CONNECT " + global.SocketInfo(Socket))
this.AddNodeToActive(Node)
Node.Socket = Socket
SetSocketStatus(Socket, 3)
SetSocketStatus(Socket, 100)
global.SetSocketStatus(Socket, 3)
global.SetSocketStatus(Socket, 100)
Socket.Node = Node
Socket.write(this.GetBufFromData("POW_CONNECT0", "OK", 2))
return;
@ -865,7 +863,7 @@ export default class CTransport extends require("./connect")
}
let SOCKET = sock;
global.socketInit(SOCKET, "c")
SetSocketStatus(SOCKET, 0)
global.SetSocketStatus(SOCKET, 0)
global.AddNodeInfo(SOCKET, "Client *" + SOCKET.ConnectID + " connected from " + SOCKET.remoteAddress + ":" + SOCKET.remotePort, 1)
global.ADD_TO_STAT("ClientConnected")
SOCKET.HashRND = crypto.randomBytes(32)
@ -904,9 +902,9 @@ export default class CTransport extends require("./connect")
SOCKET.on('end', function() {
global.ADD_TO_STAT("ClientEnd")
var Node = SOCKET.Node;
var Status = GetSocketStatus(SOCKET);
var Status = global.GetSocketStatus(SOCKET);
if (Status)
global.AddNodeInfo(Node, "Get socket end *" + SOCKET.ConnectID + " from client Stat: " + SocketStatistic(SOCKET))
global.AddNodeInfo(Node, "Get socket end *" + SOCKET.ConnectID + " from client Stat: " + global.SocketStatistic(SOCKET))
if (Node && Status === 200) {
Node.SwapSockets()
SOCKET.WasClose = 1
@ -914,12 +912,12 @@ export default class CTransport extends require("./connect")
})
SOCKET.on('close', function(err) {
global.ADD_TO_STAT("ClientClose")
if (SOCKET.ConnectID && GetSocketStatus(SOCKET))
global.AddNodeInfo(SOCKET.Node, "Get socket close *" + SOCKET.ConnectID + " from client Stat: " + SocketStatistic(SOCKET))
if (SOCKET.ConnectID && global.GetSocketStatus(SOCKET))
global.AddNodeInfo(SOCKET.Node, "Get socket close *" + SOCKET.ConnectID + " from client Stat: " + global.SocketStatistic(SOCKET))
if (!SOCKET.WasClose && SOCKET.Node) {
global.CloseSocket(SOCKET, "GET CLOSE")
}
SetSocketStatus(SOCKET, 0)
global.SetSocketStatus(SOCKET, 0)
})
SOCKET.on('error', function(err) {
global.ADD_TO_STAT("ERRORS")
@ -999,7 +997,7 @@ export default class CTransport extends require("./connect")
global.CloseSocket(Context.Socket, "CLOSE_SOCKET")
}
SendCloseSocket(Socket, Str) {
global.AddNodeInfo(Socket.Node, "CLOSE_SOCKET " + SocketInfo(Socket) + " - " + Str)
global.AddNodeInfo(Socket.Node, "CLOSE_SOCKET " + global.SocketInfo(Socket) + " - " + Str)
if (Socket.WasClose) {
return;
}

View File

@ -9,6 +9,7 @@
*/
"use strict";
import CConsensus from './block-exchange'
require("../system/dapp");
require("../system/accounts");
require("../system/smart");
@ -17,13 +18,20 @@ require("../system/messager");
require("../system/names");
if (global.PROCESS_NAME === "MAIN" || global.PROCESS_NAME === "TX")
require("./wallet");
module.exports = class CSmartContract extends require("./block-exchange")
{
export default class CSmartContract extends CConsensus {
BufHashTree
SenderBlockHashMap
SenderMap
WasReloadSenderMapFromDB
constructor(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual) {
super(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)
this.BufHashTree = new global.RBTree(global.CompareArr)
this.BufHashTree.LastAddNum = 0
this.SenderBlockHashMap = {}
this.SenderMap = {}
if (!global.ADDRLIST_MODE && !this.VirtualMode && global.START_SERVER) {
setInterval(this.ClearOldSenderMapItem.bind(this), 10000)
}
}
AddBlockToHashTree(Block) {
this.BufHashTree.LastAddNum = Block.BlockNum
@ -45,6 +53,9 @@ module.exports = class CSmartContract extends require("./block-exchange")
}
}
OnWriteBlock(Block) {
this.AddToSenderMap(Block)
}
OnDelete(Block) {
}
BlockProcessTX(Block) {
if (Block.BlockNum < 1)
@ -82,7 +93,7 @@ module.exports = class CSmartContract extends require("./block-exchange")
var arr = Block.arrContent;
if (arr)
for (var i = 0; i < arr.length; i++) {
var HASH = global.shaarr(arr[i]);
var HASH = global.sha3(arr[i]);
if (this.BufHashTree.find(HASH)) {
continue;
}
@ -91,7 +102,7 @@ module.exports = class CSmartContract extends require("./block-exchange")
if (App) {
App.ResultTx = 0
global.DApps.Accounts.BeginTransaction()
var StrHex = global.GetHexFromArr(global.sha3(arr[i]));
var StrHex = global.GetHexFromArr(HASH);
var item;
global.CurTrItem = undefined
if (global.TreeFindTX) {
@ -148,8 +159,6 @@ module.exports = class CSmartContract extends require("./block-exchange")
global.DApps[key].OnDeleteBlock(Block)
}
}
OnDelete(Block) {
}
IsValidTicket(Tr, BlockNum) {
this.CheckCreateTicketObject(Tr, BlockNum)
if (Tr.power < global.MIN_POWER_POW_TR)
@ -218,4 +227,87 @@ module.exports = class CSmartContract extends require("./block-exchange")
global.TX_PROCESS.Worker.send({ cmd: "FindTX", TX: StrHex })
return this.AddTransaction(Tr, 1);
}
AddTransaction(Tr, ToAll) {
// transfer-msg.ts(CMessages)
}
AddToSenderMap(Block) {
var BlockNum = Block.BlockNum;
var StrBlockHash = global.GetHexFromArr(Block.Hash);
this.SenderBlockHashMap[BlockNum] = StrBlockHash
var arr = Block.arrContent;
if (arr) {
for (var i = 0; i < arr.length; i++) {
var type = arr[i][0];
var App = global.DAppByType[type];
if (App) {
var Body = arr[i];
var SenderNum = App.GetSenderNum(BlockNum, Body);
if (SenderNum < 0)
continue;
var ItemArr = this.SenderMap[SenderNum];
if (!ItemArr) {
ItemArr = []
this.SenderMap[SenderNum] = ItemArr
}
ItemArr.push({ BlockNum: BlockNum, StrHash: StrBlockHash })
}
}
}
}
GetSenderPrioritet(BlockNum, SenderNum) {
if (!this.WasReloadSenderMapFromDB)
this.ReloadSenderMapFromDB()
if (SenderNum < 0)
return global.MAX_LENGTH_SENDER_MAP;
var MaxBlockNum = BlockNum - global.DELTA_START_SENDER_MAP;
if (MaxBlockNum > this.BlockNumDB)
return global.MAX_LENGTH_SENDER_MAP;
var ItemArr = this.SenderMap[SenderNum];
if (!ItemArr) {
return global.MAX_LENGTH_SENDER_MAP;
}
for (var i = ItemArr.length - 1; i--; i >= 0) {
var Item = ItemArr[i];
if (Item.BlockNum <= MaxBlockNum && this.SenderBlockHashMap[Item.BlockNum] === Item.StrHash) {
var Delta = MaxBlockNum - Item.BlockNum;
if (Delta > global.MAX_LENGTH_SENDER_MAP)
Delta = global.MAX_LENGTH_SENDER_MAP
return Delta;
}
}
return global.MAX_LENGTH_SENDER_MAP;
}
ReloadSenderMapFromDB() {
this.SenderMap = {}
this.SenderBlockHashMap = {}
var EndNum = global.GetCurrentBlockNumByTime();
var StartNum = EndNum - global.MAX_LENGTH_SENDER_MAP - global.DELTA_START_SENDER_MAP;
if (StartNum < 0)
StartNum = 0
for (var Num = StartNum; Num < EndNum; Num++) {
var Block = this.ReadBlockDB(Num);
if (!Block)
break;
this.AddToSenderMap(Block)
}
this.WasReloadSenderMapFromDB = 1
}
ClearOldSenderMapItem() {
var MinBlockNum = global.GetCurrentBlockNumByTime() - global.MAX_LENGTH_SENDER_MAP * 2;
var ArrForDel = [];
for (var key in this.SenderMap) {
var ItemArr = this.SenderMap[key];
while (ItemArr.length) {
var Item = ItemArr[0];
if (Item.BlockNum > MinBlockNum)
break;
ItemArr.shift()
}
if (ItemArr.length === 0)
ArrForDel.push(key)
}
for (var i = 0; i < ArrForDel.length; i++) {
delete this.SenderMap[ArrForDel[i]]
}
}
};

View File

@ -9,11 +9,10 @@
*/
"use strict";
import CSmartContract from './transaction-validator'
const MAX_MESSAGE_COUNT = 1000;
module.exports = class CMessages extends require("./transaction-validator")
{
export default class CMessages extends CSmartContract {
MemPoolMsg
constructor(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual) {
super(SetKeyPair, RunIP, RunPort, UseRNDHeader, bVirtual)
this.MemPoolMsg = []
@ -194,7 +193,7 @@ module.exports = class CMessages extends require("./transaction-validator")
}
Node.TaskLastSend = CurTime
this.SendF(Node, { "Method": "TRANSACTION", "Data": Tr }, Tr.body.length + 1000)
ToLogContext("Send " + TrName(Tr) + " to " + NodeName(Node))
ToLogContext("Send " + TrName(Tr) + " to " + global.NodeName(Node))
Count--
if (Count <= 0)
break;
@ -206,7 +205,7 @@ module.exports = class CMessages extends require("./transaction-validator")
}
TRANSACTION(Info, CurTime) {
var Tr = this.DataFromF(Info);
ToLogContext("Receive " + TrName(Tr) + " from " + NodeName(Info.Node))
ToLogContext("Receive " + TrName(Tr) + " from " + global.NodeName(Info.Node))
this.AddTransaction(Tr, 0)
}
};

View File

@ -7,7 +7,7 @@
* Twitter: https://twitter.com/terafoundation
* Telegram: https://t.me/terafoundation
*/
const fs = require('fs')
global.RunOnUpdate = RunOnUpdate;
function RunOnUpdate() {
@ -146,10 +146,11 @@ function RecreateAccountHashDB3() {
}
};
import '../core/db/db-row'
function ReWriteDBSmartWrite() {
global.UpdateMode = 1;
global.ToLog("Start ReWriteDBSmartWrite");
require("../core/db/db-row");
for (var num = 0; true; num++) {
var Item = global.DApps.Smart.DBSmart.Read(num);
if (!Item)

36
src/global.d.ts vendored
View File

@ -415,19 +415,19 @@ declare global {
//#endregion
//#region block-db.ts
BlockDB: any;
BLOCK_HEADER_SIZE: number;
BLOCK_HEADER_SIZE2: number;
DB_VERSION: number;
AddInfoChain: Function;
AddInfoBlock: Function;
GetNodeStrPort: Function;
NO_CHECK_BLOCKNUM_ONSTART: number;
//#endregion
// //#region block-db.ts
// BlockDB: any;
// BLOCK_HEADER_SIZE: number;
// BLOCK_HEADER_SIZE2: number;
// DB_VERSION: number;
// AddInfoChain: Function;
// AddInfoBlock: Function;
// GetNodeStrPort: Function;
// NO_CHECK_BLOCKNUM_ONSTART: number;
// //#endregion
//#region db.ts
CheckStartOneProcess: Function;
//CheckStartOneProcess: Function;
//#endregion
//#region update.ts
@ -439,10 +439,16 @@ declare global {
FORMAT_FILE_CREATE: string;
//#endregion
//#region dapp.ts
DApps: any;
DAppByType: any;
//#endregion
// //#region dapp.ts
// DApps: {
// Accounts?: any,
// File?: any,
// Names?: any,
// Messager?: any,
// Smart?: any,
// };
// DAppByType: any;
// //#endregion
//#region names.ts
NAMES: any;

View File

@ -37,12 +37,19 @@ global.glCurNumFindArr = 0;
global.ArrReconnect = [];
global.ArrConnect = [];
var FindList = [
{ "ip": "91.235.136.81", "port": 30005 },
{ "ip": "149.154.70.158", "port": 30000 },
{ "ip": "185.240.243.182", "port": 30000 },
{ "ip": "212.109.197.205", "port": 30000 },
{ "ip": "212.109.197.209", "port": 30000 },
{ "ip": "80.87.192.24", "port": 30000 },
{ "ip": "60.12.241.181", "port": 30000 },
{ "ip": "60.12.241.181", "port": 30001 },
{ "ip": "60.12.241.181", "port": 30002 },
{ "ip": "60.12.241.181", "port": 30003 },
{ "ip": "60.12.241.181", "port": 30004 },
{ "ip": "60.12.241.181", "port": 30005 },];
{ "ip": "60.12.241.181", "port": 30005 },
];
if (global.LOCAL_RUN) {
FindList = [{ "ip": "127.0.0.1", "port": 50001 }, { "ip": "127.0.0.1", "port": 50002 }];
}
@ -351,16 +358,12 @@ global.StopChildProcess = function() {
};
require("../core/html-server");
RunServer();
let {
ArrReconnect,
ArrConnect
} = global
setInterval(function run1() {
DoConnectToNodes(ArrReconnect, "RECONNECT");
DoConnectToNodes(global.ArrReconnect, "RECONNECT");
}, 200);
setInterval(function run2() {
DoGetNodes();
DoConnectToNodes(ArrConnect, "CONNECT");
DoConnectToNodes(global.ArrConnect, "CONNECT");
}, 500);
var StartCheckMining = 0;
global.MiningPaused = 0;
@ -536,7 +539,7 @@ function DoGetNodes() {
return;
if (global.SERVER.BusyLevel && Node.BlockProcessCount <= global.SERVER.BusyLevel)
return;
if (GetSocketStatus(Node.Socket) === 100) {
if (global.GetSocketStatus(Node.Socket) === 100) {
global.SERVER.StartGetNodes(Node);
}
};
@ -572,19 +575,12 @@ function DoConnectToNodes(Arr, Mode) {
var idRunOnce;
function RunServer() {
let {
GetNetworkName,
NET_WORK_MODE,
SAVE_CONST,
START_IP,
START_PORT_NUMBER
} = global
idRunOnce = setInterval(RunOnce, 1000);
global.ToLog("NETWORK: " + GetNetworkName());
global.ToLog("NETWORK: " + global.GetNetworkName());
global.ToLog("VERSION: " + global.DEF_VERSION);
if (global.NET_WORK_MODE) {
global.START_IP = NET_WORK_MODE.ip;
global.START_PORT_NUMBER = NET_WORK_MODE.port;
global.START_IP = global.NET_WORK_MODE.ip;
global.START_PORT_NUMBER = global.NET_WORK_MODE.port;
}
var KeyPair = crypto.createECDH('secp256k1');
if (!global.SERVER_PRIVATE_KEY_HEX || global.NEW_SERVER_PRIVATE_KEY) {
@ -596,7 +592,7 @@ function RunServer() {
break;
}
global.SERVER_PRIVATE_KEY_HEX = global.GetHexFromArr(Arr);
SAVE_CONST(true);
global.SAVE_CONST(true);
}
var ServerPrivKey = global.GetArrFromHex(global.SERVER_PRIVATE_KEY_HEX);
if (global.USE_NET_FOR_SERVER_ADDRES) {
@ -615,7 +611,7 @@ function RunServer() {
}
}
KeyPair.setPrivateKey(Buffer.from(ServerPrivKey));
new CServer(KeyPair, START_IP, START_PORT_NUMBER, false, false);
new CServer(KeyPair, global.START_IP, global.START_PORT_NUMBER, false, false);
DoStartFindList();
};
@ -639,9 +635,9 @@ function RunOnce() {
if (global.SERVER && global.SERVER.CheckOnStartComplete) {
clearInterval(idRunOnce);
require("../core/update");
RunOnUpdate();
global.RunOnUpdate();
StartAllProcess(1);
require("./dogs");
// require("./dogs");
if (global.RESTART_PERIOD_SEC) {
var Period = (global.random(600) + global.RESTART_PERIOD_SEC);
global.ToLog("SET RESTART NODE AFTER: " + Period + " sec");

View File

@ -71,8 +71,8 @@ function StartHashPump(e) {
(!global.BlockPump || global.BlockPump.BlockNum < e.BlockNum || global.BlockPump.MinerID !== e.MinerID || global.BlockPump.Percent !== e.Percent) && (global.BlockPump = {
BlockNum: e.BlockNum,
RunCount: e.RunCount, MinerID: e.MinerID, Percent: e.Percent, LastNonce: 0
}), idIntervalPump || (idIntervalPump = setInterval(PumpHash,
global.POWRunPeriod));
}), idIntervalPump = idIntervalPump || setInterval(PumpHash,
global.POWRunPeriod);
};
var StartTime = 1, EndTime = 0;

View File

@ -91,7 +91,7 @@ process.on('error' as any, function(err: TeraError) {
global.ToError("STATIC-DB:\n" + err.stack);
global.ToLog(err.stack);
});
var CServerDB = require("../core/db/block-db");
import CServerDB from '../core/db/block-db'
var KeyPair = crypto.createECDH('secp256k1');
KeyPair.setPrivateKey(Buffer.from([77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77]));
global.SERVER = new CServerDB(KeyPair, undefined, undefined, false, true);

View File

@ -90,10 +90,9 @@ process.on('error' as any, function(err: TeraError) {
global.ToLog(err.stack);
});
global.HTTP_PORT_NUMBER = 0;
var CServerDB = require("../core/transaction-validator");
import CServerDB from '../core/transaction-validator'
var KeyPair = crypto.createECDH('secp256k1');
KeyPair.setPrivateKey(Buffer.from([77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
77, 77, 77, 77, 77, 77, 77, 77, 77, 77]));
KeyPair.setPrivateKey(Buffer.from([77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77]));
global.SERVER = new CServerDB(KeyPair, undefined, undefined, false, true);
global.TreeFindTX = new global.STreeBuffer(30 * 1000, global.CompareItemHashSimple, "string");
setInterval(function() {
@ -243,7 +242,9 @@ function InitTXProcess() {
if (LastBlockNum > 100) {
LastBlockNum = 1 + LastBlockNum - 100;
}
global.ToLog("Start CalcMerkleTree", 2);
global.DApps.Accounts.CalcMerkleTree(1);
global.ToLog("Finsih CalcMerkleTree", 2);
if (LastBlockNum <= 0)
RewriteAllTransactions();
else

View File

@ -35,12 +35,6 @@ setInterval(function() {
}, 1000);
process.send({ cmd: "online", message: "OK" });
process.on('message', function(msg) {
let {
GlobalRunMap,
ADD_TO_STAT,
ToLogClient0,
ArrLogClient
} = global
LastAlive = Date.now();
switch (msg.cmd) {
case "ALive":
@ -62,14 +56,14 @@ process.on('message', function(msg) {
process.send({ cmd: "retcall", id: msg.id, Err: Err, Params: Ret });
break;
case "retcall":
var F = GlobalRunMap[msg.id];
var F = global.GlobalRunMap[msg.id];
if (F) {
delete GlobalRunMap[msg.id];
delete global.GlobalRunMap[msg.id];
F(msg.Err, msg.Params);
}
break;
case "Stat":
ADD_TO_STAT(msg.Name, msg.Value);
global.ADD_TO_STAT(msg.Name, msg.Value);
break;
case "NodeList":
HostNodeList = msg.Value;
@ -85,7 +79,7 @@ process.on('message', function(msg) {
}
case "ToLogClient":
{
ToLogClient0(msg.Str, msg.StrKey, msg.bFinal);
global.ToLogClient0(msg.Str, msg.StrKey, msg.bFinal);
break;
}
case "RetFindTX":
@ -98,7 +92,7 @@ process.on('message', function(msg) {
break;
}
}
ArrLogClient.push({ text: msg.ResultStr, key: msg.TX, final: msg.bFinal, });
global.ArrLogClient.push({ text: msg.ResultStr, key: msg.TX, final: msg.bFinal, });
break;
}
}
@ -142,8 +136,7 @@ if (!global.HTTP_HOSTING_PORT) {
}
var CServerDB = require("../core/db/block-db");
var KeyPair = crypto.createECDH('secp256k1');
KeyPair.setPrivateKey(Buffer.from([77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
77, 77, 77, 77, 77, 77, 77, 77, 77, 77]));
KeyPair.setPrivateKey(Buffer.from([77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77]));
global.SERVER = new CServerDB(KeyPair, undefined, undefined, false, true);
global.HTTP_PORT_NUMBER = 0;
require("../core/html-server");
@ -240,16 +233,12 @@ var bWasRun = 0;
var TimeToRerun = 3000;
function RunListenServer() {
let {
ToLogClient,
LISTEN_IP
} = global
HostingServer.on('error', function(err) {
if (err.code === 'EADDRINUSE') {
TimeToRerun = Math.floor(TimeToRerun * 1.1);
if (TimeToRerun > 1000000 * 1000)
return;
ToLogClient('Port ' + global.HTTP_HOSTING_PORT + ' in use, retrying...');
global.ToLogClient('Port ' + global.HTTP_HOSTING_PORT + ' in use, retrying...');
if (HostingServer.Server)
HostingServer.Server.close();
if (!bWasRun)
@ -261,10 +250,10 @@ function RunListenServer() {
global.ToError("H##6");
global.ToError(err);
});
ToLogClient("Prepare to run WEB-server on port: " + global.HTTP_HOSTING_PORT);
HostingServer.listen(global.HTTP_HOSTING_PORT, LISTEN_IP, function() {
global.ToLogClient("Prepare to run WEB-server on port: " + global.HTTP_HOSTING_PORT);
HostingServer.listen(global.HTTP_HOSTING_PORT, global.LISTEN_IP, function() {
if (!bWasRun)
ToLogClient("Run WEB-server on " + LISTEN_IP + ":" + global.HTTP_HOSTING_PORT);
global.ToLogClient("Run WEB-server on " + global.LISTEN_IP + ":" + global.HTTP_HOSTING_PORT);
bWasRun = 1;
});
};

View File

@ -1,12 +1,10 @@
const fs = require('fs');
const os = require('os');
if(!global.DATA_PATH || global.DATA_PATH==="")
global.DATA_PATH="../DATA-TEST";
global.CODE_PATH=process.cwd();
if (!global.DATA_PATH || global.DATA_PATH === "")
global.DATA_PATH = "../DATA-TEST";
global.CODE_PATH = process.cwd();
global.HTTP_PORT_NUMBER = 8080;
global.START_PORT_NUMBER = 40000;
if(global.LOCAL_RUN===undefined)
global.LOCAL_RUN=0;
if (global.LOCAL_RUN === undefined)
global.LOCAL_RUN = 0;
global.TEST_NETWORK = 1;

View File

@ -10,11 +10,12 @@
"use strict";
import * as fs from 'fs'
const DBRow = require("../core/db/db-row");
import DApp from './dapp'
import DBRow from '../core/db/db-row'
import DBLib from "../core/db/db"
require('../core/rest_tables');
const MAX_SUM_TER = 1e9;
const MAX_SUM_CENT = 1e9;
const DBLib = require("../core/db/db");
global.HistoryDB = new DBLib();
const FILE_NAME_HISTORY = "history-body";
var WorkStructHistory = {};
@ -135,8 +136,7 @@ class MerkleDBRow extends DBRow {
}
}
};
class AccountApp extends require("./dapp")
{
class AccountApp extends DApp {
CreateTrCount
FORMAT_ACCOUNT_ROW
SIZE_ACCOUNT_ROW
@ -178,8 +178,7 @@ class AccountApp extends require("./dapp")
}"
this.SIZE_ACCOUNT_ROW_REST = 1024
this.DBRest = new DBRow("accounts-rest", this.SIZE_ACCOUNT_ROW_REST, this.FORMAT_ACCOUNT_ROW_REST, bReadOnly)
this.DBAct = new DBRow("accounts-act", 6 + 6 + (6 + 4 + 6 + 6 + 84) + 1 + 11, "{ID:uint, BlockNum:uint,PrevValue:{SumCOIN:uint,SumCENT:uint32, NextPos:uint, OperationID:uint,Smart:uint32,Data:arr80}, Mode:byte, TrNum:uint16, Reserve: arr9}",
bReadOnly)
this.DBAct = new DBRow("accounts-act", 6 + 6 + (6 + 4 + 6 + 6 + 84) + 1 + 11, "{ID:uint, BlockNum:uint,PrevValue:{SumCOIN:uint,SumCENT:uint32, NextPos:uint, OperationID:uint,Smart:uint32,Data:arr80}, Mode:byte, TrNum:uint16, Reserve: arr9}", bReadOnly)
this.DBActPrev = new DBRow("accounts-act-prev", this.DBAct.DataSize, this.DBAct.Format, bReadOnly)
this.FORMAT_STATE_HISTORY = "{NextPos:uint,Reserv:arr2}"
this.DBStateHistory = new DBRow("history-state", 8, this.FORMAT_STATE_HISTORY, bReadOnly)
@ -188,8 +187,7 @@ class AccountApp extends require("./dapp")
this.DBStateTX = new DBRow("accounts-tx", 6 + 6 + 88, "{BlockNum:uint, BlockNumMin:uint, Reserve: arr88}", bReadOnly)
if (global.READ_ONLY_DB)
return;
this.DBAccountsHash = new DBRow("accounts-hash3", 6 + 32 + 32 + 32 + 6 + 6 + 14, "{BlockNum:uint, AccHash:hash, SumHash:hash, SmartHash:hash, AccountMax:uint, SmartCount:uint, Reserve: arr14}",
bReadOnly)
this.DBAccountsHash = new DBRow("accounts-hash3", 6 + 32 + 32 + 32 + 6 + 6 + 14, "{BlockNum:uint, AccHash:hash, SumHash:hash, SmartHash:hash, AccountMax:uint, SmartCount:uint, Reserve: arr14}", bReadOnly)
if (global.START_SERVER)
return;
if (!bReadOnly)
@ -210,8 +208,9 @@ class AccountApp extends require("./dapp")
this.DBStateTX.Truncate(- 1)
this.DBRest.Truncate(- 1)
this._DBStateWrite({ Num: 0, PubKey: [], Value: { BlockNum: 1, SumCOIN: 0.95 * global.TOTAL_SUPPLY_TERA }, Name: "System account" }, 1)
for (var i = 1; i < 8; i++)
for (var i = 1; i < 8; i++) {
this._DBStateWrite({ Num: i, PubKey: [], Value: { BlockNum: 1 }, Name: "" })
}
this._DBStateWrite({ Num: 8, PubKey: global.GetArrFromHex(global.ARR_PUB_KEY[0]), Value: { BlockNum: 1, SumCOIN: 0.05 * global.TOTAL_SUPPLY_TERA }, Name: "Founder account" })
this._DBStateWrite({ Num: 9, PubKey: global.GetArrFromHex(global.ARR_PUB_KEY[1]), Value: { BlockNum: 1, SumCOIN: 0 }, Name: "Developer account" })
for (var i = 10; i < global.BLOCK_PROCESSING_LENGTH2; i++)
@ -296,18 +295,19 @@ class AccountApp extends require("./dapp")
var FileNameFull2 = this.DBActPrev.FileNameFull + "_del";
try {
fs.renameSync(this.DBActPrev.FileNameFull, FileNameFull2)
}
catch (e) {
global.ToLog("Can-t rename for delete act-file: " + FileNameFull2)
} catch (e) {
global.ToLog("Can-t rename for delete act-file: " + FileNameFull2 + " " + e)
return;
}
fs.unlinkSync(FileNameFull2)
}
try {
fs.renameSync(this.DBAct.FileNameFull, this.DBActPrev.FileNameFull)
}
catch (e) {
} catch (e) {
global.ToLog("Can-t rename act-file!")
console.error(e)
console.log(`${this.DBAct}, ${this.DBActPrev}`)
console.log(`${this.DBAct.FileNameFull}, ${this.DBActPrev.FileNameFull}`)
return;
}
}
@ -358,8 +358,7 @@ class AccountApp extends require("./dapp")
var Result;
try {
Result = this.OnWriteTransactionTR(Block, Body, BlockNum, TrNum, ContextFrom)
}
catch (e) {
} catch (e) {
Result = "" + e
}
if (Result !== true) {
@ -396,8 +395,7 @@ class AccountApp extends require("./dapp")
Result = 1
if (global.LOCAL_RUN || global.TEST_NETWORK) {
}
else {
} else {
if (BlockNum < global.global.START_BLOCK_ACCOUNT_HASH + 200000)
break;
}
@ -531,34 +529,35 @@ class AccountApp extends require("./dapp")
global.ConvertBufferToStr(TR)
return JSON.stringify(TR, undefined, 2);
}
TRCheckAccountHash(Body, BlockNum, TrNum) {
if (BlockNum % global.PERIOD_ACCOUNT_HASH !== 0)
TRCheckAccountHash(Body, BlockNum, TrNum?) {
if (BlockNum % global.PERIOD_ACCOUNT_HASH !== 0) {
return 1;
}
try {
var TR = global.BufLib.GetObjectFromBuffer(Body, global.FORMAT_ACCOUNT_HASH3, {});
}
catch (e) {
} catch (e) {
return 0;
}
if (BlockNum < global.START_BLOCK_ACCOUNT_HASH + 200000)
if (BlockNum < global.START_BLOCK_ACCOUNT_HASH + 200000) {
return 1;
}
var Item = this.GetAccountHashItem(TR.BlockNum);
if (Item && Item.BlockNum === TR.BlockNum) {
if (global.CompareArr(Item.AccHash, TR.AccHash) === 0) {
if (TR.BlockNum >= global.START_BLOCK_ACCOUNT_HASH3) {
if (global.CompareArr(Item.SmartHash, TR.SmartHash) === 0 && Item.AccountMax === TR.AccountMax && Item.SmartCount === TR.SmartCount) {
return 1;
}
else
} else {
return 0;
}
}
return 1;
}
else
} else {
return 0;
}
else
}
} else {
return 2;
}
}
TRCreateAccount(Body, BlockNum, TrNum, ContextFrom) {
if (Body.length < 90)
@ -913,7 +912,7 @@ class AccountApp extends require("./dapp")
GetMaxAccount() {
return this.DBState.GetMaxNum();
}
GetRowsAccounts(start, count, Filter, bGetState) {
GetRowsAccounts(start, count, Filter?, bGetState?) {
if (Filter) {
Filter = Filter.trim()
}
@ -1005,7 +1004,7 @@ class AccountApp extends require("./dapp")
GetActsMaxNum() {
return this.DBActPrev.GetMaxNum() + this.DBAct.GetMaxNum();
}
GetActList(start, count) {
GetActList(start, count, b?) {
var arr = [];
var num;
for (num = start; num < start + count; num++) {
@ -1338,7 +1337,7 @@ class AccountApp extends require("./dapp")
}
return Position;
}
GetHistory(Num, Count, StartPos, MinConfirm) {
GetHistory(Num, Count, StartPos, MinConfirm?) {
if (!MinConfirm)
MinConfirm = 0
var MaxNumBlockDB = global.SERVER.GetMaxNumBlockDB();
@ -1392,7 +1391,6 @@ class AccountApp extends require("./dapp")
return global.FLOAT_FROM_COIN(SumCoin);
}
};
module.exports = AccountApp;
var App = new AccountApp;
global.DApps["Accounts"] = App;
global.DAppByType[global.TYPE_TRANSACTION_CREATE] = App;
@ -1401,6 +1399,7 @@ global.DAppByType[TYPE_DEPRECATED_TRANSFER2] = App;
global.DAppByType[TYPE_TRANSACTION_TRANSFER] = App;
global.DAppByType[global.TYPE_TRANSACTION_ACC_HASH] = App;
export default AccountApp;
// function TestStateFiles(Size, Format) {
// return;
// if (global.PROCESS_NAME !== "MAIN")

View File

@ -9,7 +9,6 @@
*/
"use strict";
// import * as fs from 'fs'
class DApp {
constructor() {
}
@ -39,12 +38,37 @@ class DApp {
}
OnDeleteBlock(Block) {
}
OnWriteTransaction(Block, Body, BlockNum, TrNum) {
OnWriteTransaction(Block, Body, BlockNum, TrNum, next) {
}
OnMessage(Msg) {
}
Close() {
}
};
module.exports = DApp;
import AccountApp from './accounts'
import SmartApp from './smart'
import MessagerApp from './messager'
import FileApp from './file'
import NameApp from './names'
declare global {
namespace NodeJS {
interface Global {
//#region dapp.ts
DApps: {
Accounts?: AccountApp,
File?: FileApp,
Names?: NameApp,
Messager?: MessagerApp,
Smart?: SmartApp,
DBHistory?: DApp,
};
DAppByType: any;
//#endregion
}
}
}
// function ReqDir(Path) {
// if (fs.existsSync(Path)) {
@ -59,3 +83,5 @@ module.exports = DApp;
// };
global.DApps = {};
global.DAppByType = {};
export default DApp;

View File

@ -9,12 +9,12 @@
*/
"use strict";
import DApp from './dapp'
global.TYPE_TRANSACTION_FILE = 5;
global.FORMAT_FILE_CREATE = "{type:byte,Name:str,ContentType:str,Reserve:arr10,Data:tr}";
//@ts-ignore
let WorkStructRun = {};
class FileApp extends require("./dapp")
{
class FileApp extends DApp {
constructor() {
super()
}
@ -34,7 +34,8 @@ class FileApp extends require("./dapp")
return 1;
}
};
module.exports = FileApp;
var App = new FileApp;
global.DApps["File"] = App;
global.DApps.File = App;
global.DAppByType[global.TYPE_TRANSACTION_FILE] = App;
export default FileApp

View File

@ -9,6 +9,7 @@
*/
"use strict";
import DApp from './dapp'
require('../core/crypto-library');
const OPEN_TYPE_TRANSACTION = 11;
const MESSAGE_TYPE_TRANSACTION = 12;
@ -16,8 +17,10 @@ const MAX_MSG_SIZE = 1024;
var TempArrayTr = new Uint8Array(MAX_MSG_SIZE);
const MESSAGE_START = 9;
const MESSAGE_END = MAX_MSG_SIZE - 5;
require("./names");
class CApp extends require("./dapp") {
import './names'
class MessagerApp extends DApp {
Server
Channels
NamesMap
constructor() {
@ -116,8 +119,9 @@ function TestEncryptDecrypt() {
console.log("Decrypt:");
console.log(Str2);
};
module.exports = CApp;
var Messager = new CApp;
global.DApps["Messager"] = Messager;
global.DAppByType[OPEN_TYPE_TRANSACTION] = Messager;
global.DAppByType[MESSAGE_TYPE_TRANSACTION] = Messager;
var messager = new MessagerApp();
global.DApps.Messager = messager;
global.DAppByType[OPEN_TYPE_TRANSACTION] = messager;
global.DAppByType[MESSAGE_TYPE_TRANSACTION] = messager;
export default MessagerApp;

View File

@ -9,9 +9,10 @@
*/
"use strict";
import DApp from './dapp'
const NAMES_TYPE_TRANSACTION = 10;
class NameApp extends require("./dapp")
{
class NameApp extends DApp {
Server
KeyValueMap;
CurrentNameArr;
constructor() {
@ -32,7 +33,8 @@ class NameApp extends require("./dapp")
}
}
};
module.exports = NameApp;
var Names = new NameApp;
global.DApps["Names"] = Names;
global.DAppByType[NAMES_TYPE_TRANSACTION] = Names;
var Name = new NameApp();
global.DApps.Names = Name;
global.DAppByType[NAMES_TYPE_TRANSACTION] = Name;
export default NameApp

View File

@ -9,11 +9,12 @@
*/
"use strict";
import DApp from './dapp'
import DBRow from '../core/db/db-row'
const LOC_ADD_NAME = "$";
require("../HTML/JS/lexer.js");
global.TickCounter = 0;
//@ts-ignore
const DBRow = require("../core/db/db-row");
const TYPE_TRANSACTION_SMART_CREATE = 130;
global.TYPE_TRANSACTION_SMART_RUN = 135;
const TYPE_TRANSACTION_SMART_CHANGE = 140;
@ -61,8 +62,7 @@ global.FORMAT_SMART_CHANGE = "{\
Sign:arr64,\
}";
const WorkStructChange = {};
class SmartApp extends require("./dapp")
{
class SmartApp extends DApp {
FORMAT_ROW
ROW_SIZE
DBSmart
@ -364,7 +364,7 @@ class SmartApp extends require("./dapp")
}
return true;
}
GetRows(start, count, Filter, Category, GetAllData, bTokenGenerate) {
GetRows(start, count, Filter, Category, GetAllData, bTokenGenerate?) {
if (Filter) {
Filter = Filter.trim()
Filter = Filter.toUpperCase()
@ -1213,9 +1213,10 @@ function StaticGetSmart(Num) {
};
ChangePrototype();
InitEval();
module.exports = SmartApp;
var smartApp = new SmartApp;
global.DApps["Smart"] = smartApp;
global.DApps.Smart = smartApp;
global.DAppByType[TYPE_TRANSACTION_SMART_CREATE] = smartApp;
global.DAppByType[global.TYPE_TRANSACTION_SMART_RUN] = smartApp;
global.DAppByType[TYPE_TRANSACTION_SMART_CHANGE] = smartApp;
export default SmartApp

View File

@ -3,7 +3,6 @@
"outDir": "dist",
"allowJs": true,
"sourceMap": true,
"noUnusedLocals": true,
"target": "es5"
},
"include": [