godprotocol 1.0.798 → 1.0.831

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.
package/framer.js CHANGED
@@ -1,61 +1,56 @@
1
1
  import Frame from "./Objects/Frame";
2
2
 
3
- const framer = (initiator) => {
4
- let frame = new Frame({
5
- Opcodes: {
6
- add: null,
7
- equal: null,
8
- multiply: null,
9
- subtract: null,
10
- divide: null,
11
- exp: null,
12
- equal: null,
13
- not_equal: null,
14
- greater_than: null,
15
- less_than: null,
16
- gte: null,
17
- lte: null,
3
+ let obj = {
4
+ Opcodes: {
5
+ add: null,
6
+ equal: null,
7
+ multiply: null,
8
+ subtract: null,
9
+ divide: null,
10
+ exp: null,
11
+ equal: null,
18
12
 
19
- send: null,
20
- readonly: null,
21
- socket_send: null,
13
+ send: null,
14
+ readonly: null,
15
+ socket_send: null,
22
16
 
23
- jmp: null,
24
- jmp_if: null,
25
- hold: null,
17
+ jmp: null,
26
18
 
27
- stdout: null,
28
- stdin: null,
19
+ stdout: null,
20
+ stdin: null,
29
21
 
30
- run: null,
31
- load: null,
32
- parse: null,
33
- create_account: null,
22
+ run: null,
23
+ load: null,
24
+ parse: null,
25
+ create_account: null,
26
+ },
27
+ Datatypes: {
28
+ Number: null,
29
+ String: null,
30
+ Twain: null,
31
+ Array: null,
32
+ },
33
+ Objects: {
34
+ Blockchain: {
35
+ Chain: null,
36
+ Block: null,
34
37
  },
35
- Datatypes: {
36
- Number: null,
37
- String: null,
38
- Twain: null,
39
- Array: null,
38
+ Folder: {
39
+ active_file: null,
40
+ folder: null,
41
+ file: null,
40
42
  },
41
- Objects: {
42
- Blockchain: {
43
- Chain: null,
44
- Block: null,
45
- },
46
- Folder: {
47
- active_file: null,
48
- folder: null,
49
- file: null,
50
- },
51
- File: {
52
- row: null,
53
- parse: null,
54
- column: null,
55
- write: null,
56
- },
43
+ File: {
44
+ row: null,
45
+ parse: null,
46
+ column: null,
47
+ write: null,
57
48
  },
58
- });
49
+ },
50
+ };
51
+
52
+ const framer = (initiator) => {
53
+ let frame = new Frame(obj);
59
54
  frame.to_instruction();
60
55
  let instructions = frame.flatten_instructions();
61
56
 
@@ -63,3 +58,4 @@ const framer = (initiator) => {
63
58
  };
64
59
 
65
60
  export default framer;
61
+ export { obj };
package/opcodes/add.js CHANGED
@@ -5,11 +5,6 @@ let ops = [
5
5
  { name: "divide", sign: "/" },
6
6
  { name: "exp", sign: "**" },
7
7
  { name: "equal", sign: "==" },
8
- { name: "not_equal", sign: "!=" },
9
- { name: "greater_than", sign: ">" },
10
- { name: "less_than", sign: "<" },
11
- { name: "gte", sign: ">=" },
12
- { name: "lte", sign: "<=" },
13
8
  ];
14
9
 
15
10
  export { ops };
@@ -0,0 +1,28 @@
1
+ const getter = (args) => {
2
+ let base = args.op0;
3
+ if (typeof base === "number") return base;
4
+
5
+ if (typeof base === "string") return base[args.op1];
6
+
7
+ if (Array.isArray(base)) return base.slice(args.op1)[0];
8
+
9
+ return base[args.op1];
10
+ };
11
+
12
+ const setter = (args) => {
13
+ let base = args.op0;
14
+ if (typeof base === "number") return base;
15
+
16
+ if (typeof base === "string") {
17
+ base = `${base.slice(0, args.op2)}${args.op1}${base.slice(args.op2 + 1)}`;
18
+ } else {
19
+ if (Array.isArray(base)) {
20
+ if (args.op2 == null || args.op2 >= base.length) base.push(args.op1);
21
+ else base[args.op2] = args.op1;
22
+ } else base[args.op2] = args.op1;
23
+ }
24
+
25
+ return base;
26
+ };
27
+
28
+ export { setter, getter };
package/opcodes/jmp.js CHANGED
@@ -1,15 +1,14 @@
1
- const jmp = (args, vm) => {
2
- vm.account.manager.tracker[vm.mgr_index].pointer += args.index;
3
- };
1
+ const jmp = (args, vm, meta) => {
2
+ meta = meta || {};
3
+ let { flag, inverse } = meta;
4
4
 
5
- const jmp_if = (args, vm) => {
6
- if (args.passed)
7
- vm.account.manager.tracker[vm.mgr_index].pointer += args.index;
8
- };
5
+ let condition;
6
+ if (flag) condition = vm.flags[flag];
7
+ if (inverse) condition = !!!condition;
9
8
 
10
- const hold = (args, vm) => {
11
- let track = vm.account.manager.tracker[vm.mgr_index];
12
- track.hold = args.hold;
9
+ if ((condition || !flag) && typeof args.op0 === "number") {
10
+ vm.track.pointer = args.op0;
11
+ }
13
12
  };
14
13
 
15
- export { jmp, jmp_if, hold };
14
+ export { jmp };
package/opcodes/std.js CHANGED
@@ -1,6 +1,8 @@
1
- const stdout = (args) => {
1
+ const stdout = (args, vm) => {
2
2
  if (!args) return;
3
3
 
4
+ vm.account.stdout.push({ data: args, pid: vm.track.pid });
5
+
4
6
  for (let v in args) console.log(args[v]);
5
7
  };
6
8
 
package/opcodes.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // import { socket_send } from "./Socket";
2
2
  import { ops } from "./opcodes/add";
3
- import { hold, jmp, jmp_if } from "./opcodes/jmp";
3
+ import { getter, setter } from "./opcodes/indices";
4
+ import { jmp } from "./opcodes/jmp";
4
5
  import { stdout } from "./opcodes/std";
5
6
  import { post_request } from "./utils/services";
6
7
 
@@ -13,6 +14,10 @@ const opcodes = (account) => {
13
14
 
14
15
  try {
15
16
  let result = eval(`${args.op0} ${op.sign} ${args.op1}`);
17
+ if (op.sign === "==") {
18
+ account.vm.flags.equal = !!result;
19
+ return;
20
+ }
16
21
 
17
22
  return result;
18
23
  } catch (e) {
@@ -21,16 +26,25 @@ const opcodes = (account) => {
21
26
  });
22
27
  });
23
28
 
24
- set("hold", hold);
29
+ Object.keys(account.vm.flags).map((flag) => {
30
+ set(`jmp_${flag}`, (args, vm) => jmp(args, vm, { flag }));
31
+ set(`jmp_not_${flag}`, (args, vm) =>
32
+ jmp(args, vm, { flag, inverse: true })
33
+ );
34
+ });
25
35
  set("jmp", jmp);
26
- set("jmp_if", jmp_if);
36
+
37
+ set("setter", setter);
38
+ set("getter", getter);
27
39
 
28
40
  set("send", (data) => post_request(data, account.vm.stdin));
29
41
  // set("socket_send", socket_send);
30
42
 
31
43
  set("stdout", stdout);
32
44
 
33
- ["run", "load", "parse", "create_account"].map((op) =>
45
+ set("add_server", (args, vm) => account.add_server(args && args.op0))[
46
+ ("run", "load", "parse", "create_account")
47
+ ].map((op) =>
34
48
  set(op, (arg) => arg && arg.op0 && account[op](arg && arg.op0))
35
49
  );
36
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "godprotocol",
3
- "version": "1.0.798",
3
+ "version": "1.0.831",
4
4
  "description": "A data mediator.",
5
5
  "main": "Index.js",
6
6
  "types": "types/index.d.ts",
@@ -45,7 +45,8 @@
45
45
  "dependencies": {
46
46
  "crypto": "^1.0.1",
47
47
  "elliptic": "^6.5.5",
48
- "fs": "^0.0.1-security"
48
+ "fs": "^0.0.1-security",
49
+ "generalised-datastore": "^1.7.85"
49
50
  },
50
51
  "publishConfig": {
51
52
  "ignore": [
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "paths": {
5
+ "@types/*": ["types/*"]
6
+ }
7
+ }
8
+ }
package/types/Oracle.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import fs from "fs";
1
+ // import fs from "fs";
2
2
 
3
3
  declare class Oracle {
4
- fs: typeof fs;
4
+ // fs: typeof fs;
5
5
  mgr: any;
6
6
  datapaths: { [key: string]: { type: string; obj: any } };
7
7
 
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { default as Account } from "./Account";
2
2
  export { default as Virtual_machine } from "./Virtual_machine";
3
3
  export { default as Filesystem } from "./Filesystem";
4
- export { default as Loader_sequence } from "./Loader_sequence";
4
+ export { default as Loader_sequence } from "../Loader_sequence/main";
package/.babelrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "presets": [["@babel/preset-env"]]
3
- }
package/build/Account.js DELETED
@@ -1,162 +0,0 @@
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
69
- });
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
- error: true,
83
- error_message: "Address not found"
84
- });
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({
106
- sequence: program,
107
- account: account,
108
- pid: pid
109
- });
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;
package/build/Block.js DELETED
@@ -1,65 +0,0 @@
1
- "use strict";
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];
26
- 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];
33
- delete content[curs];
34
- }
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
- });
52
- obj.chain = {
53
- hash: _this.chain.hash,
54
- physical_address: _this.chain.physical_address
55
- };
56
- 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;
package/build/Blockweb.js DELETED
@@ -1,36 +0,0 @@
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];
22
- 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;
29
- 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;