godprotocol 1.1.0 → 1.1.2

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 (98) hide show
  1. package/Datatypes/arr.js +11 -0
  2. package/Datatypes/bool.js +11 -0
  3. package/Datatypes/callable.js +11 -0
  4. package/Datatypes/functions/storage.js +5 -0
  5. package/Datatypes/num.js +11 -0
  6. package/Datatypes/str.js +11 -0
  7. package/Datatypes/twa.js +11 -0
  8. package/Datatypes/voi.js +11 -0
  9. package/Index.js +36 -2
  10. package/Objects/Account.js +35 -322
  11. package/Objects/Block.js +7 -80
  12. package/Objects/Blockweb.js +19 -26
  13. package/Objects/Callable.js +40 -0
  14. package/Objects/Chain.js +20 -244
  15. package/Objects/GDS/Arena_classic/.config +1 -0
  16. package/Objects/GDS/Arena_classic/Accounts/lola/.config +1 -0
  17. package/Objects/Manager.js +28 -294
  18. package/Objects/Oracle.js +67 -84
  19. package/Objects/Repository.js +67 -0
  20. package/Objects/Trinity.js +24 -0
  21. package/Objects/Virtual_machine.js +16 -206
  22. package/callables/functions/assign.js +6 -0
  23. package/callables/functions/display.js +3 -0
  24. package/callables/register.js +22 -0
  25. package/package.json +24 -43
  26. package/utils/create_server.js +35 -88
  27. package/utils/functions.js +0 -70
  28. package/utils/server.cert +23 -0
  29. package/utils/server.key +28 -0
  30. package/utils/services.js +61 -21
  31. package/utils/vm_utils.js +53 -275
  32. package/Executables/callables.js +0 -131
  33. package/Executables/executables.js +0 -230
  34. package/Executables/functions/adminstrator/adm_register.js +0 -29
  35. package/Executables/functions/adminstrator/native_components.js +0 -10
  36. package/Executables/functions/adminstrator/query_selectors.js +0 -10
  37. package/Executables/functions/adminstrator/render.js +0 -24
  38. package/Executables/functions/array_register.js +0 -161
  39. package/Executables/functions/assign.js +0 -19
  40. package/Executables/functions/display.js +0 -55
  41. package/Executables/functions/folder.js +0 -95
  42. package/Executables/functions/folder_register.js +0 -87
  43. package/Executables/functions/importcheck.js +0 -13
  44. package/Executables/functions/indices.js +0 -56
  45. package/Executables/functions/len.js +0 -22
  46. package/Executables/functions/methods/array.js +0 -272
  47. package/Executables/functions/methods/string.js +0 -197
  48. package/Executables/functions/methods/twain.js +0 -148
  49. package/Executables/functions/op.js +0 -15
  50. package/Executables/functions/price_register.js +0 -30
  51. package/Executables/functions/pricing.js +0 -26
  52. package/Executables/functions/servers/account.js +0 -81
  53. package/Executables/functions/servers/account_register.js +0 -56
  54. package/Executables/functions/servers/block.js +0 -21
  55. package/Executables/functions/servers/block_register.js +0 -18
  56. package/Executables/functions/servers/chain.js +0 -42
  57. package/Executables/functions/servers/chain_register.js +0 -28
  58. package/Executables/functions/set_error_catch.js +0 -34
  59. package/Executables/functions/string_register.js +0 -130
  60. package/Executables/functions/twain_register.js +0 -56
  61. package/Executables/functions/typecast.js +0 -43
  62. package/Executables/functions/utils.js +0 -9
  63. package/Executables/stack.js +0 -53
  64. package/Loader_sequence/main.js +0 -805
  65. package/Loader_sequence/repository.js +0 -33
  66. package/Objects/Explorer.js +0 -40
  67. package/Objects/Fee.js +0 -33
  68. package/Objects/Filesystem.js +0 -216
  69. package/Objects/Frame.js +0 -54
  70. package/Objects/Opcodes.js +0 -87
  71. package/Objects/Protocol.js +0 -5
  72. package/Trinity.js +0 -20
  73. package/callables.js +0 -172
  74. package/framer.js +0 -124
  75. package/opcodes/add.js +0 -15
  76. package/opcodes/indices.js +0 -82
  77. package/opcodes/jmp.js +0 -16
  78. package/opcodes/std.js +0 -12
  79. package/opcodes.js +0 -96
  80. package/readme.md +0 -133
  81. package/starter_scripts/constants.seq +0 -11
  82. package/tsconfig.json +0 -8
  83. package/types/Account.d.ts +0 -73
  84. package/types/Block.d.ts +0 -22
  85. package/types/Blockweb.d.ts +0 -14
  86. package/types/Chain.d.ts +0 -35
  87. package/types/Explorer.d.ts +0 -9
  88. package/types/Filesystem.d.ts +0 -23
  89. package/types/Frame.d.ts +0 -14
  90. package/types/Manager.d.ts +0 -21
  91. package/types/Opcodes.d.ts +0 -11
  92. package/types/Oracle.d.ts +0 -17
  93. package/types/Virtual_machine.d.ts +0 -20
  94. package/types/index.d.ts +0 -4
  95. package/utils/hash.js +0 -13
  96. package/utils/logger.js +0 -79
  97. package/utils/privacy.js +0 -22
  98. package/utils/type_coersion.js +0 -3
@@ -0,0 +1,11 @@
1
+ import Storage from "./functions/storage";
2
+
3
+ class Arr extends Storage {
4
+ constructor(value) {
5
+ super();
6
+
7
+ this.value = value;
8
+ }
9
+ }
10
+
11
+ export default Arr;
@@ -0,0 +1,11 @@
1
+ import Storage from "./functions/storage";
2
+
3
+ class Bool extends Storage {
4
+ constructor(value) {
5
+ super();
6
+
7
+ this.value = value;
8
+ }
9
+ }
10
+
11
+ export default Bool;
@@ -0,0 +1,11 @@
1
+ import Storage from "./functions/storage";
2
+
3
+ class Callable extends Storage {
4
+ constructor(value) {
5
+ super();
6
+
7
+ this.value = value;
8
+ }
9
+ }
10
+
11
+ export default Callable;
@@ -0,0 +1,5 @@
1
+ class Storage {
2
+ constructor() {}
3
+ }
4
+
5
+ export default Storage;
@@ -0,0 +1,11 @@
1
+ import Storage from "./functions/storage";
2
+
3
+ class Num extends Storage {
4
+ constructor(value) {
5
+ super();
6
+
7
+ this.value = value;
8
+ }
9
+ }
10
+
11
+ export default Num;
@@ -0,0 +1,11 @@
1
+ import Storage from "./functions/storage";
2
+
3
+ class Str extends Storage {
4
+ constructor(value) {
5
+ super();
6
+
7
+ this.value = value;
8
+ }
9
+ }
10
+
11
+ export default Str;
@@ -0,0 +1,11 @@
1
+ import Storage from "./functions/storage";
2
+
3
+ class Twa extends Storage {
4
+ constructor(value) {
5
+ super();
6
+
7
+ this.value = value;
8
+ }
9
+ }
10
+
11
+ export default Twa;
@@ -0,0 +1,11 @@
1
+ import Storage from "./functions/storage";
2
+
3
+ class Voi extends Storage {
4
+ constructor(value) {
5
+ super();
6
+
7
+ this.value = value;
8
+ }
9
+ }
10
+
11
+ export default Voi;
package/Index.js CHANGED
@@ -1,4 +1,38 @@
1
- import Trinity from "./Trinity";
1
+ import Trinity from "./Objects/Trinity";
2
2
 
3
+ let trinity = new Trinity();
3
4
 
4
- export default new Trinity();
5
+ const starter = async () => {
6
+ let manager = await trinity.add_manager("Arena_classic", {
7
+ server: {
8
+ port: 1408,
9
+ hostname: "127.0.0.1",
10
+ repo: true,
11
+ },
12
+ repositories: [
13
+ // {server}
14
+ ],
15
+ });
16
+
17
+ // let manager2 = await trinity.add_manager("Arena_classic", {
18
+ // server: {
19
+ // port: 1409,
20
+ // hostname: "127.0.0.1",
21
+ // repo: true,
22
+ // },
23
+ // sync_server: {
24
+ // port: 1408,
25
+ // hostname: "127.0.0.1",
26
+ // },
27
+ // repositories: [
28
+ // // {server}
29
+ // ],
30
+ // });
31
+
32
+ let account = await manager.add_account("lola");
33
+ // let account2 = await manager2.add_account("lola");
34
+ };
35
+
36
+ starter();
37
+
38
+ export default trinity;
@@ -1,348 +1,61 @@
1
-
2
- import Loader_sequence from "../Loader_sequence/main";
3
- import validate_signature from "../utils/privacy";
4
- import { post_request } from "../utils/services";
5
- import Filesystem from "./Filesystem";
1
+ import register from "../callables/register";
2
+ import Chain from "./Chain";
6
3
  import Virtual_machine from "./Virtual_machine";
7
4
 
8
- class Account extends Filesystem {
9
- constructor(name, meta = {}) {
10
- super();
11
-
12
- meta = meta || {};
13
-
5
+ class Account {
6
+ constructor(name, options) {
14
7
  this.name = name;
15
- this.private = meta.private;
16
- this.manager = meta.manager;
17
- this.account = this;
18
- this.stdin = new Array();
19
- this.stdout = new Array();
20
-
21
- this.log_output = this.manager.logger.store_log
22
-
23
- if (!this.manager) throw new Error("Manager instance missing.");
24
-
25
- this.name_hash();
26
- this.physical_address = `${this.base_address}/${this.name}`;
27
- this.set_paths(this);
28
-
29
- this.assembler = new Loader_sequence(this);
30
-
31
- this.chain = this.account_chain(this);
32
- this.vm = new Virtual_machine(this.chain);
33
-
34
- this.mine_buffer = {};
35
- this.privileges = new Object();
36
-
37
- this.events = new Object();
38
-
39
- this.log_output(`Account Instance: ${this.name}`);
40
- }
41
-
42
- on = (event, handler) => {
43
- let handlers = this.events[event];
44
- if (!handlers) {
45
- handlers = new Array();
46
- this.events[event] = handlers;
47
- }
48
- handlers.push(handler);
49
- };
50
-
51
- emit = (event, data) => {
52
- let handlers = this.events[event];
53
- Array.isArray(handlers) &&
54
- handlers.map((handle) => this.run_callback(handle, data));
55
- };
56
-
57
- propagate = (data, endpoint) => {
58
- if (data.is_propagated) return;
59
-
60
- let servers = this.privileges[endpoint];
61
-
62
- if (data.exclusive) {
63
- if (typeof data.exclusive === "boolean") return;
64
- else if (Array.isArray(data.exclusive)) {
65
- servers =
66
- servers &&
67
- servers.filter((serv) => {
68
- return data.exclusive.includes(serv.domain);
69
- });
70
- }
71
- }
72
-
73
- data.is_propagated = true;
74
- data = JSON.stringify(data);
75
-
76
- if (servers && servers.length) {
77
- servers.map((serv) => {
78
- post_request({
79
- options: {
80
- ...serv,
81
- path: `/${endpoint}`,
82
- },
83
- data,
84
- });
85
- });
86
- }
87
- };
88
-
89
- add_server = ({ server, privileges }) => {
90
- if (!Array.isArray(privileges) && privileges)
91
- privileges = ["load", "parse", "run", "create_account"];
92
-
93
- privileges.map((privilege) => {
94
- let priv = this.privileges[privilege];
95
- if (!priv) {
96
- priv = [];
97
- this.privileges[privilege] = priv;
98
- }
99
- if (!priv.find((serv) => serv.domain === server.domain))
100
- priv.push(server);
101
- });
102
- };
103
-
104
- get_account = (name) => {
105
- return this.manager.get_account(name) || this;
106
- };
107
-
108
- manage_buffer = (callback, real_cb) => {
109
- let call_session = `${Date.now()}-${Math.random()}`;
110
- this.mine_buffer[call_session] = { blocks: [], callback, real_cb };
111
-
112
- return call_session;
113
- };
114
-
115
- results = new Object()
116
-
117
- buff = (block, pid) => {
118
- if(block.ret){
119
- this.results[pid] = block.ret
120
- return;
121
- }
122
-
123
- let buffer = this.mine_buffer[pid];
124
- if (!buffer) return;
125
-
126
- block && block.stringify && buffer.blocks.push(block.stringify());
127
- };
128
-
129
- flush_buffer = (pid, payload) => {
130
- let buff = this.mine_buffer[pid];
131
- if (!buff) return;
132
-
133
- if (buff.callback){
134
- this.run_callback(buff.callback,{ payload, ret: this.results[pid] , blocks: buff.blocks});
135
- } else if(buff.real_cb){
136
- buff.real_cb(payload)
137
- }
138
-
139
- delete this.mine_buffer[pid];
140
- delete this.results[pid]
141
- };
142
-
143
- execute =( opcode, args)=>{
144
- let circ = this.vm.opcodes[opcode]
145
- if (typeof circ !== 'function') {return}
146
8
 
147
- circ(args)
148
- }
9
+ this.manager = options.manager;
10
+ this.repository = this.manager.repository;
149
11
 
150
- process_fee = ({fee, validator}, cb)=>{
151
- let content = this.vm.read_chain(fee, {tell_callable})
12
+ this.physical_address = `Accounts/${name}`;
152
13
 
153
- if (content.callable){
154
- this.vm.exec({executable: content.__address__, location:result=>{
155
- this.vm.exec({executable: validator, location: result=>{
156
- cb && cb(result)
157
- }, arguments: {argc:1, argv: [{position: 0, static_value: result}]}})
158
- } })
159
- }else {
160
- this.vm.exec({executable: validator, location: (result)=>{
161
- cb && cb(result)
162
- }, arguments: {argc:1, argv: [{position:0, address: fee}]}})
163
- }
14
+ this.chain = new Chain(this.physical_address, this);
164
15
  }
165
-
166
- load = (payload) => {
167
- let { program, callback, location } = payload;
168
- let { instructions, assemble, forge, spawn, unshift } = program;
169
-
170
- this.propagate(payload, "load");
171
-
172
- if(forge){
173
- let chain = this.vm.handle_chain(forge)
174
- chain.forge_block({metadata:{output:this.save(instructions)}})
175
- } else if (assemble) {
176
- this.assembler
177
- .spawn()
178
- .run(instructions, { cb: callback, location, options: assemble , unshift});
179
- } else {
180
- let pid = this.manage_buffer(location?res=>{
181
- this.vm.air_object(res, {location})
182
- } : callback,location&& callback);
183
-
184
- this.manager.push({ sequence: instructions, spawn, account: this, pid, unshift });
185
- }
186
-
187
- if(location && callback){
188
- callback({estimated_time:'-ms', callback:location})
189
- }
190
- };
191
16
 
192
- parse = (program) => {
193
- let { payload, callback, signature } = program;
17
+ run = async (payload) => {
18
+ let { physical_address, query } = payload;
194
19
 
195
- this.propagate(program, "parse");
20
+ let chain = await this.vm.handle_chain(physical_address);
21
+ let codes = await chain.read(query);
196
22
 
197
- this.manager.oracle.fetch({ ...payload, signature }, (result) =>
198
- this.run_callback(callback, result)
199
- );
23
+ await this.vm.execute(codes);
200
24
  };
201
25
 
202
- run = (request) => {
203
- let { payload, callback, location} = request;
204
-
205
- let { physical_address, query, history } = payload;
206
-
207
- history = Math.abs(Number(history)) || 0;
208
-
209
- this.propagate(request, "run");
210
-
211
- let pid = this.manage_buffer(location?res=>{
212
- this.vm.air_object(res, {location})
213
- } : callback,location&& callback);
214
-
215
- let context = physical_address
216
- ? this.manager.web.get(physical_address)
217
- : this.vm.get_context();
218
-
219
- if (!context) {
220
- if (physical_address)
221
- context = this.vm.handle_chain(physical_address);
222
- else return this.flush_buffer(pid);
223
- }
224
- if(!context)throw new Error()
225
-
226
- let blk = query ? context.explore(query) : context.get_latest_block();
227
-
228
- // console.log(context.stringify())
229
- // console.log(blk)
230
-
231
- if (!query) {
232
- let index = context.height;
233
- index -= 1;
234
-
235
- const historic = (blk) => {
236
- if (blk && blk.metadata.program) {
237
- if (history) {
238
- history--;
239
- blk = null;
240
- }
241
- } else blk = null;
242
-
243
- return blk;
244
- };
245
- blk = historic(blk);
26
+ load = async (payload) => {
27
+ let { sequence: codes, physical_address } = payload;
246
28
 
247
- while (!blk && index >= 0) {
248
- index--;
249
- blk = context.get_block(index);
29
+ for (let c = 0; c < codes.length; c++) {
30
+ let instruction = codes[c];
250
31
 
251
- blk = historic(blk);
252
- // console.log(blk)
253
- }
254
- }
255
-
256
- // console.log(blk)
257
-
258
- if (blk && blk.metadata && blk.metadata.program) {
259
- let program = this.read(blk.metadata.program);
260
-
261
- if (Array.isArray(program) && program.length) {
262
- this.vm.push_context(context);
263
- program = [...program, 'pop']
264
-
265
- // console.log(program)
266
-
267
- this.manager.push({
268
- sequence: program,
269
- account: this,
270
- payload,
271
- error_stack: JSON.stringify(this.vm.error_manager),
272
- pid,
32
+ if (["function", "class"].includes(instruction.type)) {
33
+ let addresses = await this.load({
34
+ ...instruction,
35
+ sequence: instruction.sequence,
36
+ physical_address: instruction.physical_address,
273
37
  });
38
+ instruction.sequence = addresses;
274
39
  }
275
- } else this.flush_buffer(pid,{error:true, error_message: "Program is not set!"});
276
-
277
- if(location && callback){
278
- callback({estimated_time:'-ms', callback:location})
279
- }
280
- };
281
-
282
- run_callback = (callback, payload) => {
283
- setTimeout(() => {
284
- if (!callback) return;
285
40
 
286
- if (typeof callback === "function") return callback(payload);
287
-
288
- callback.payload &&
289
- callback.payload.physical_address &&
290
- this.vm.stdin(payload, callback);
291
- }, 0);
292
- };
293
-
294
- flush_stdout = (block) => {
295
- if (
296
- block.chain.physical_address === `${this.physical_address}/Opcodes/stdout`
297
- )
298
- return;
299
-
300
- for (let s = 0; s < this.stdout.length; s++) {
301
- let out = this.stdout[s];
302
- if (out.pid === this.vm.track.pid) {
303
- block.metadata.stdout.push(out.data);
304
- this.stdout[s] = null;
305
- }
41
+ let chain = await this.vm.handle_chain(instruction.physical_address);
42
+ let block = await chain.write(instruction);
43
+ codes[c] = block.address;
306
44
  }
307
- this.stdout = this.stdout.filter((out) => !!out);
308
- };
45
+ let chain = await this.vm.handle_chain(physical_address);
46
+ await chain.write({ ...payload, sequence: codes });
309
47
 
310
- validate = (payload, signature, callback) => {
311
- if (!this.private) return true;
312
-
313
- let valid = validate_signature(
314
- this.name,
315
- JSON.stringify(payload),
316
- signature
317
- );
318
- if (!valid && callback)
319
- this.run_callback(callback, {
320
- private: this.private,
321
- error: true,
322
- error_message: "Invalid signature",
323
- });
324
-
325
- return valid;
48
+ return codes;
326
49
  };
327
50
 
328
- stringify = (str) => {
329
- let obj = {};
330
-
331
- obj.name = this.name;
332
- obj.hash = this.hash;
333
- obj.path = this.path;
334
- obj.private = this.private;
335
- obj.chain = this.chain.stringify();
336
- obj.physical_address = this.physical_address;
337
-
338
- return str ? JSON.stringify(obj) : obj;
339
- };
51
+ sync = async () => {
52
+ this.servers = new Array();
53
+ this.vm = new Virtual_machine(this);
340
54
 
341
- create_account = (payload) => {
342
- this.propagate(payload, "create_account");
343
- let { name, meta } = payload;
55
+ await this.chain.sync();
56
+ await this.vm.sync();
344
57
 
345
- return this.manager.add_account(name, meta);
58
+ await register(this);
346
59
  };
347
60
  }
348
61
 
package/Objects/Block.js CHANGED
@@ -1,90 +1,17 @@
1
- import { hash } from "../utils/hash";
2
- import { _id } from "generalised-datastore/utils/functions";
3
-
4
1
  class Block {
5
- constructor(chain) {
2
+ constructor(meta, chain) {
3
+ this.content = meta.content;
6
4
  this.chain = chain;
7
- this.data = this.chain.txs;
8
- this.metadata = {};
9
- this.children = new Array();
10
- this.index = this.chain.height;
11
- this._id = _id(this.chain.hash);
12
- this.previous_hash = this.chain.recent_block && this.chain.recent_block._id
5
+ this.index = chain.blocks.length;
13
6
  }
14
7
 
15
- generate_hash = () => {
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];
22
- if (!content) return;
23
-
24
- if (this.data.length<=1 && this.chain.account.is_datatype(this.chain)){
25
- content = this.chain.account.stringify_type(this.chain)
26
- }else {
27
- let cursors = Object.keys(content).filter(
28
- (c) => c.startsWith("{") && c.endsWith("}")
29
- );
30
-
31
- for (let c = 0; c < cursors.length; c++) {
32
- let curs = cursors[c];
33
-
34
- this.metadata[curs.slice(1, -1)] = content[curs];
35
- delete content[curs];
36
- }
37
- }
38
-
39
-
40
- this.metadata.stdout = new Array();
41
- this.chain.account.flush_stdout(this);
8
+ sync = async () => {
9
+ this.address = `${this.chain.physical_address}:${this.index}`;
42
10
 
43
- if(!this.chain.datapath){
44
- let datapath = this.chain.account.save(content, this.chain);
45
- this.datapath = datapath
46
- }else {
47
- this.chain.account.save(content)
48
- this.datapath = this.chain.datapath
49
- }
11
+ await this.generate_hash();
50
12
  };
51
13
 
52
- stringify = (str) => {
53
- let obj = {};
54
-
55
- obj.metadata = this.metadata;
56
- obj.datapath = this.datapath;
57
- obj.timelapse = this.timelapse;
58
- obj.index = this.index;
59
- obj.hash = this.hash;
60
- obj.previous_hash = this.previous_hash;
61
- obj.data = this.data;
62
- obj._id = this._id;
63
- obj.children = this.children.map((ch) => ch && ch._id);
64
- obj.chain = {
65
- hash: this.chain.hash,
66
- physical_address: this.chain.physical_address,
67
- };
68
-
69
- return str ? JSON.stringify(obj) : obj;
70
- };
71
-
72
- static build = (data, chain) => {
73
- let blck = new Block(chain);
74
- blck.chain = chain;
75
- blck.metadata = data.metadata;
76
- blck.datapath = data.datapath;
77
- blck.timelapse = data.timelapse;
78
- blck.index = data.index;
79
- blck.previous_hash = data.previous_hash;
80
- blck.hash = data.hash;
81
- blck.data = data.data;
82
- blck.children = data.children || [];
83
-
84
- blck._id = data._id;
85
-
86
- return blck;
87
- };
14
+ generate_hash = async () => {};
88
15
  }
89
16
 
90
17
  export default Block;
@@ -1,40 +1,33 @@
1
1
  import Chain from "./Chain";
2
2
 
3
3
  class Blockweb {
4
- constructor(mgr) {
5
- this.mgr = mgr;
6
- this.physical_addresses = new Object();
4
+ constructor(manager) {
5
+ this.manager = manager;
6
+
7
7
  this.chains = new Object();
8
+ this.listeners = new Object();
8
9
  }
9
10
 
10
- get = (addr) => {
11
- let hash = this.physical_addresses[addr];
12
-
13
- let chain = this.chains[hash];
14
-
15
- return chain;
16
- };
17
-
18
- split_set = (physical_address) => {
19
- let spli = physical_address.split("/");
20
-
21
- let chain = this.get(physical_address);
22
- if (!chain && spli.length >1) {
23
- chain = this.set(spli.slice(0, -1).join("/"), spli.slice(-1)[0]);
11
+ listen = async (physical_address, config) => {
12
+ let ls = this.listeners[physical_address];
13
+ if (!ls) {
14
+ ls = new Array();
15
+ this.listeners[physical_address] = ls;
24
16
  }
25
- return chain;
17
+ ls.push(config.server);
26
18
  };
27
19
 
28
- set = (parent, name) => {
29
- if (typeof parent === "string") {
30
- parent = this.get(parent) || this.split_set(parent);
31
- }
20
+ spli_get = async (address, account) => {
21
+ return this.get(address) || (await this.set(address, account));
22
+ };
32
23
 
33
- let chain = new Chain(parent, name);
34
- this.chains[chain.hash] = chain;
24
+ get = (address) => {
25
+ return this.chains[address];
26
+ };
35
27
 
36
- this.physical_addresses[chain.physical_address] = chain.hash;
37
- this.chains[chain.hash] = chain;
28
+ set = async (address, account) => {
29
+ let chain = new Chain(address, account);
30
+ await chain.sync();
38
31
 
39
32
  return chain;
40
33
  };