godprotocol 1.0.79 → 1.0.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/Index.js +8 -14
  2. package/Loader_sequence/main.js +384 -206
  3. package/Objects/Account.js +191 -157
  4. package/Objects/Block.js +60 -58
  5. package/Objects/Blockweb.js +27 -34
  6. package/Objects/Chain.js +115 -118
  7. package/Objects/Explorer.js +30 -37
  8. package/Objects/Filesystem.js +95 -80
  9. package/Objects/Frame.js +43 -48
  10. package/Objects/Manager.js +67 -89
  11. package/Objects/Opcodes.js +43 -36
  12. package/Objects/Oracle.js +63 -40
  13. package/Objects/Virtual_machine.js +135 -127
  14. package/build/Account.js +187 -0
  15. package/build/Block.js +68 -0
  16. package/build/Blockweb.js +36 -0
  17. package/build/Chain.js +119 -0
  18. package/build/Explorer.js +47 -0
  19. package/build/Filesystem.js +127 -0
  20. package/build/Frame.js +52 -0
  21. package/build/Index.js +20 -0
  22. package/build/Manager.js +86 -0
  23. package/build/Opcodes.js +109 -0
  24. package/build/Oracle.js +81 -0
  25. package/build/Virtual_machine.js +136 -0
  26. package/build/add.js +26 -0
  27. package/build/create_server.js +132 -0
  28. package/build/framer.js +59 -0
  29. package/build/functions.js +82 -0
  30. package/build/hash.js +14 -0
  31. package/build/indices.js +31 -0
  32. package/build/jmp.js +19 -0
  33. package/build/main.js +327 -0
  34. package/build/opcodes.js +60 -0
  35. package/build/privacy.js +27 -0
  36. package/build/services.js +50 -0
  37. package/build/std.js +15 -0
  38. package/framer.js +58 -54
  39. package/opcodes/add.js +9 -40
  40. package/opcodes/indices.js +28 -0
  41. package/opcodes/jmp.js +12 -17
  42. package/opcodes/std.js +7 -9
  43. package/opcodes.js +36 -28
  44. package/package.json +4 -3
  45. package/tsconfig.json +8 -0
  46. package/types/Account.d.ts +73 -0
  47. package/types/Block.d.ts +22 -0
  48. package/types/Blockweb.d.ts +14 -0
  49. package/types/Chain.d.ts +35 -0
  50. package/types/Explorer.d.ts +9 -0
  51. package/types/Filesystem.d.ts +23 -0
  52. package/types/Frame.d.ts +14 -0
  53. package/types/Manager.d.ts +21 -0
  54. package/types/Opcodes.d.ts +11 -0
  55. package/types/Oracle.d.ts +17 -0
  56. package/types/Virtual_machine.d.ts +20 -0
  57. package/types/index.d.ts +4 -0
  58. package/utils/create_server.js +88 -108
  59. package/utils/functions.js +31 -43
  60. package/utils/hash.js +10 -11
  61. package/utils/privacy.js +10 -15
  62. package/utils/services.js +32 -33
@@ -1,162 +1,196 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _main = _interopRequireDefault(require("../Loader_sequence/main"));
8
- var _privacy = _interopRequireDefault(require("../utils/privacy"));
9
- var _Filesystem2 = _interopRequireDefault(require("./Filesystem"));
10
- var _Virtual_machine = _interopRequireDefault(require("./Virtual_machine"));
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
13
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
14
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
15
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
16
- function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
17
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
18
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
19
- function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
20
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
21
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
22
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
23
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
24
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
25
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
26
- var Account = /*#__PURE__*/function (_Filesystem) {
27
- _inherits(Account, _Filesystem);
28
- var _super = _createSuper(Account);
29
- function Account(_name) {
30
- var _this;
31
- var _meta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
32
- _classCallCheck(this, Account);
33
- _this = _super.call(this);
34
- _defineProperty(_assertThisInitialized(_this), "get_account", function (name) {
35
- return _this.manager.get_account(name) || _assertThisInitialized(_this);
36
- });
37
- _defineProperty(_assertThisInitialized(_this), "manage_buffer", function (callback) {
38
- var call_session = "".concat(Date.now(), "-").concat(Math.random());
39
- _this.mine_buffer[call_session] = {
40
- blocks: [],
41
- callback: callback
42
- };
43
- return call_session;
44
- });
45
- _defineProperty(_assertThisInitialized(_this), "buff", function (block, pid) {
46
- var buffer = _this.mine_buffer[pid];
47
- if (!buffer) return;
48
- buffer.blocks.push(block.stringify());
49
- });
50
- _defineProperty(_assertThisInitialized(_this), "flush_buffer", function (pid) {
51
- var buff = _this.mine_buffer[pid];
52
- if (!buff) return;
53
- buff.callback && _this.run_callback(buff.callback, buff.blocks);
54
- delete _this.mine_buffer[pid];
55
- });
56
- _defineProperty(_assertThisInitialized(_this), "load", function (_ref) {
57
- var program = _ref.program,
58
- signature = _ref.signature,
59
- callback = _ref.callback;
60
- var instructions = program.instructions,
61
- account = program.account;
62
- account = _this.get_account(account);
63
- if (!account.validate(program, signature)) return;
64
- var pid = account.manage_buffer(callback);
65
- _this.manager.push({
66
- sequence: instructions,
67
- account: account,
68
- pid: pid
1
+ import Loader_sequence from "../Loader_sequence/main";
2
+ import validate_signature from "../utils/privacy";
3
+ import Filesystem from "./Filesystem";
4
+ import Virtual_machine from "./Virtual_machine";
5
+
6
+ class Account extends Filesystem {
7
+ constructor(name, meta = {}) {
8
+ super();
9
+
10
+ meta = meta || {};
11
+
12
+ this.name = name;
13
+ this.private = meta.private;
14
+ this.manager = meta.manager;
15
+ this.account = this;
16
+ this.stdin = new Array();
17
+ this.stdout = new Array();
18
+
19
+ if (!this.manager) throw new Error("Manager instance missing.");
20
+
21
+ this.name_hash();
22
+ this.physical_address = `${this.base_address}/${this.name}`;
23
+ this.set_paths(this);
24
+
25
+ this.assembler = new Loader_sequence(this);
26
+
27
+ this.chain = this.account_chain(this);
28
+ this.vm = new Virtual_machine(this.chain);
29
+
30
+ this.mine_buffer = {};
31
+
32
+ console.log(`Account Instance: ${this.name}`);
33
+ }
34
+
35
+ get_account = (name) => {
36
+ return this.manager.get_account(name) || this;
37
+ };
38
+
39
+ manage_buffer = (callback) => {
40
+ let call_session = `${Date.now()}-${Math.random()}`;
41
+ this.mine_buffer[call_session] = { blocks: [], callback };
42
+
43
+ return call_session;
44
+ };
45
+
46
+ buff = (block, pid) => {
47
+ let buffer = this.mine_buffer[pid];
48
+ if (!buffer) return;
49
+
50
+ buffer.blocks.push(block.stringify());
51
+ };
52
+
53
+ flush_buffer = (pid) => {
54
+ let buff = this.mine_buffer[pid];
55
+ if (!buff) return;
56
+
57
+ buff.callback && this.run_callback(buff.callback, buff.blocks);
58
+ delete this.mine_buffer[pid];
59
+ };
60
+
61
+ load = ({ program, signature, callback }) => {
62
+ let { instructions, account } = program;
63
+ account = this.get_account(account);
64
+
65
+ if (!account.validate(program, signature, callback)) return;
66
+
67
+ let pid = account.manage_buffer(callback);
68
+
69
+ this.manager.push({ sequence: instructions, account, pid });
70
+ };
71
+
72
+ parse = ({ payload, signature, callback }) => {
73
+ let { physical_address, account, query } = payload;
74
+ account = this.get_account(account);
75
+
76
+ if (!account.validate(payload, signature))
77
+ return this.run_callback(callback, {
78
+ private: account.private,
79
+ error: true,
80
+ error_message: "Invalid signature",
69
81
  });
70
- });
71
- _defineProperty(_assertThisInitialized(_this), "parse", function (_ref2) {
72
- var payload = _ref2.payload,
73
- signature = _ref2.signature,
74
- callback = _ref2.callback;
75
- var physical_address = payload.physical_address,
76
- account = payload.account,
77
- query = payload.query;
78
- account = _this.get_account(account);
79
- if (!account.validate(payload, signature)) return;
80
- var chain = account.manager.web.get(physical_address);
81
- if (!chain) return _this.run_callback(callback, {
82
+
83
+ let chain = account.manager.web.get(physical_address);
84
+
85
+ if (!chain)
86
+ return this.run_callback(callback, {
82
87
  error: true,
83
- error_message: "Address not found"
88
+ error_message: "Address not found",
84
89
  });
85
- var data = query ? chain.explore(query) : chain;
86
- _this.run_callback(callback, data && data.stringify());
87
- });
88
- _defineProperty(_assertThisInitialized(_this), "run", function (request) {
89
- var payload = request.payload,
90
- signature = request.signature,
91
- callback = request.callback;
92
- var physical_address = payload.physical_address,
93
- account = payload.account,
94
- query = payload.query;
95
- account = _this.get_account(account);
96
- if (!account.validate(payload, signature)) return;
97
- var pid = account.manage_buffer(callback);
98
- var context = physical_address ? _this.manager.web.get(physical_address) : account.vm.get_context();
99
- if (!context) return account.flush_buffer(pid);
100
- var blk = query ? context.explore(query) : context.get_latest_block();
101
- if (blk && blk.metadata && blk.metadata.program) {
102
- var program = _this.read(blk.metadata.program);
103
- account.vm.contexts.push(context);
104
- program.push("pop");
105
- Array.isArray(program) && program.length && _this.manager.push({
90
+
91
+ let data = query ? chain.explore(query) : chain;
92
+
93
+ this.run_callback(callback, data && data.stringify());
94
+ };
95
+
96
+ run = (request) => {
97
+ let { payload, signature, callback } = request;
98
+
99
+ let { physical_address, account, query } = payload;
100
+ account = this.get_account(account);
101
+
102
+ if (!account.validate(payload, signature, callback)) return;
103
+
104
+ let pid = account.manage_buffer(callback);
105
+
106
+ let context = physical_address
107
+ ? this.manager.web.get(physical_address)
108
+ : account.vm.get_context();
109
+
110
+ if (!context) return account.flush_buffer(pid);
111
+
112
+ let blk = query ? context.explore(query) : context.get_latest_block();
113
+
114
+ if (blk && blk.metadata && blk.metadata.program) {
115
+ let program = this.read(blk.metadata.program);
116
+
117
+ account.vm.contexts.push(context);
118
+ program.push("pop");
119
+
120
+ Array.isArray(program) &&
121
+ program.length &&
122
+ this.manager.push({
106
123
  sequence: program,
107
- account: account,
108
- pid: pid
124
+ account,
125
+ pid,
109
126
  });
110
- } else account.flush_buffer(pid);
111
- });
112
- _defineProperty(_assertThisInitialized(_this), "run_callback", function (callback, payload) {
113
- setTimeout(function () {
114
- if (!callback) return;
115
- if (typeof callback === "function") return callback(payload);
116
- _this.vm.stdin(payload);
117
- callback.payload && callback.payload.physical_address && _this.run(callback);
118
- }, 0);
119
- });
120
- _defineProperty(_assertThisInitialized(_this), "validate", function (payload, signature) {
121
- if (!_this["private"]) return true;
122
- return (0, _privacy["default"])(_this.name, JSON.stringify(payload), signature);
123
- });
124
- _defineProperty(_assertThisInitialized(_this), "stringify", function (str) {
125
- var obj = {};
126
- obj.name = _this.name;
127
- obj.hash = _this.hash;
128
- obj.path = _this.path;
129
- obj["private"] = _this["private"];
130
- obj.chain = _this.chain.stringify();
131
- obj.physical_address = _this.physical_address;
132
- return str ? JSON.stringify(obj) : obj;
133
- });
134
- _defineProperty(_assertThisInitialized(_this), "create_account", function (payload) {
135
- var name = payload.name,
136
- meta = payload.meta;
137
- return _this.manager.add_account(name, meta);
138
- });
139
- _defineProperty(_assertThisInitialized(_this), "endpoint", function (endpoint, payload) {
140
- var method = _this[endpoint];
141
- typeof method === "function" && method(payload);
142
- });
143
- _meta = _meta || {};
144
- _this.name = _name;
145
- _this["private"] = _meta["private"];
146
- _this.manager = _meta.manager;
147
- _this.account = _assertThisInitialized(_this);
148
- if (!_this.manager) throw new Error("Manager instance missing.");
149
- _this.name_hash();
150
- _this.physical_address = "".concat(_this.base_address, "/").concat(_this.name);
151
- _this.set_paths(_assertThisInitialized(_this));
152
- _this.compiler = new _main["default"](_assertThisInitialized(_this));
153
- _this.chain = _this.account_chain(_assertThisInitialized(_this));
154
- _this.vm = new _Virtual_machine["default"](_this.chain);
155
- _this.mine_buffer = {};
156
- console.log("Account Instance: ".concat(_this.name));
157
- return _this;
158
- }
159
- return _createClass(Account);
160
- }(_Filesystem2["default"]);
161
- var _default = Account;
162
- exports["default"] = _default;
127
+ } else account.flush_buffer(pid);
128
+ };
129
+
130
+ run_callback = (callback, payload) => {
131
+ setTimeout(() => {
132
+ if (!callback) return;
133
+
134
+ if (typeof callback === "function") return callback(payload);
135
+
136
+ callback.payload &&
137
+ callback.payload.physical_address &&
138
+ this.vm.stdin(payload, () => this.run(callback));
139
+ }, 0);
140
+ };
141
+
142
+ flush_stdout = (block) => {
143
+ for (let s = 0; s < this.stdout.length; s++) {
144
+ let out = this.stdout[s];
145
+ if (out.pid === this.vm.track.pid) {
146
+ block.metadata.stdout.push(out.data);
147
+ this.stdout[s] = null;
148
+ }
149
+ }
150
+ this.stdout = this.stdout.filter((out) => !!out);
151
+ };
152
+
153
+ validate = (payload, signature, callback) => {
154
+ if (!this.private) return true;
155
+
156
+ let valid = validate_signature(
157
+ this.name,
158
+ JSON.stringify(payload),
159
+ signature
160
+ );
161
+ if (!valid && callback)
162
+ this.run_callback(callback, {
163
+ private: this.private,
164
+ error: true,
165
+ error_message: "Invalid signature",
166
+ });
167
+
168
+ return valid;
169
+ };
170
+
171
+ stringify = (str) => {
172
+ let obj = {};
173
+
174
+ obj.name = this.name;
175
+ obj.hash = this.hash;
176
+ obj.path = this.path;
177
+ obj.private = this.private;
178
+ obj.chain = this.chain.stringify();
179
+ obj.physical_address = this.physical_address;
180
+
181
+ return str ? JSON.stringify(obj) : obj;
182
+ };
183
+
184
+ create_account = (payload) => {
185
+ let { name, meta } = payload;
186
+
187
+ return this.manager.add_account(name, meta);
188
+ };
189
+
190
+ endpoint = (endpoint, payload) => {
191
+ let method = this[endpoint];
192
+ typeof method === "function" && method(payload);
193
+ };
194
+ }
195
+
196
+ export default Account;
package/Objects/Block.js CHANGED
@@ -1,65 +1,67 @@
1
- "use strict";
1
+ import { hash } from "../utils/hash";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _hash = require("../utils/hash");
8
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
9
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
10
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
12
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
13
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
- var Block = /*#__PURE__*/_createClass(function Block(chain) {
16
- var _this = this;
17
- _classCallCheck(this, Block);
18
- _defineProperty(this, "generate_hash", function () {
19
- _this.previous_hash = _this.chain.get_latest_block();
20
- if (_this.previous_hash) _this.previous_hash = _this.previous_hash.hash;
21
- _this.hash = (0, _hash.hash)(JSON.stringify(_this.data));
22
- });
23
- _defineProperty(this, "store", function (no_curs) {
24
- var content = _this.chain.buffs.splice(-1)[0];
25
- if (!no_curs) _this.cursor = _this.chain.cursors.splice(-1)[0];
3
+ class Block {
4
+ constructor(chain) {
5
+ this.chain = chain;
6
+ this.data = this.chain.txs;
7
+ this.metadata = {};
8
+ this.children = new Array();
9
+ this.index = this.chain.blocks.length;
10
+ }
11
+
12
+ generate_hash = () => {
13
+ this.previous_hash = this.chain.get_latest_block();
14
+ if (this.previous_hash) this.previous_hash = this.previous_hash.hash;
15
+
16
+ this.hash = hash(JSON.stringify(this.data));
17
+ };
18
+
19
+ store = (no_curs) => {
20
+ let content = this.chain.buffs.splice(-1)[0];
21
+ if (!no_curs) this.cursor = this.chain.cursors.splice(-1)[0];
26
22
  if (!content) return;
27
- var cursors = Object.keys(content).filter(function (c) {
28
- return c.startsWith("{") && c.endsWith("}");
29
- });
30
- for (var c = 0; c < cursors.length; c++) {
31
- var curs = cursors[c];
32
- _this.metadata[curs.slice(1, -1)] = content[curs];
23
+
24
+ let cursors = Object.keys(content).filter(
25
+ (c) => c.startsWith("{") && c.endsWith("}")
26
+ );
27
+
28
+ for (let c = 0; c < cursors.length; c++) {
29
+ let curs = cursors[c];
30
+
31
+ this.metadata[curs.slice(1, -1)] = content[curs];
33
32
  delete content[curs];
34
33
  }
35
- var datapath = _this.chain.account.save(content, _this.chain);
36
- _this.datapath = datapath;
37
- });
38
- _defineProperty(this, "stringify", function (str) {
39
- var obj = {};
40
- obj.metadata = _this.metadata;
41
- obj.datapath = _this.datapath;
42
- obj.timelapse = _this.timelapse;
43
- obj.index = _this.index;
44
- obj.hash = _this.hash;
45
- obj.data = _this.data;
46
- obj.children = _this.children.map(function (ch) {
47
- return new Object({
48
- hash: ch.hash,
49
- chain: ch.chain.hash
50
- });
51
- });
34
+ this.metadata.stdout = new Array();
35
+ this.chain.account.flush_stdout(this);
36
+
37
+ let datapath = this.chain.account.save(content, this.chain);
38
+ this.datapath = datapath;
39
+ };
40
+
41
+ stringify = (str) => {
42
+ let obj = {};
43
+
44
+ obj.metadata = this.metadata;
45
+ obj.datapath = this.datapath;
46
+ obj.timelapse = this.timelapse;
47
+ obj.index = this.index;
48
+ obj.hash = this.hash;
49
+ obj.data = this.data;
50
+ obj.children = this.children.map(
51
+ (ch) =>
52
+ new Object({
53
+ hash: ch.hash,
54
+ chain: ch.chain.hash,
55
+ physical_address: ch.chain.physical_address,
56
+ })
57
+ );
52
58
  obj.chain = {
53
- hash: _this.chain.hash,
54
- physical_address: _this.chain.physical_address
59
+ hash: this.chain.hash,
60
+ physical_address: this.chain.physical_address,
55
61
  };
62
+
56
63
  return str ? JSON.stringify(obj) : obj;
57
- });
58
- this.chain = chain;
59
- this.data = this.chain.txs;
60
- this.metadata = {};
61
- this.children = new Array();
62
- this.index = this.chain.blocks.length;
63
- });
64
- var _default = Block;
65
- exports["default"] = _default;
64
+ };
65
+ }
66
+
67
+ export default Block;
@@ -1,36 +1,29 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _Chain = _interopRequireDefault(require("./Chain"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
11
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
12
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
13
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
14
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
15
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
- var Blockweb = /*#__PURE__*/_createClass(function Blockweb(mgr) {
17
- var _this = this;
18
- _classCallCheck(this, Blockweb);
19
- _defineProperty(this, "get", function (addr) {
20
- var hash = _this.physical_addresses[addr];
21
- var chain = _this.chains[hash];
1
+ import Chain from "./Chain";
2
+
3
+ class Blockweb {
4
+ constructor(mgr) {
5
+ this.mgr = mgr;
6
+ this.physical_addresses = new Object();
7
+ this.chains = new Object();
8
+ }
9
+
10
+ get = (addr) => {
11
+ let hash = this.physical_addresses[addr];
12
+
13
+ let chain = this.chains[hash];
14
+
22
15
  return chain;
23
- });
24
- _defineProperty(this, "set", function (parent, name) {
25
- var chain = new _Chain["default"](parent, name);
26
- _this.chains[chain.hash] = chain;
27
- _this.physical_addresses[chain.physical_address] = chain.hash;
28
- _this.chains[chain.hash] = chain;
16
+ };
17
+
18
+ set = (parent, name) => {
19
+ let chain = new Chain(parent, name);
20
+ this.chains[chain.hash] = chain;
21
+
22
+ this.physical_addresses[chain.physical_address] = chain.hash;
23
+ this.chains[chain.hash] = chain;
24
+
29
25
  return chain;
30
- });
31
- this.mgr = mgr;
32
- this.physical_addresses = new Object();
33
- this.chains = new Object();
34
- });
35
- var _default = Blockweb;
36
- exports["default"] = _default;
26
+ };
27
+ }
28
+
29
+ export default Blockweb;