godprotocol 1.0.842 → 1.1.0

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 (64) hide show
  1. package/Executables/callables.js +131 -0
  2. package/Executables/executables.js +230 -0
  3. package/Executables/functions/adminstrator/adm_register.js +29 -0
  4. package/Executables/functions/adminstrator/native_components.js +10 -0
  5. package/Executables/functions/adminstrator/query_selectors.js +10 -0
  6. package/Executables/functions/adminstrator/render.js +24 -0
  7. package/Executables/functions/array_register.js +161 -0
  8. package/Executables/functions/assign.js +19 -0
  9. package/Executables/functions/display.js +55 -0
  10. package/Executables/functions/folder.js +95 -0
  11. package/Executables/functions/folder_register.js +87 -0
  12. package/Executables/functions/importcheck.js +13 -0
  13. package/Executables/functions/indices.js +56 -0
  14. package/Executables/functions/len.js +22 -0
  15. package/Executables/functions/methods/array.js +272 -0
  16. package/Executables/functions/methods/string.js +197 -0
  17. package/Executables/functions/methods/twain.js +148 -0
  18. package/Executables/functions/op.js +15 -0
  19. package/Executables/functions/price_register.js +30 -0
  20. package/Executables/functions/pricing.js +26 -0
  21. package/Executables/functions/servers/account.js +81 -0
  22. package/Executables/functions/servers/account_register.js +56 -0
  23. package/Executables/functions/servers/block.js +21 -0
  24. package/Executables/functions/servers/block_register.js +18 -0
  25. package/Executables/functions/servers/chain.js +42 -0
  26. package/Executables/functions/servers/chain_register.js +28 -0
  27. package/Executables/functions/set_error_catch.js +34 -0
  28. package/Executables/functions/string_register.js +130 -0
  29. package/Executables/functions/twain_register.js +56 -0
  30. package/Executables/functions/typecast.js +43 -0
  31. package/Executables/functions/utils.js +9 -0
  32. package/Executables/stack.js +53 -0
  33. package/Index.js +2 -55
  34. package/Loader_sequence/main.js +371 -124
  35. package/Loader_sequence/repository.js +1 -1
  36. package/Objects/Account.js +101 -34
  37. package/Objects/Block.js +24 -18
  38. package/Objects/Blockweb.js +1 -1
  39. package/Objects/Chain.js +127 -29
  40. package/Objects/Explorer.js +3 -17
  41. package/Objects/Fee.js +33 -0
  42. package/Objects/Filesystem.js +98 -25
  43. package/Objects/Frame.js +10 -3
  44. package/Objects/Manager.js +193 -23
  45. package/Objects/Opcodes.js +48 -10
  46. package/Objects/Oracle.js +11 -8
  47. package/Objects/Protocol.js +5 -0
  48. package/Objects/Virtual_machine.js +130 -59
  49. package/Trinity.js +20 -0
  50. package/callables.js +172 -0
  51. package/framer.js +65 -12
  52. package/opcodes/add.js +6 -1
  53. package/opcodes/indices.js +60 -6
  54. package/opcodes/jmp.js +2 -0
  55. package/opcodes/std.js +5 -2
  56. package/opcodes.js +56 -18
  57. package/package.json +2 -2
  58. package/starter_scripts/constants.seq +11 -0
  59. package/utils/create_server.js +15 -7
  60. package/utils/hash.js +2 -2
  61. package/utils/logger.js +79 -0
  62. package/utils/services.js +5 -3
  63. package/utils/type_coersion.js +3 -0
  64. package/utils/vm_utils.js +292 -0
@@ -7,17 +7,19 @@ class Filesystem {
7
7
  }
8
8
 
9
9
  parse_path = (path) => {
10
- if (!path || (path && !path.includes("/"))) return path;
10
+ if (!path || (typeof path === 'string' && (!path.includes("/") || path.includes(' ')))) return path;
11
11
 
12
12
  return this.read(path);
13
13
  };
14
14
 
15
15
  read = (datapath) => {
16
16
  if (!datapath) return null;
17
-
17
+
18
18
  let type_folder = this.account.manager.oracle.get(datapath);
19
19
 
20
- if (!type_folder) return datapath;
20
+ if (!type_folder){
21
+ return datapath;
22
+ }
21
23
 
22
24
  let content;
23
25
  if (type_folder.type === "twain") {
@@ -37,35 +39,78 @@ class Filesystem {
37
39
  return content;
38
40
  };
39
41
 
40
- save = (content, chain, just_obj) => {
41
- let addr, obj;
42
+ object_type = (obj, chain)=>{
43
+ let type = typeof obj
44
+ if (type === 'object'){
45
+ if (Array.isArray(obj)) type = 'array'
46
+ else if (!obj) type = 'void'
47
+ else type = 'twain'
48
+ }
42
49
 
43
- let type = typeof chain === "string" ? chain : this.get_type(chain);
50
+ if (!chain)return type;
44
51
 
45
- if (type === "array" || type === "string") {
46
- obj = [];
52
+ type = `${type[0].toUpperCase()}${type.slice(1)}`
53
+
54
+ return this.get_datatype_chain(type)
55
+ }
47
56
 
48
- for (let curs in content)
49
- obj.splice(Number(curs) || -1, 0, content[curs]);
57
+ get_datatype_chain = (type)=>{
58
+ let chain = this.vm.handle_chain(`${this.account.physical_address}/Datatypes/${type}`)
50
59
 
51
- if (type === "string") obj = obj.join(" ");
52
- } else if (type === "twain") {
53
- obj = {};
54
- for (let curs in content) {
55
- obj[curs] = content[curs];
56
- }
57
- } else if (type === "number") {
58
- obj = Number(content["-1"]);
59
- if (isNaN(obj)) obj = -1;
60
- } else {
61
- obj = null;
60
+ return chain
61
+ }
62
+
63
+ save = (content, chain, options) => {
64
+ let just_obj, pure;
65
+ if (typeof options !== 'object'){
66
+ just_obj = options
67
+ }else if(options) {
68
+ just_obj = options.just_obj
69
+ pure = options.pure
70
+ }
71
+ let addr, obj;
72
+
73
+ if (!chain){
74
+ chain = this.object_type(content, true)
62
75
  }
63
76
 
77
+ let type = typeof chain === "string" ? chain : this.get_type(chain);
78
+
79
+
80
+ if(!pure){
81
+ if(typeof content==='string'){
82
+ if(type!=="string")obj= JSON.parse(content)
83
+ else obj = content
84
+ } else{
85
+ if (type === "array" || type === "string") {
86
+ obj = [];
87
+
88
+ for (let curs in content)
89
+ obj.splice(Number(curs) || -1, 0, content[curs]);
90
+
91
+ if (type === "string") obj = obj.join(" ");
92
+ } else if (type === "twain") {
93
+ obj = {};
94
+ for (let curs in content) {
95
+ obj[curs] = content[curs];
96
+ }
97
+ } else if (type === "number") {
98
+ obj = Number(content["-1"]);
99
+ if (isNaN(obj)) obj = 0;
100
+ }else if (type === 'boolean'){
101
+ obj = content['-1']
102
+ obj = obj === 'True' ? true:false
103
+ } else {
104
+ obj = null;
105
+ }
106
+ }
107
+ }else obj = content
108
+
64
109
  if (just_obj) return obj;
65
110
 
66
111
  addr = `${chain.path}/${hash(JSON.stringify(obj))}`;
67
112
  this;
68
- if (obj != null) this.manager.oracle.write(addr, obj);
113
+ if (obj != null || type === 'void') this.manager.oracle.write(addr, obj);
69
114
 
70
115
  this.manager.oracle.set(addr, { obj, type });
71
116
 
@@ -93,13 +138,41 @@ class Filesystem {
93
138
  }
94
139
  };
95
140
 
141
+ is_datatype=chain=>{
142
+
143
+ let type = this.get_type(chain);
144
+ return !!type
145
+ }
146
+
147
+ stringify_type = (type)=>{
148
+ let val;
149
+ switch(type){
150
+ case 'string':
151
+ val = ""
152
+ break;
153
+ case 'number':
154
+ val = "0"
155
+ break;
156
+ case 'array':
157
+ val = "[]"
158
+ break;
159
+ case 'twain':
160
+ val = "{}"
161
+ break;
162
+ case 'void':
163
+ val = 'null'
164
+ break
165
+ ;
166
+ }
167
+ return val
168
+ }
169
+
96
170
  write = (arg, context) => {
97
171
  let content = context.get_buffer();
98
172
 
99
173
  if (!content || !arg) return;
100
174
 
101
175
  content[context.cursor] = arg;
102
- // console.log(`Writing: ${arg}`);
103
176
  };
104
177
 
105
178
  name_hash = () => {
@@ -117,8 +190,8 @@ class Filesystem {
117
190
 
118
191
  let fs = this.manager.oracle.fs;
119
192
 
120
- if (!fs.existsSync(`${this.root}/${chain.path}`)) {
121
- fs.mkdirSync(`${this.root}/${chain.path}`, { recursive: true });
193
+ if (!fs.existsSync(`${this.manager.root}/${chain.path}`)) {
194
+ fs.mkdirSync(`${this.manager.root}/${chain.path}`, { recursive: true });
122
195
  }
123
196
  };
124
197
 
package/Objects/Frame.js CHANGED
@@ -8,15 +8,14 @@ class Frame {
8
8
  ? array_to_nested_objects(object)
9
9
  : object;
10
10
 
11
- this.children = new Array();
12
11
  this.instructions = new Array();
13
12
  }
14
13
 
15
14
  frame = (object) => {
16
15
  let frame = new Frame(object, this);
16
+ frame.account = this.account;
17
17
 
18
18
  this.instructions.push(frame);
19
- this.children.push(frame);
20
19
 
21
20
  return frame;
22
21
  };
@@ -26,7 +25,14 @@ class Frame {
26
25
  let val = this.object[prop];
27
26
  this.instructions.push(`chain ${prop}`);
28
27
 
29
- val && this.frame(val).to_instruction();
28
+ if(val && val.__type){
29
+ let instructions = this.account.assembler.run(JSON.stringify(val.value), {instructions: true, pure: true})
30
+
31
+ this.instructions.push(...instructions)
32
+
33
+ this.instructions.push(`cursor {output}`)
34
+ this.instructions.push(`write {datapath:-1}`)
35
+ }else val && this.frame(val).to_instruction();
30
36
 
31
37
  this.instructions.push(`pop ${prop}`);
32
38
  }
@@ -40,6 +46,7 @@ class Frame {
40
46
  if (ins instanceof Frame) inss.push(...ins.flatten_instructions());
41
47
  else inss.push(ins);
42
48
  }
49
+
43
50
  return inss;
44
51
  };
45
52
  }
@@ -4,22 +4,31 @@ import opcodes from "../opcodes";
4
4
  import Account from "./Account";
5
5
  import Blockweb from "./Blockweb";
6
6
  import Oracle from "./Oracle";
7
+ import Logger from "../utils/logger";
8
+ import Protocol from "godprotocol/Objects/Protocol";
7
9
 
8
- class Manager {
10
+
11
+ class Manager extends Protocol{
9
12
  constructor(meta) {
13
+ super()
14
+
10
15
  meta = meta || {};
11
16
 
12
17
  this.compression = meta.compression;
18
+ this.frequency = meta.frequency
13
19
  this.manager_id = _id("manager");
14
20
  this.accounts = new Object();
15
21
  this.running = 0;
16
- this.tracks = new Object();
22
+ this.logger = new Logger()
23
+ this.root = meta.root || __dirname;
24
+ this.accounts_et_programs = new Object();
17
25
  this.web = new Blockweb(this);
18
26
  this.oracle = new Oracle(this, {
19
27
  compression: this.compression,
20
28
  datastore: meta.datastore,
21
29
  });
22
30
  this.servers = new Array();
31
+ this.init_name = meta.initiator|| process.env.INITIATOR || "initiator"
23
32
  }
24
33
 
25
34
  stringify = (str) => {
@@ -33,40 +42,119 @@ class Manager {
33
42
 
34
43
  initiate = (meta) => {
35
44
  this.initiator = this.add_account(
36
- process.env.INITIATOR || "initiator",
45
+ this.init_name,
37
46
  meta
38
47
  );
39
48
 
40
49
  return this.initiator;
41
50
  };
42
51
 
52
+ set_track = ({account, physical_address, pointer}, slice)=>{
53
+ let payload = this.accounts_et_programs[account], t, track;
54
+
55
+ for(t= payload.tracks.length-1; t>=0; t--){
56
+ let trck = payload.tracks[t]
57
+ if (trck.payload.physical_address === physical_address){
58
+ track = trck
59
+ break
60
+ }
61
+ }
62
+
63
+ if(slice && track){
64
+ payload.tracks.splice(t+1)
65
+ }
66
+ if(pointer != null){
67
+ track.pointer = pointer;
68
+ }
69
+
70
+ return track
71
+ }
72
+
73
+ state_logger = ()=>{
74
+ let lines=0
75
+ for (let account in this.accounts_et_programs){
76
+ let payload = this.accounts_et_programs[account];
77
+ let tracks = payload.tracks
78
+
79
+ console.log(`(${payload.clocks}) Account: ${account} [tracks(${tracks.length})]`)
80
+
81
+ let curr_track = tracks.slice(-1)[0]
82
+ let pointer = curr_track.pointer
83
+ let instruction = curr_track.sequence[pointer]
84
+
85
+ console.log(`>(${curr_track.clocks}) Track [${pointer} / ${curr_track.sequence.length}] - executing '${instruction}'`)
86
+ lines+=2
87
+ }
88
+ return lines
89
+ }
90
+
91
+ finish_state = ()=>{
92
+ console.log(`All programs finished execution`)
93
+ }
94
+
43
95
  start_clock = () => {
44
- let frequency = Number(process.env.HERTS) || 10;
96
+ let frequency = Number(this.frequency)|| Number(process.env.HERTS) || 10;
45
97
  this.clock = setInterval(() => {
46
- for (let account in this.tracks) {
47
- let track = this.tracks[account];
48
- let program = track.slice(-1)[0];
98
+
99
+ for (let account in this.accounts_et_programs) {
100
+ let payload = this.accounts_et_programs[account], spawn, tracks;
49
101
 
102
+ if(payload.spawn_list.length){
103
+ if(payload.spawn_cursor == undefined){
104
+ payload.spawn_cursor = 0
105
+ tracks = payload.tracks;
106
+ }else {
107
+ spawn = payload.spawn_list[payload.spawn_cursor]
108
+ tracks = payload.spawns[spawn];
109
+ payload.spawn_cursor ++
110
+ }
111
+ }else {
112
+ tracks = payload.tracks;
113
+ }
114
+
115
+ let program = tracks.slice(-1)[0];
116
+
117
+ payload.clocks ++
50
118
  if (program.hold) continue;
51
119
 
52
120
  let instruction = program.sequence[program.pointer];
121
+ program.clocks++
53
122
 
54
- program.account.vm.execute(instruction, program);
55
123
  program.pointer++;
56
-
57
- if (program.pointer === program.sequence.length) {
124
+ program.account.vm.execute(instruction, program);
125
+ program = program.account.vm.track;
126
+
127
+ if (program.pointer >= program.sequence.length) {
58
128
  program.account.flush_buffer(program.pid);
59
129
 
60
- track.pop();
130
+ if (program.error_stack)
131
+ program.account.vm.error_manager = JSON.parse(program.error_stack)
132
+ tracks.pop();
133
+
134
+ if(spawn){
135
+ if (payload.spawn_cursor >= payload.spawn_list.length){
136
+ payload.spawn_cursor = undefined
137
+ }
138
+ }
61
139
  }
62
- if (!track.length) {
63
- this.running -= 1;
64
- delete this.tracks[account];
65
- program.account.chain.mine(program.account.vm);
140
+ if (!tracks.length) {
141
+ if (spawn){
142
+ delete payload.spawns[spawn]
143
+ payload.spawn_list = payload.spawn_list.filter(s=>s!==spawn)
144
+ }else {
145
+ this.running -= 1;
146
+ delete this.accounts_et_programs[account];
147
+ program.account.chain.mine(program.account.vm);
148
+ }
149
+
66
150
  }
67
151
  }
68
152
 
69
- !this.running && clearInterval(this.clock);
153
+ this.logger.log(this.state_logger)
154
+ if (!this.running){
155
+ clearInterval(this.clock)
156
+ this. finish_state(this.finish_state)
157
+ }
70
158
  }, frequency);
71
159
  };
72
160
 
@@ -99,13 +187,35 @@ class Manager {
99
187
  };
100
188
 
101
189
  push = (program) => {
102
- let track = this.tracks[program.account.name];
190
+ let account = this.accounts_et_programs[program.account.name];
191
+ let tracks ;
103
192
 
104
- if (track) {
105
- track.push({ ...program, pointer: 0 });
193
+ if (account) {
194
+ if (program.spawn) {
195
+ tracks = account.spawns[program.spawn]
196
+ if (!tracks) {
197
+ tracks = []
198
+ account.spawns[program.spawn] = tracks;
199
+ }
200
+ account.spawn_list.push(program.spawn)
201
+ }else tracks= account.tracks
202
+ if(program.unshift){
203
+ delete program.unshift
204
+ tracks.unshift({ ...program, pointer: 0, clocks:0 });
205
+ } else tracks.push({ ...program, pointer: 0, clocks:0 });
106
206
  } else {
107
- track = [{ ...program, pointer: 0 }];
108
- this.tracks[program.account.name] = track;
207
+ tracks = [{ ...program, pointer: 0, clocks:0 }];
208
+ account = {
209
+ clocks:0,
210
+ spawns: {},
211
+ spawn_list: []
212
+ }
213
+ if (program.spawn){
214
+ account.spawns[program.spawn] = tracks
215
+ account.spawn_list.push(program.spawn)
216
+ }else account.tracks = tracks;
217
+
218
+ this.accounts_et_programs[program.account.name] = account;
109
219
 
110
220
  this.running++;
111
221
  this.running === 1 && this.start_clock();
@@ -116,14 +226,14 @@ class Manager {
116
226
 
117
227
  endpoint = (endpoint, payload, callback) => {
118
228
  let account = this.get_account(payload.account);
119
- if (!account) {
229
+ if (!account && payload.account) {
120
230
  return this.get_initiator().run_callback(callback, {
121
231
  error: true,
122
232
  error_message: "Account is not found",
123
233
  payload,
124
234
  endpoint,
125
235
  });
126
- }
236
+ }else account = this.get_initiator()
127
237
 
128
238
  if (
129
239
  !account.validate(
@@ -141,6 +251,66 @@ class Manager {
141
251
  add_server = (server) => {
142
252
  this.servers.push(server);
143
253
  };
254
+
255
+ prepare_query = query=>{
256
+ query = query.split('&');
257
+ let obj = {}
258
+ for (let q=0; q< query.length; q++){
259
+ let [prop, value] = query[q].split('=')
260
+
261
+ if (prop === 'executable'){
262
+ obj.executable = value;
263
+ }else if (prop.startsWith('arguments')){
264
+ if (!obj.arguments) obj.arguments = {argv: []}
265
+ if (prop.includes('.')){
266
+ prop = prop.split('.')
267
+ if (prop[2] ==='$'){
268
+ try{
269
+ value = JSON.parse(value)
270
+ }catch(e){}
271
+ }
272
+ obj.arguments.argv.push({name: prop[1], [prop[2]==='$'?'static_value':'address']: value})
273
+ } else {
274
+ obj.arguments.argv.push({address:value, position: obj.arguments.argv.length})
275
+ }
276
+ obj.arguments.argc = obj.arguments.argv.length
277
+ }else if (prop === 'location'){
278
+ obj.location = value;
279
+ }else if (prop === 'metadata'){
280
+ try {
281
+ obj.metadata = JSON.parse(value);
282
+ } catch (e) {}
283
+ }
284
+ }
285
+
286
+ return obj;
287
+ }
288
+
289
+ handle_route = ({req,res, data})=>{
290
+ let url = req.url;
291
+ let split = url.split('?')
292
+ let query = split[1]
293
+
294
+ let payload = data || this.prepare_query(query);
295
+ url = split[0].split('/').filter(a=>!!a)
296
+
297
+ if (url.length> 2){}
298
+
299
+ let account = this.get_account(data && data.account || url[1]);
300
+ if(!account){
301
+ return res.end(JSON.stringify({error:true, error_message:"Account is not found!"}))
302
+ }
303
+
304
+ if (['display', 'read_chain'].includes(payload.executable )){
305
+ if (!payload.metadata)payload.metadata = {}
306
+ payload.metadata.raw = true;
307
+ }
308
+
309
+ let response = account.vm.exec(payload)
310
+
311
+ res.writeHead(200, { "Content-Type": "application/json" });
312
+ res.end(JSON.stringify(response))
313
+ }
144
314
  }
145
315
 
146
316
  export default Manager;
@@ -1,7 +1,10 @@
1
+ import Vm_utils from "../utils/vm_utils";
1
2
  import { obj } from "../framer";
2
3
 
3
- class Opcodes {
4
+ class Opcodes extends Vm_utils {
4
5
  constructor() {
6
+ super()
7
+
5
8
  this.opcodes = new Object();
6
9
  }
7
10
 
@@ -23,26 +26,61 @@ class Opcodes {
23
26
  context.account.read(buf && buf.inputs) ||
24
27
  this.account.stdin.splice(-1)[0];
25
28
 
26
- let res = circ(args, this);
29
+ try{
30
+ let res = circ(args, this);
27
31
 
28
- this.stdin(res);
32
+ this.stdin(this.static_cast(res));
33
+ } catch(e){
34
+ console.log(e)
35
+ this.stderr(`${JSON.stringify({circuit:opcode,args, error_message:e.message})}`)
36
+ }
29
37
  };
30
38
 
31
- stdin = (object, cb) => {
39
+ stdin = (object, cb, options) => {
40
+ options = options || {}
41
+ let full_obj = object
42
+ object = object.static_value
43
+
32
44
  if (object == null) {
33
45
  this.flags.void = true;
34
- return;
35
- }
36
- this.flags.void = false;
46
+ object = null
47
+ } else this.flags.void = false;
37
48
 
38
49
  this.flags.zero = !object;
39
50
  if (typeof object === "number") this.flags.neg = object < 0;
40
51
 
41
- let code_string =
42
- typeof object !== "string" ? JSON.stringify(object) : object;
52
+ let code_string;
53
+
54
+ if (cb && cb.payload && cb.payload.stdin)
55
+ options.address = cb.payload.stdin;
43
56
 
57
+ if (!options.address){
58
+ let contx_2 = this.get_context(-2)
59
+ if (full_obj&& typeof full_obj === 'object'){
60
+ if(contx_2){
61
+ full_obj.__address__ = contx_2.physical_address
62
+ }else full_obj .__address__ = this.get_context().physical_address
63
+ }
64
+ }
65
+
66
+ if (typeof full_obj === 'string'){
67
+ code_string = full_obj
68
+ } else if (full_obj.type){
69
+ if (full_obj.type === 'boolean'){
70
+ code_string = `{"type":"boolean", "static_value":${full_obj.static_value?'True':'False'},"__address__":"${full_obj.__address__}"}`
71
+ }else code_string = JSON.stringify(full_obj)
72
+ }else code_string= typeof object !== "string" ?object ==null?'Void': JSON.stringify(object) : `"${object}"`;
73
+
74
+ if (options.address){
75
+ let addr = options.address;
76
+ if(!addr.startsWith('@')){
77
+ addr = `@/${addr.split('/').slice(2).join('/')}`
78
+ }
79
+
80
+ code_string = `>${addr} ${code_string}`
81
+ }
82
+
44
83
  this.account.assembler.run(code_string, { cb, pure: true });
45
- // console.log(`Writing in: ${code_string}`);
46
84
  };
47
85
  }
48
86
 
package/Objects/Oracle.js CHANGED
@@ -36,23 +36,26 @@ class Oracle {
36
36
 
37
37
  if (!obj) {
38
38
  try {
39
- obj = this.fs.readFileSync(`${this.mgr.initiator.root}/${path}`);
40
- obj = JSON.parse(obj).payload;
39
+ obj = this.fs.readFileSync(`${this.mgr.root}/${path}`, {encoding:'utf-8'});
40
+ obj = JSON.parse(obj);
41
41
  let type = obj && obj.payload && typeof obj.payload;
42
+ obj = obj && obj.payload;
42
43
  type =
43
44
  type === "object" ? (Array.isArray(obj) ? "array" : "twain") : type;
44
45
 
45
46
  obj = { type, obj };
46
47
  this.set(path, obj);
47
- } catch (e) {}
48
+ } catch (e) {
49
+ // console.log(e.message, 'Error thrown?')
50
+ }
48
51
  }
49
52
 
50
53
  return obj;
51
54
  };
52
55
 
53
- hash = (data) => {
56
+ hash = (data, alg) => {
54
57
  data = typeof data !== "string" ? JSON.stringify(data) : data;
55
- return hash(data);
58
+ return hash(data, alg);
56
59
  };
57
60
 
58
61
  handle_compression = ({ addr, data, no_string }) => {
@@ -66,14 +69,14 @@ class Oracle {
66
69
  return data;
67
70
  };
68
71
 
69
- write = (address, payload) => {
72
+ write = (address, payload) => {
70
73
  payload = JSON.stringify({ payload });
71
74
  let data = this.handle_compression({
72
75
  addr: address,
73
76
  data: payload,
74
77
  });
75
-
76
- this.fs.writeFileSync(`${this.mgr.initiator.root}/${address}`, data, {
78
+
79
+ this.fs.writeFileSync(`${this.mgr.root}/${address}`, data, {
77
80
  encoding: "utf-8",
78
81
  });
79
82
  };
@@ -0,0 +1,5 @@
1
+ class Protocol{
2
+
3
+ }
4
+
5
+ export default Protocol