godprotocol 1.0.838 → 1.0.840

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/Index.js CHANGED
@@ -8,16 +8,44 @@ import create_server from "./utils/create_server";
8
8
  // initiator.assembler.run(
9
9
  // `@/datastore/main
10
10
 
11
- // @/datastore/main/grey
12
- // >matter 'lola'
13
- // ;
11
+ // >object
12
+ // >keys []
13
+ // >entries {}
14
+ // >size 0
14
15
 
15
- // >storage {}
16
+ // ./set
17
+ // >key
18
+ // >key_static getter key "static_value"
19
+ // >value
20
+ // >exists getter ../entries key
21
+ // jmp_not_void :proceed
22
+ // >../size add ../size 1
23
+ // >../keys setter ../keys -1 key
24
+
25
+ // :proceed
26
+ // >../entries setter ../entries key_static value
27
+ // ;
28
+
29
+ // ./get
30
+ // >key
31
+ // >value getter ../entries key
32
+ // ;
33
+
34
+ // ./remove
35
+ // >key
36
+ // >../entries delete ../entries key
37
+ // >../keys delete ../keys key
38
+ // >../size sub ../size 1
39
+ // ;
40
+
41
+ // ./get_keys
42
+ // >output ../keys
43
+ // ;
16
44
 
17
45
  // ;`,
18
46
  // {
19
47
  // cb: (blks) => {
20
- // console.log(!!blks, "did");
48
+ // console.log(blks, blks.length, "did");
21
49
  // },
22
50
  // }
23
51
  // ),
@@ -65,6 +65,7 @@ class Loader {
65
65
  while (pos < line.length) {
66
66
  let char = line[pos].trim();
67
67
 
68
+ console.log(char);
68
69
  if (char === stop_char) return { tokens, pos };
69
70
 
70
71
  if (!char) {
@@ -76,7 +77,7 @@ class Loader {
76
77
  if (char === "\n") {
77
78
  line_number++;
78
79
  pos++;
79
- } else if (char === "@") {
80
+ } else if (char === "@" || char === ".") {
80
81
  let acc = "";
81
82
  while (line[pos] && line[pos].trim()) {
82
83
  acc += line[pos];
@@ -110,7 +111,7 @@ class Loader {
110
111
  }
111
112
  pos++;
112
113
  push_token(acc, "string");
113
- } else if (num_pattern.test(char)) {
114
+ } else if (num_pattern.test(char) || char === "-") {
114
115
  let acc = char;
115
116
  pos++;
116
117
  while (
@@ -281,6 +282,8 @@ class Loader {
281
282
  ]);
282
283
 
283
284
  tokens.slice(1).map((tok, i) => {
285
+ if (tok.type === "address") tok.value = this.resolve_addr(tok.value);
286
+
284
287
  if (tok.type === "address" && tok.value.match(this.marker_pattern)) {
285
288
  this.push_instruction([
286
289
  `link ${this.account.physical_address}/Datatypes/Number`,
@@ -470,6 +473,10 @@ class Loader {
470
473
  obj[index] = line.slice(1).join(":").trim();
471
474
  };
472
475
 
476
+ spawn = () => {
477
+ return new Loader(this.account);
478
+ };
479
+
473
480
  compile = (codes) => {
474
481
  let code_array = codes.split("\n");
475
482
 
@@ -494,7 +501,8 @@ class Loader {
494
501
  if (line === ";") this.pop();
495
502
  else if (this.is_routine) this.parse_routine(line);
496
503
  else if (line.startsWith("//")) this.parse_comment(line.slice(2).trim());
497
- else if (line.startsWith(">@")) this.parse_assignment(line, true);
504
+ else if (line.startsWith(">@") || line.startsWith(">."))
505
+ this.parse_assignment(line, true);
498
506
  else if (line.startsWith(">")) this.parse_assignment(line);
499
507
  else this.parse_opcode(line);
500
508
 
@@ -534,6 +542,8 @@ class Loader {
534
542
  callback: cb,
535
543
  });
536
544
 
545
+ this.program_configs[0].main = this.repository.oracle.hash(codes);
546
+ console.log(this.program_configs);
537
547
  this.program_configs.map((config) => this.repository.add_program(config));
538
548
 
539
549
  this.program_configs = [];
@@ -8,11 +8,12 @@ class Repository {
8
8
  }
9
9
 
10
10
  add_program = (config) => {
11
- let code_hash = this.oracle.hash(config.codes);
11
+ let codes = config.codes.filter((line) => !!line.trim());
12
+ let code_hash = this.oracle.hash(codes);
12
13
  let code_exist = this.codes.readone({ hash: code_hash });
13
14
 
14
15
  let code = this.codes.write({
15
- body: config.codes,
16
+ body: codes,
16
17
  hash: code_hash,
17
18
  _id: code_exist && code_exist._id,
18
19
  });
@@ -131,7 +131,7 @@ class Account extends Filesystem {
131
131
  this.propagate(payload, "load");
132
132
 
133
133
  if (assemble) {
134
- this.assembler.run(instructions, { cb: callback });
134
+ this.assembler.spawn().run(instructions, { cb: callback });
135
135
  } else {
136
136
  let pid = this.manage_buffer(callback);
137
137
 
package/Objects/Block.js CHANGED
@@ -52,6 +52,7 @@ class Block {
52
52
  obj.timelapse = this.timelapse;
53
53
  obj.index = this.index;
54
54
  obj.hash = this.hash;
55
+ obj.previous_hash = this.previous_hash;
55
56
  obj.data = this.data;
56
57
  obj._id = this._id;
57
58
  obj.children = this.children.map((ch) => ch._id);
package/Objects/Chain.js CHANGED
@@ -122,6 +122,8 @@ class Chain extends Explorer {
122
122
  };
123
123
 
124
124
  add_block = (block) => {
125
+ let recent_blk = this.get_latest_block();
126
+ block.previous_hash = recent_blk && recent_blk._id;
125
127
  this.blocks.push(block);
126
128
  this.height = this.blocks.length;
127
129
  };
@@ -15,7 +15,10 @@ class Manager {
15
15
  this.running = 0;
16
16
  this.tracks = new Object();
17
17
  this.web = new Blockweb(this);
18
- this.oracle = new Oracle(this, { compression: this.compression });
18
+ this.oracle = new Oracle(this, {
19
+ compression: this.compression,
20
+ datastore: meta.datastore,
21
+ });
19
22
  this.servers = new Array();
20
23
  }
21
24
 
package/Objects/Oracle.js CHANGED
@@ -10,7 +10,9 @@ class Oracle {
10
10
  this.fs = fs;
11
11
  this.mgr = mgr;
12
12
  this.datapaths = new Object();
13
- this.gds = new GDS(process.env.DATASTORE || "godprotocol").sync({
13
+ this.gds = new GDS(
14
+ meta.datastore || process.env.DATASTORE || "godprotocol"
15
+ ).sync({
14
16
  manager: this.mgr,
15
17
  });
16
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "godprotocol",
3
- "version": "1.0.838",
3
+ "version": "1.0.840",
4
4
  "description": "A data mediator.",
5
5
  "main": "Index.js",
6
6
  "types": "types/index.d.ts",
@@ -90,7 +90,7 @@ const create_server = async (app, settings) => {
90
90
 
91
91
  server.listen(port, () => {
92
92
  console.log(`\n...GOD PROTOCOL RUNNING :${port}`);
93
- manager.add_server({ ...settings.server_details, port: PORT });
93
+ settings.manager.add_server({ ...settings.server_details, port: PORT });
94
94
  });
95
95
  };
96
96