godprotocol 1.0.5 → 1.0.6
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/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
- package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/4e7ba40328eee49c03ebf12bed83a10f42022b10601b9963ee299e50cbde0026/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
- package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
- package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
- package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
- package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
- package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/4e7ba40328eee49c03ebf12bed83a10f42022b10601b9963ee299e50cbde0026/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/bd82cf16699be29ec05cbb763199c12f0dced428dde8381dbdd31c1d5dd0e8d4/7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/46931496c37b22cb91df1929ca4d44b3349c68ec818b37b63dd8583f31e3015b +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/4c061633d7fc20f5202cf7d5940b8623c12064c5ede02977e8b5e9e6e7fb9687 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/a20ee8d03f370f8bc61adaf18b681b3e2c4017defd3ad38cb99d2111167ca479 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/ad1e584a505553ddda31fe599dad98fc35a04bd0ff5a654035f85137aa633842 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/bb3d37eee86ecb7262c8ac311a2ddd7f6b9f6298682e348bc784e91511d41638 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/be574e4859c2aba2a2e6a4eb7cf51f006fe2d493ad0268a1f6341e50f0beba90 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/f5822a8abd3cb9f230711a1ceac473518a38f8824164c9536ae2d20ca264a385 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/f5bbe585b2c9ef9a1dca11d1520b40847dc0858a0da1e509f646963be5d3866b +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/f8127f98684c7e3ab56acdc33af3a3ffe02fbcce9740184d2fa64cc7f3db7fdc +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/63d42d26156fcc761e57da4128e9881d5bdf3bf933f0f6e9c93d6e26b9b90ae7/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/63d42d26156fcc761e57da4128e9881d5bdf3bf933f0f6e9c93d6e26b9b90ae7/51a3716d770009c68d68a8f39f912020972c5219187f79f77bdf996e6d3cc530 +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/63d42d26156fcc761e57da4128e9881d5bdf3bf933f0f6e9c93d6e26b9b90ae7/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
- package/Aircode/functions/parse_expression.js +117 -0
- package/Aircode/functions/parse_to_obj.js +26 -0
- package/Aircode/functions/parse_variable.js +35 -0
- package/Aircode/functions/tokenise.js +118 -0
- package/Aircode/functions/utils.js +11 -0
- package/Aircode/keywords/conditional.js +104 -0
- package/Aircode/keywords/parse.js +20 -0
- package/Aircode/main.js +94 -0
- package/Aircode/native_classes/Variable.js +36 -0
- package/Aircode/native_classes/datatypes/Number.js +20 -0
- package/Aircode/native_classes/datatypes/String.js +20 -0
- package/Aircode/native_classes/global.js +21 -0
- package/Aircode/native_classes/native.js +23 -0
- package/Aircode/native_classes/operators.js +47 -0
- package/Aircode/native_classes/parse.js +42 -0
- package/Aircode/utils/format_instructions.js +36 -0
- package/Aircode/utils/traverse.js +13 -0
- package/Index.js +19 -20
- package/Objects/Account.js +90 -98
- package/Objects/Block.js +45 -0
- package/Objects/Blockweb.js +30 -12
- package/Objects/Chain.js +96 -0
- package/Objects/Explorer.js +18 -62
- package/Objects/Filesystem.js +163 -12
- package/Objects/Frame.js +11 -1
- package/Objects/Manager.js +56 -0
- package/Objects/Opcodes.js +13 -17
- package/Objects/Oracle.js +35 -0
- package/Objects/Virtual_machine.js +72 -70
- package/Objects/folder.js +8 -83
- package/framer.js +27 -4
- package/opcodes/add.js +15 -38
- package/opcodes/jmp.js +9 -3
- package/opcodes/std.js +5 -0
- package/opcodes.js +19 -10
- package/package.json +1 -1
- package/utils/create_server.js +23 -12
- package/utils/hash.js +1 -38
- package/utils/services.js +25 -15
- package/.keypair +0 -1
- package/Datatypes/Array.js +0 -33
- package/Datatypes/Number.js +0 -21
- package/Datatypes/String.js +0 -23
- package/Datatypes/Twain.js +0 -42
- package/Objects/Blockchain.js +0 -135
- package/Objects/Emitter.js +0 -38
- package/Objects/Queries.js +0 -13
- package/Objects/file.js +0 -21
- package/Socket.js +0 -83
- package/index.d.ts +0 -50
- package/utils/gen_key_pair.js +0 -36
|
@@ -1,112 +1,114 @@
|
|
|
1
|
-
import { Block } from "./Blockchain";
|
|
2
|
-
import Blockweb from "./Blockweb";
|
|
3
|
-
import File_system from "./Filesystem";
|
|
4
|
-
import Frame from "./Frame";
|
|
5
1
|
import Opcodes from "./Opcodes";
|
|
6
2
|
|
|
7
3
|
class Virtual_machine extends Opcodes {
|
|
8
|
-
constructor(
|
|
4
|
+
constructor(context) {
|
|
9
5
|
super();
|
|
10
6
|
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.fm = new File_system(this);
|
|
14
|
-
|
|
15
|
-
this.pointers = new Array();
|
|
7
|
+
this.account = context.parent.account;
|
|
8
|
+
this.contexts = [context];
|
|
16
9
|
}
|
|
17
10
|
|
|
18
11
|
get_context = (index) => {
|
|
19
|
-
return index != null ?
|
|
12
|
+
return this.contexts.slice(index != null ? index : -1)[0];
|
|
20
13
|
};
|
|
21
14
|
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
/* VM moment */
|
|
16
|
+
snap_id = () => {
|
|
17
|
+
return `${this.get_context().hash}-${this.mgr_index || -1}`;
|
|
18
|
+
};
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (ins) {
|
|
28
|
-
let res = this.check_instruction(ins);
|
|
29
|
-
if (res) {
|
|
30
|
-
} else this.execute(ins);
|
|
31
|
-
}
|
|
20
|
+
parse_arg = (arg, cursor) => {
|
|
21
|
+
let context = this.get_context();
|
|
32
22
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
23
|
+
let args = arg.split("/"),
|
|
24
|
+
i = 0;
|
|
25
|
+
while (args[0] === "..") {
|
|
26
|
+
i++;
|
|
38
27
|
|
|
39
|
-
|
|
40
|
-
if (instruction instanceof Block) {
|
|
41
|
-
this.state.push(instruction);
|
|
42
|
-
instruction = instruction.data;
|
|
43
|
-
} else if (instruction instanceof Frame) {
|
|
44
|
-
instruction = instruction.instructions;
|
|
45
|
-
} else {
|
|
46
|
-
return;
|
|
28
|
+
args.splice(0, 1);
|
|
47
29
|
}
|
|
48
30
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
31
|
+
i = (i + 1) * -1;
|
|
32
|
+
context = i ? this.get_context(i) : context;
|
|
52
33
|
|
|
53
|
-
|
|
54
|
-
let tags = tag.split(":");
|
|
55
|
-
tags[0] = tags[0].slice(1);
|
|
56
|
-
tags[1] = tags[1].slice(0, -1);
|
|
34
|
+
arg = args.join("/");
|
|
57
35
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let data;
|
|
63
|
-
if (!arg) return;
|
|
64
|
-
if (arg.startsWith("{")) {
|
|
65
|
-
data = this.readonly();
|
|
36
|
+
if (arg.startsWith("{*") && cursor) {
|
|
37
|
+
arg = context.explore(arg.splice(2, -1));
|
|
38
|
+
} else if (arg.startsWith("{") && !cursor) {
|
|
39
|
+
arg = context.explore(arg.slice(1, -1));
|
|
66
40
|
}
|
|
67
41
|
|
|
68
|
-
return
|
|
42
|
+
return arg;
|
|
69
43
|
};
|
|
70
44
|
|
|
71
|
-
execute(instruction) {
|
|
72
|
-
|
|
45
|
+
execute = (instruction, mgr_index) => {
|
|
46
|
+
this.mgr_index = mgr_index;
|
|
47
|
+
|
|
48
|
+
let split = instruction.split(" ");
|
|
49
|
+
let opcode = split[0],
|
|
50
|
+
args = split.slice(1).join(" ");
|
|
73
51
|
|
|
74
52
|
let context = this.get_context();
|
|
75
53
|
|
|
76
54
|
context.add_tx(instruction);
|
|
77
|
-
|
|
55
|
+
|
|
56
|
+
let chain;
|
|
57
|
+
|
|
58
|
+
args = this.parse_arg(args, opcode === "cursor");
|
|
59
|
+
|
|
60
|
+
context.on(opcode, args);
|
|
78
61
|
|
|
79
62
|
switch (opcode) {
|
|
80
63
|
case "chain":
|
|
81
|
-
|
|
82
|
-
this.
|
|
64
|
+
chain = context.parent.add_chain(args, mgr_index);
|
|
65
|
+
this.contexts.push(chain);
|
|
66
|
+
|
|
67
|
+
chain.append_buffer();
|
|
68
|
+
context.parent.account.send(chain);
|
|
83
69
|
break;
|
|
84
70
|
case "link":
|
|
85
|
-
|
|
71
|
+
let folder = context.parent.account.manager.oracle.get(args);
|
|
72
|
+
|
|
73
|
+
if (!folder) {
|
|
74
|
+
console.log(`LINKing Failed. - ${args}`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
chain = folder.get_chain(context);
|
|
79
|
+
|
|
80
|
+
chain.append_buffer();
|
|
81
|
+
|
|
82
|
+
this.contexts.push(chain);
|
|
83
|
+
|
|
84
|
+
context.parent.account.send(chain);
|
|
86
85
|
break;
|
|
87
|
-
case "
|
|
88
|
-
context.
|
|
89
|
-
this.state.slice(-2)[0].handle_children(context.get_latest_block());
|
|
86
|
+
case "listen":
|
|
87
|
+
context.add_listener(args);
|
|
90
88
|
break;
|
|
91
|
-
case "
|
|
92
|
-
|
|
89
|
+
case "mine":
|
|
90
|
+
let bloc = context.mine(this);
|
|
91
|
+
context.parent.account.send(bloc, null, bloc.chain.hash);
|
|
93
92
|
break;
|
|
94
93
|
case "pop":
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
let blk;
|
|
95
|
+
if (context.txs.length > 1) {
|
|
96
|
+
blk = context.mine(this);
|
|
97
|
+
context.parent.account.send(blk, null, blk.chain.hash);
|
|
98
|
+
}
|
|
99
|
+
this.contexts.pop();
|
|
97
100
|
break;
|
|
98
|
-
case "
|
|
99
|
-
|
|
101
|
+
case "cursor":
|
|
102
|
+
context.cursor = args;
|
|
103
|
+
break;
|
|
104
|
+
case "write":
|
|
105
|
+
context.parent.write(args, context);
|
|
100
106
|
break;
|
|
101
107
|
default:
|
|
102
|
-
|
|
103
|
-
else this.prepare_operation(opcode, context);
|
|
108
|
+
this.prepare_operation(opcode, context);
|
|
104
109
|
}
|
|
105
|
-
}
|
|
106
110
|
|
|
107
|
-
|
|
108
|
-
console.log(msg);
|
|
109
|
-
this.err_ = true;
|
|
111
|
+
context.after(opcode, args);
|
|
110
112
|
};
|
|
111
113
|
}
|
|
112
114
|
|
package/Objects/folder.js
CHANGED
|
@@ -1,94 +1,19 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { emitter } from "./Account";
|
|
3
|
-
import File from "./file";
|
|
4
|
-
import { Block, Chain } from "./Blockchain";
|
|
5
1
|
import { hash } from "../utils/hash";
|
|
2
|
+
import Filesystem from "./Filesystem";
|
|
6
3
|
|
|
7
|
-
class Folder {
|
|
8
|
-
|
|
4
|
+
class Folder extends Filesystem {
|
|
5
|
+
constructor(name, parent) {
|
|
6
|
+
super();
|
|
9
7
|
|
|
10
|
-
constructor(name, parent, hash) {
|
|
11
8
|
this.name = name;
|
|
12
9
|
this.parent = parent;
|
|
13
|
-
this.hash = hash;
|
|
14
|
-
this.
|
|
10
|
+
this.hash = hash(this.name);
|
|
11
|
+
this.physical_address = `${this.parent.physical_address}/${this.name}`;
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
this.account = this.parent.account;
|
|
17
14
|
|
|
18
|
-
this.
|
|
19
|
-
this.files = new Array();
|
|
20
|
-
this.folders = new Array();
|
|
21
|
-
this.chain = new Chain(this);
|
|
22
|
-
|
|
23
|
-
this.curs = -1;
|
|
24
|
-
this.content_buffer = new Object();
|
|
25
|
-
|
|
26
|
-
this.set_path();
|
|
15
|
+
this.set_paths();
|
|
27
16
|
}
|
|
28
|
-
|
|
29
|
-
cursor = (curs) => (this.curs = curs);
|
|
30
|
-
|
|
31
|
-
write = (data) => {
|
|
32
|
-
let v = this.content_buffer[this.curs];
|
|
33
|
-
|
|
34
|
-
if (!v) {
|
|
35
|
-
v = new Array();
|
|
36
|
-
this.content_buffer[this.curs] = v;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
v.push(data instanceof Block ? data.hash : data);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
file = (name) => {
|
|
43
|
-
let file = this.files.find((f) => f.name === name);
|
|
44
|
-
|
|
45
|
-
if (!file) {
|
|
46
|
-
file = new File(name, this);
|
|
47
|
-
this.files.push(file);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return file;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
get = (opcode) => {
|
|
54
|
-
let circ = this[opcode];
|
|
55
|
-
|
|
56
|
-
return circ;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
get_column = () => {
|
|
60
|
-
this.get_active_file().block.get_column();
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
fetch_arg = (path) => {
|
|
64
|
-
let block = this.chain.explore({ parents: `./God/${path}` });
|
|
65
|
-
return block.file.parse(true);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
folder = (name, context) => {
|
|
69
|
-
let name_hash = hash(name + context.hash);
|
|
70
|
-
let folder = this.folders.find((f) => f.hash === name_hash);
|
|
71
|
-
if (!folder) {
|
|
72
|
-
folder = new Folder(name, this, name_hash);
|
|
73
|
-
folder.account = this.account;
|
|
74
|
-
|
|
75
|
-
this.folders.push(folder);
|
|
76
|
-
}
|
|
77
|
-
folder.context = context.hash;
|
|
78
|
-
|
|
79
|
-
return folder;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
parse = () => {
|
|
83
|
-
return this;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
set_path = () => {
|
|
87
|
-
if (fs.existsSync(this.path)) {
|
|
88
|
-
} else {
|
|
89
|
-
fs.mkdirSync(this.path);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
17
|
}
|
|
93
18
|
|
|
94
19
|
export default Folder;
|
package/framer.js
CHANGED
|
@@ -1,19 +1,39 @@
|
|
|
1
|
+
import Frame from "./Objects/Frame";
|
|
2
|
+
|
|
1
3
|
const framer = (initiator) => {
|
|
2
|
-
let frame =
|
|
4
|
+
let frame = new Frame({
|
|
3
5
|
Opcodes: {
|
|
4
6
|
add: null,
|
|
5
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,
|
|
18
|
+
|
|
6
19
|
send: null,
|
|
7
|
-
jmp: null,
|
|
8
|
-
jmp_if: null,
|
|
9
20
|
readonly: null,
|
|
10
21
|
socket_send: null,
|
|
22
|
+
|
|
23
|
+
jmp: null,
|
|
24
|
+
jmp_if: null,
|
|
25
|
+
hold: null,
|
|
26
|
+
|
|
27
|
+
stdout: null,
|
|
28
|
+
stdin: null,
|
|
11
29
|
},
|
|
12
30
|
Datatypes: {
|
|
13
31
|
Number: null,
|
|
14
32
|
String: null,
|
|
15
33
|
Twain: null,
|
|
16
34
|
Array: null,
|
|
35
|
+
Void: null,
|
|
36
|
+
Boolean: null,
|
|
17
37
|
},
|
|
18
38
|
Objects: {
|
|
19
39
|
Blockchain: {
|
|
@@ -33,8 +53,11 @@ const framer = (initiator) => {
|
|
|
33
53
|
},
|
|
34
54
|
},
|
|
35
55
|
});
|
|
56
|
+
frame.to_instruction();
|
|
36
57
|
|
|
37
|
-
initiator.load({
|
|
58
|
+
initiator.load({
|
|
59
|
+
instructions: frame.flatten_instructions(),
|
|
60
|
+
});
|
|
38
61
|
};
|
|
39
62
|
|
|
40
63
|
export default framer;
|
package/opcodes/add.js
CHANGED
|
@@ -1,38 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const exp = (args) => {
|
|
17
|
-
let result = args.op1 ** args.op2;
|
|
18
|
-
|
|
19
|
-
return new Num(result, "exp").load(initiator);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const multiply = (args) => {
|
|
23
|
-
let result = args.op1 * args.op2;
|
|
24
|
-
|
|
25
|
-
return new Num(result, "multiply").load(initiator);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const subtract = (args) => {
|
|
29
|
-
let result = args.op1 - args.op2;
|
|
30
|
-
|
|
31
|
-
return new Num(result, "subtract").load(initiator);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const equal = (args) => {
|
|
35
|
-
return new Num(Number(args.op1 === args.op2), "equal").load(initiator);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export { add, equal, divide, multiply, exp, subtract };
|
|
1
|
+
let ops = [
|
|
2
|
+
{ name: "add", sign: "+" },
|
|
3
|
+
{ name: "multiply", sign: "*" },
|
|
4
|
+
{ name: "subtract", sign: "-" },
|
|
5
|
+
{ name: "divide", sign: "/" },
|
|
6
|
+
{ name: "exp", sign: "**" },
|
|
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
|
+
];
|
|
14
|
+
|
|
15
|
+
export { ops };
|
package/opcodes/jmp.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
const jmp = (args, vm) => {
|
|
2
|
-
vm.
|
|
2
|
+
vm.account.manager.tracker[vm.mgr_index].pointer += args.index;
|
|
3
3
|
};
|
|
4
4
|
|
|
5
5
|
const jmp_if = (args, vm) => {
|
|
6
|
-
if (args.passed)
|
|
6
|
+
if (args.passed)
|
|
7
|
+
vm.account.manager.tracker[vm.mgr_index].pointer += args.index;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
const hold = (args, vm) => {
|
|
11
|
+
let track = vm.account.manager.tracker[vm.mgr_index];
|
|
12
|
+
track.hold = args.hold;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { jmp, jmp_if, hold };
|
package/opcodes/std.js
ADDED
package/opcodes.js
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import { socket_send } from "./Socket";
|
|
2
|
-
import {
|
|
3
|
-
import { jmp, jmp_if } from "./opcodes/jmp";
|
|
1
|
+
// import { socket_send } from "./Socket";
|
|
2
|
+
import { ops } from "./opcodes/add";
|
|
3
|
+
import { hold, jmp, jmp_if } from "./opcodes/jmp";
|
|
4
|
+
import { stdout } from "./opcodes/std";
|
|
4
5
|
import { post_request } from "./utils/services";
|
|
5
6
|
|
|
6
7
|
const opcodes = (initiator) => {
|
|
7
8
|
let set = initiator.vm.set;
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
ops.map((op) => {
|
|
11
|
+
set(op.name, (args) => {
|
|
12
|
+
console.log(args, "EMpty?");
|
|
13
|
+
try {
|
|
14
|
+
let result = eval(`${args.op0} ${op.sign} ${args.op1}`);
|
|
15
|
+
return result;
|
|
16
|
+
} catch (e) {
|
|
17
|
+
console.log(e.message);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
15
21
|
|
|
22
|
+
set("hold", hold);
|
|
16
23
|
set("jmp", jmp);
|
|
17
24
|
set("jmp_if", jmp_if);
|
|
18
25
|
|
|
19
26
|
set("send", post_request);
|
|
20
|
-
set("socket_send", socket_send);
|
|
27
|
+
// set("socket_send", socket_send);
|
|
28
|
+
|
|
29
|
+
set("stdout", stdout);
|
|
21
30
|
};
|
|
22
31
|
|
|
23
32
|
export default opcodes;
|
package/package.json
CHANGED
package/utils/create_server.js
CHANGED
|
@@ -1,28 +1,34 @@
|
|
|
1
1
|
import http from "http";
|
|
2
|
+
import { manager } from "../Index";
|
|
2
3
|
|
|
3
|
-
let PORT =
|
|
4
|
+
let PORT = 1901,
|
|
5
|
+
domain;
|
|
6
|
+
|
|
7
|
+
const create_server = (initiator, serve) => {
|
|
8
|
+
PORT = (serve && serve.port) || PORT;
|
|
4
9
|
|
|
5
|
-
const create_server = (initiator) => {
|
|
6
10
|
let server = http.createServer((req, res) => {
|
|
7
11
|
let data = "";
|
|
8
12
|
|
|
9
13
|
req.on("data", (chunk) => {
|
|
10
|
-
console.log("Received chunk");
|
|
11
14
|
data += chunk;
|
|
12
15
|
});
|
|
13
16
|
|
|
14
17
|
req.on("end", () => {
|
|
15
18
|
data = JSON.parse(data);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
|
|
20
|
+
if (req.url === "/distribute") {
|
|
21
|
+
if (data.blocks) {
|
|
22
|
+
manager.web.store_chain(data);
|
|
23
|
+
} else if (data.chain) {
|
|
24
|
+
manager.web.store_block(data);
|
|
25
|
+
}
|
|
26
|
+
res.end();
|
|
27
|
+
} else if (req.url === "/create_account") {
|
|
28
|
+
let account = initiator.account(data.name, data.server);
|
|
29
|
+
res.end(JSON.stringify(account.stringify()));
|
|
30
|
+
} else if (req.url === "/load") {
|
|
23
31
|
initiator.load(data);
|
|
24
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
25
|
-
res.end(JSON.stringify({ status: "success", message: "Data loaded" }));
|
|
26
32
|
}
|
|
27
33
|
});
|
|
28
34
|
|
|
@@ -33,6 +39,11 @@ const create_server = (initiator) => {
|
|
|
33
39
|
});
|
|
34
40
|
|
|
35
41
|
server.listen(PORT, () => {
|
|
42
|
+
initiator.add_server({
|
|
43
|
+
hostname: (serve && serve.domain) || domain || "127.0.0.1",
|
|
44
|
+
port: PORT,
|
|
45
|
+
});
|
|
46
|
+
|
|
36
47
|
console.log(
|
|
37
48
|
`\n...GOD PROTOCOL RUNNING :${PORT}\nYour Public_key: ${process.env.PUBLIC_KEY}`
|
|
38
49
|
);
|
package/utils/hash.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import Num from "../Datatypes/Number";
|
|
3
|
-
import Str from "../Datatypes/String";
|
|
4
|
-
import Arr from "../Datatypes/Array";
|
|
5
|
-
import Twain from "../Datatypes/Twain";
|
|
6
1
|
const crypto = require("crypto");
|
|
7
2
|
|
|
8
3
|
const hash = (data) => {
|
|
@@ -15,36 +10,4 @@ const hash = (data) => {
|
|
|
15
10
|
return result;
|
|
16
11
|
};
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const fs_buffer = (payload, buff_index) => {
|
|
21
|
-
try {
|
|
22
|
-
fs.writeFileSync(payload.addr, JSON.stringify(payload.data));
|
|
23
|
-
|
|
24
|
-
if (buff_index) Buffs.splice(buff_index - 1, 1);
|
|
25
|
-
} catch (e) {
|
|
26
|
-
!buff_index && Buffs.push({ hash: hash(JSON.stringify(payload)), payload });
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const store = (obj) => {
|
|
31
|
-
let addr;
|
|
32
|
-
|
|
33
|
-
if (obj.type === "string") {
|
|
34
|
-
addr = new Str(obj.value.join("")).store();
|
|
35
|
-
} else if (obj.type === "number") {
|
|
36
|
-
addr = new Num(obj.value).store();
|
|
37
|
-
} else if (obj.type === "array") {
|
|
38
|
-
addr = new Arr(obj.value).store();
|
|
39
|
-
} else if (obj.type === "twain") {
|
|
40
|
-
addr = new Twain(obj.value).store();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return addr;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const load = (addr) => {
|
|
47
|
-
let obj;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export { hash, fs_buffer, store, Buffs, load };
|
|
13
|
+
export { hash };
|
package/utils/services.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { store } from "./hash";
|
|
2
|
-
|
|
3
1
|
const http = require("http");
|
|
4
2
|
|
|
5
3
|
const get_request = (payload, context) => {
|
|
@@ -27,7 +25,7 @@ const get_request = (payload, context) => {
|
|
|
27
25
|
req.end();
|
|
28
26
|
};
|
|
29
27
|
|
|
30
|
-
const post_request = (payload,
|
|
28
|
+
const post_request = (payload, cb) => {
|
|
31
29
|
// let options = {
|
|
32
30
|
// hostname: 'example.com',
|
|
33
31
|
// port: 80,
|
|
@@ -38,23 +36,35 @@ const post_request = (payload, context) => {
|
|
|
38
36
|
// 'Content-Length': Buffer.byteLength(postData),
|
|
39
37
|
// },
|
|
40
38
|
// };
|
|
41
|
-
let initiator = context.get_context(0);
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
let data = "";
|
|
40
|
+
// console.log(payload);
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
let req = http.request(
|
|
43
|
+
{
|
|
44
|
+
...payload.options,
|
|
45
|
+
method: "POST",
|
|
46
|
+
headers: {
|
|
47
|
+
"Content-Type": "application/json",
|
|
48
|
+
"Content-Length": Buffer.byteLength(payload.data),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
(res) => {
|
|
52
|
+
let data = "";
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
res.on("data", (chunk) => {
|
|
55
|
+
data += chunk;
|
|
56
|
+
cb && cb(chunk);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
res.on("end", () => {
|
|
60
|
+
cb && cb(data);
|
|
61
|
+
// console.log("Response:", data);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
);
|
|
55
65
|
|
|
56
66
|
req.on("error", (e) => {
|
|
57
|
-
|
|
67
|
+
cb(e.message);
|
|
58
68
|
console.error(`Problem with request: ${e.message}`);
|
|
59
69
|
});
|
|
60
70
|
|
package/.keypair
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"private_key":"51903accc9f7c5eaa76068a02380456df623b7a7a6e991a6168b17f5f13d35ca","public_key":"04ca9003f27e69ef18a79767e22604aef44ec187bf558d9c877e52a7621e3200f12755c996f5befe7c73e2e62e389cd006717e3319a9c28a917020beb74bcf64b9","public_key_compressed":"03ca9003f27e69ef18a79767e22604aef44ec187bf558d9c877e52a7621e3200f1"}
|
package/Datatypes/Array.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { hash, load } from "../utils/hash";
|
|
3
|
-
|
|
4
|
-
class Arr {
|
|
5
|
-
constructor(object, account) {
|
|
6
|
-
this.object = object;
|
|
7
|
-
this.account = account;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
load = () => {
|
|
11
|
-
let obj = [];
|
|
12
|
-
this.object.map((o) => {
|
|
13
|
-
let blk = this.account.vm.web.blocks[o];
|
|
14
|
-
obj.push(load(blk.read_metadata()));
|
|
15
|
-
});
|
|
16
|
-
return obj;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
store = () => {
|
|
20
|
-
let curr_hash = hash("[]");
|
|
21
|
-
this.object.map((o) => {
|
|
22
|
-
hash(curr_hash + hash(o));
|
|
23
|
-
});
|
|
24
|
-
this.path = `${this.account.path}/Datatypes/Array`;
|
|
25
|
-
curr_hash = hash(curr_hash);
|
|
26
|
-
|
|
27
|
-
fs.writeFileSync(`${this.path}/${curr_hash}`, JSON.stringify(this.object));
|
|
28
|
-
|
|
29
|
-
return this;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default Arr;
|