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
package/Objects/Blockweb.js
CHANGED
|
@@ -1,25 +1,43 @@
|
|
|
1
|
+
import Block from "./Block";
|
|
2
|
+
import Chain from "./Chain";
|
|
3
|
+
|
|
1
4
|
class Blockweb {
|
|
2
|
-
constructor(
|
|
3
|
-
this.
|
|
5
|
+
constructor(mgr) {
|
|
6
|
+
this.mgr = mgr;
|
|
4
7
|
this.chains = new Object();
|
|
5
8
|
this.blocks = new Object();
|
|
9
|
+
|
|
10
|
+
this.physical_addresses = new Object();
|
|
6
11
|
}
|
|
7
12
|
|
|
8
|
-
|
|
9
|
-
this.
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
sync_chain = (chain) => {
|
|
14
|
+
let chain_obj = this.chains[chain.hash];
|
|
15
|
+
if (!chain_obj) {
|
|
16
|
+
this.store_chain(chain.stringify());
|
|
17
|
+
|
|
18
|
+
return chain;
|
|
19
|
+
}
|
|
12
20
|
|
|
13
|
-
|
|
14
|
-
this.vm.get_context().chain.explore(query);
|
|
21
|
+
return chain_obj;
|
|
15
22
|
};
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
this.
|
|
24
|
+
store_chain = (chain_obj) => {
|
|
25
|
+
let addr = this.mgr.oracle.get(chain_obj.physical_address);
|
|
26
|
+
|
|
27
|
+
if (!addr) return;
|
|
28
|
+
|
|
29
|
+
let chain = new Chain(addr);
|
|
30
|
+
chain.hash = chain_obj.hash;
|
|
31
|
+
|
|
32
|
+
this.chains[chain_obj.hash] = chain;
|
|
19
33
|
};
|
|
20
34
|
|
|
21
|
-
|
|
22
|
-
this.
|
|
35
|
+
store_block = (block_obj) => {
|
|
36
|
+
let chain = this.chains[block_obj.chain];
|
|
37
|
+
if (!chain) return;
|
|
38
|
+
|
|
39
|
+
let block = new Block(chain);
|
|
40
|
+
chain.add_block(block);
|
|
23
41
|
};
|
|
24
42
|
}
|
|
25
43
|
|
package/Objects/Chain.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { hash } from "../utils/hash";
|
|
2
|
+
import Block from "./Block";
|
|
3
|
+
import Explorer from "./Explorer";
|
|
4
|
+
|
|
5
|
+
class Chain extends Explorer {
|
|
6
|
+
constructor(parent) {
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this.parent = parent;
|
|
10
|
+
this.physical_address = this.parent.physical_address;
|
|
11
|
+
this.name = this.parent.name;
|
|
12
|
+
this.servers = new Array();
|
|
13
|
+
|
|
14
|
+
this.pending_children = new Array();
|
|
15
|
+
this.connections = new Array();
|
|
16
|
+
|
|
17
|
+
this.blocks = new Array();
|
|
18
|
+
this.txs = new Array();
|
|
19
|
+
|
|
20
|
+
this.cursor = -1;
|
|
21
|
+
this.buffs = [];
|
|
22
|
+
this.listeners = [];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
add_listener = (event_twain) => {};
|
|
26
|
+
|
|
27
|
+
on = (name) => {};
|
|
28
|
+
|
|
29
|
+
after = (name) => {};
|
|
30
|
+
|
|
31
|
+
append_buffer = () => {
|
|
32
|
+
this.buffs.push({});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
get_buffer = () => {
|
|
36
|
+
return this.buffs.slice(-1)[0];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
generate_hash = () => {
|
|
40
|
+
let hsh = this.parent.path + this.parent.account.vm.snap_id();
|
|
41
|
+
this.hash = hash(hsh);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
add_tx = (instruction) => {
|
|
45
|
+
if (!this.txs.length) this.start_time = Date.now();
|
|
46
|
+
|
|
47
|
+
this.txs.push(instruction);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
set_servers = (servers) => {
|
|
51
|
+
this.servers = servers;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
mine = (vm) => {
|
|
55
|
+
let block = new Block(this);
|
|
56
|
+
|
|
57
|
+
block.store();
|
|
58
|
+
|
|
59
|
+
this.add_block(block);
|
|
60
|
+
|
|
61
|
+
vm.account.manager.web.chains[this.hash] = this;
|
|
62
|
+
|
|
63
|
+
block.children = this.pending_children;
|
|
64
|
+
this.pending_children = new Array();
|
|
65
|
+
|
|
66
|
+
let prev_context = vm.get_context(-2);
|
|
67
|
+
if (prev_context) {
|
|
68
|
+
prev_context.pending_children.push(block);
|
|
69
|
+
prev_context.connections.push(block);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.txs = new Array();
|
|
73
|
+
|
|
74
|
+
block.timelapse = Date.now() - this.start_time;
|
|
75
|
+
|
|
76
|
+
return block;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
stringify = () => {
|
|
80
|
+
let obj = {};
|
|
81
|
+
|
|
82
|
+
obj.physical_address = this.physical_address;
|
|
83
|
+
obj.parent = this.parent.path;
|
|
84
|
+
obj.connections = this.connections.map(
|
|
85
|
+
(b) => new Object({ chain: b.chain.hash, block: b.hash })
|
|
86
|
+
);
|
|
87
|
+
obj.hash = this.hash;
|
|
88
|
+
obj.blocks = this.blocks.map((blk) => blk.hash);
|
|
89
|
+
|
|
90
|
+
return obj;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
add_block = (block) => this.blocks.push(block);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default Chain;
|
package/Objects/Explorer.js
CHANGED
|
@@ -1,74 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
class Explorer {
|
|
2
|
+
constructor() {}
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
super();
|
|
6
|
-
}
|
|
4
|
+
explore = (query) => {
|
|
5
|
+
query = query.split(":");
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
return fn(v1, fn, meta);
|
|
10
|
-
};
|
|
7
|
+
query[0] = query[0].split(".");
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
let q2 = Number(query[1]);
|
|
10
|
+
|
|
11
|
+
let obj;
|
|
12
|
+
if (isNaN(q2)) {
|
|
13
|
+
obj = this.connections.find((c) => c.hash === query[1]);
|
|
14
|
+
} else if (q2 >= 0) {
|
|
15
|
+
obj = this.connections.find((q) => q.index === q2);
|
|
16
16
|
} else {
|
|
17
|
+
obj = this.connections.slice(q2)[0];
|
|
17
18
|
}
|
|
18
|
-
return circ;
|
|
19
|
-
};
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
for (let q = 0; q < query[0].length; q++) {
|
|
21
|
+
let que = query[0][q];
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
for (let p = 0; p < props.length; p++) {
|
|
27
|
-
let pp = props[p];
|
|
28
|
-
|
|
29
|
-
let q = this.get_query_circuit(pp);
|
|
30
|
-
if (!q) throw new Error(`Query ${pp} is not designed!`);
|
|
31
|
-
|
|
32
|
-
res.push(q(value, query[pp], { chain: this, query, value, block }));
|
|
23
|
+
if (!obj) break;
|
|
24
|
+
obj = obj[que];
|
|
33
25
|
}
|
|
34
26
|
|
|
35
|
-
return
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
pass = (query, block) => {
|
|
39
|
-
let pass = new Array();
|
|
40
|
-
|
|
41
|
-
if (Array.isArray(query)) {
|
|
42
|
-
for (let q = 0; q < query.length; q++) {
|
|
43
|
-
let qu = query[q];
|
|
44
|
-
let res = this.pass(qu, block);
|
|
45
|
-
if (res) {
|
|
46
|
-
pass.push(res);
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
} else
|
|
51
|
-
for (let prop in query) {
|
|
52
|
-
let value = query[prop];
|
|
53
|
-
|
|
54
|
-
if (["number", "string", "boolean"].includes(typeof value)) {
|
|
55
|
-
value = { $equals: value };
|
|
56
|
-
}
|
|
57
|
-
pass.push(
|
|
58
|
-
this.solve_query(value, !prop.startsWith("$") && block[prop], block)
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return Array.isArray(query) ? pass.includes(true) : !pass.includes(false);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
explore = (query) => {
|
|
66
|
-
let match = new Array();
|
|
67
|
-
for (let b = 0; b < this.blocks.length; b++) {
|
|
68
|
-
let block = this.blocks[b];
|
|
69
|
-
if (this.pass(query, block)) match.push(block);
|
|
70
|
-
}
|
|
71
|
-
return match;
|
|
27
|
+
return obj;
|
|
72
28
|
};
|
|
73
29
|
}
|
|
74
30
|
|
package/Objects/Filesystem.js
CHANGED
|
@@ -1,20 +1,171 @@
|
|
|
1
|
-
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import Chain from "./Chain";
|
|
3
|
+
import { hash } from "../utils/hash";
|
|
4
|
+
|
|
5
|
+
let type_buff = new Object();
|
|
6
|
+
|
|
7
|
+
class Filesystem {
|
|
2
8
|
constructor() {
|
|
3
|
-
this.
|
|
4
|
-
this.
|
|
9
|
+
this.base_address = "Accounts";
|
|
10
|
+
this.chains = new Object();
|
|
11
|
+
setTimeout(() => {
|
|
12
|
+
this.type = this.get_type();
|
|
13
|
+
}, 0);
|
|
5
14
|
}
|
|
6
15
|
|
|
7
|
-
|
|
8
|
-
|
|
16
|
+
parse_path = (path) => {
|
|
17
|
+
if (!path.includes("/")) return path;
|
|
18
|
+
|
|
19
|
+
return this.load(path);
|
|
9
20
|
};
|
|
10
21
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
22
|
+
load = (datapath) => {
|
|
23
|
+
if (!datapath) return null;
|
|
14
24
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
let type_folder = this.account.manager.oracle.tree[datapath];
|
|
26
|
+
|
|
27
|
+
if (!type_folder) return datapath;
|
|
28
|
+
|
|
29
|
+
let content;
|
|
30
|
+
if (type_folder.fold.type === "twain") {
|
|
31
|
+
content = {};
|
|
32
|
+
for (let prop in type_folder.obj) {
|
|
33
|
+
let val = type_folder.obj[prop];
|
|
34
|
+
|
|
35
|
+
content[type_folder.fold.parse_path(prop)] =
|
|
36
|
+
type_folder.fold.parse_path(val);
|
|
37
|
+
}
|
|
38
|
+
} else if (type_folder.fold.type === "array") {
|
|
39
|
+
content = [];
|
|
40
|
+
type_folder.obj.map((t) => {
|
|
41
|
+
content.push(type_folder.fold.parse_path(t));
|
|
42
|
+
});
|
|
43
|
+
} else content = type_folder.obj;
|
|
44
|
+
|
|
45
|
+
return content;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
save = (content) => {
|
|
49
|
+
let addr, obj;
|
|
50
|
+
|
|
51
|
+
if (!this.type) this.type = "Void";
|
|
52
|
+
|
|
53
|
+
if (this.type === "array" || this.type === "string") {
|
|
54
|
+
obj = [];
|
|
55
|
+
for (let curs in content) {
|
|
56
|
+
if (curs === "type") continue;
|
|
57
|
+
obj.splice(Number(curs) || -1, 0, content[curs]);
|
|
58
|
+
}
|
|
59
|
+
if (this.type === "string") {
|
|
60
|
+
obj = obj.join(" ");
|
|
61
|
+
}
|
|
62
|
+
} else if (this.type === "twain") {
|
|
63
|
+
obj = {};
|
|
64
|
+
for (let curs in content) {
|
|
65
|
+
if (curs === "type") continue;
|
|
66
|
+
obj[curs] = content[curs];
|
|
67
|
+
}
|
|
68
|
+
} else if (this.type === "number") {
|
|
69
|
+
obj = Number(content["-1"]) || -1;
|
|
70
|
+
} else {
|
|
71
|
+
obj = null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
obj = JSON.stringify(obj);
|
|
75
|
+
addr = `${this.path}/${hash(obj)}`;
|
|
76
|
+
fs.writeFileSync(addr, obj, { encoding: "utf-8" });
|
|
77
|
+
|
|
78
|
+
this.account.manager.oracle.tree[addr] = {
|
|
79
|
+
fold: this,
|
|
80
|
+
obj: JSON.parse(obj),
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return addr;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
get_type = () => {
|
|
87
|
+
if (
|
|
88
|
+
this.physical_address ===
|
|
89
|
+
`${this.account.physical_address}/Datatypes/Number`
|
|
90
|
+
)
|
|
91
|
+
return "number";
|
|
92
|
+
else if (
|
|
93
|
+
this.physical_address ===
|
|
94
|
+
`${this.account.physical_address}/Datatypes/String`
|
|
95
|
+
)
|
|
96
|
+
return "string";
|
|
97
|
+
else if (
|
|
98
|
+
this.physical_address ===
|
|
99
|
+
`${this.account.physical_address}/Datatypes/Array`
|
|
100
|
+
)
|
|
101
|
+
return "array";
|
|
102
|
+
else if (
|
|
103
|
+
this.physical_address ===
|
|
104
|
+
`${this.account.physical_address}/Datatypes/Twain`
|
|
105
|
+
)
|
|
106
|
+
return "twain";
|
|
107
|
+
else if (
|
|
108
|
+
this.physical_address ===
|
|
109
|
+
`${this.account.physical_address}/Datatypes/Void`
|
|
110
|
+
)
|
|
111
|
+
return "void";
|
|
112
|
+
else if (
|
|
113
|
+
this.physical_address ===
|
|
114
|
+
`${this.account.physical_address}/Datatypes/Boolean`
|
|
115
|
+
)
|
|
116
|
+
return "boolean";
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
write = (arg, context) => {
|
|
120
|
+
let content = context.get_buffer();
|
|
121
|
+
|
|
122
|
+
if (!content) return;
|
|
123
|
+
content[context.cursor] = arg;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
set_paths = () => {
|
|
127
|
+
this.path = `${this.parent ? this.parent.path : "Accounts"}/${this.hash}`;
|
|
128
|
+
if (!fs.existsSync(this.path)) {
|
|
129
|
+
fs.mkdirSync(this.path, { recursive: true });
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
add_chain = (name, mgr_index) => {
|
|
134
|
+
let folds = this.account.manager.oracle.get(
|
|
135
|
+
`${this.physical_address}/${name}`
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
if (!folds) {
|
|
139
|
+
folds = this.account.manager.oracle.get(name, this);
|
|
140
|
+
|
|
141
|
+
this.managers[mgr_index].folders[name] = folds;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return this.set_chain(folds);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
set_chain = (folds) => {
|
|
148
|
+
let chain = new Chain(folds);
|
|
149
|
+
chain.generate_hash();
|
|
150
|
+
|
|
151
|
+
this.account.manager.oracle.tree[folds.physical_address] = folds;
|
|
152
|
+
|
|
153
|
+
this.account.manager;
|
|
154
|
+
|
|
155
|
+
chain = this.account.manager.web.sync_chain(chain);
|
|
156
|
+
|
|
157
|
+
folds.chains[chain.hash] = chain;
|
|
158
|
+
|
|
159
|
+
return chain;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
get_chain = (context) => {
|
|
163
|
+
for (let c in this.chains) {
|
|
164
|
+
let chain = this.chains[c];
|
|
165
|
+
if (chain.physical_address === context.physical_address) return chain;
|
|
166
|
+
}
|
|
167
|
+
return this.set_chain(this);
|
|
168
|
+
};
|
|
18
169
|
}
|
|
19
170
|
|
|
20
|
-
export default
|
|
171
|
+
export default Filesystem;
|
package/Objects/Frame.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { array_to_nested_objects } from "../utils/functions";
|
|
2
|
-
import { Buffs, fs_buffer } from "../utils/hash";
|
|
3
2
|
|
|
4
3
|
class Frame {
|
|
5
4
|
constructor(object, parent) {
|
|
@@ -32,6 +31,17 @@ class Frame {
|
|
|
32
31
|
this.instructions.push(`pop ${prop}`);
|
|
33
32
|
}
|
|
34
33
|
};
|
|
34
|
+
|
|
35
|
+
flatten_instructions = () => {
|
|
36
|
+
let inss = new Array();
|
|
37
|
+
|
|
38
|
+
for (let i = 0; i < this.instructions.length; i++) {
|
|
39
|
+
let ins = this.instructions[i];
|
|
40
|
+
if (ins instanceof Frame) inss.push(...ins.flatten_instructions());
|
|
41
|
+
else inss.push(ins);
|
|
42
|
+
}
|
|
43
|
+
return inss;
|
|
44
|
+
};
|
|
35
45
|
}
|
|
36
46
|
|
|
37
47
|
export default Frame;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import Blockweb from "./Blockweb";
|
|
2
|
+
import Oracle from "./Oracle";
|
|
3
|
+
|
|
4
|
+
class Manager {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.accounts = new Object();
|
|
7
|
+
this.stack = new Object();
|
|
8
|
+
this.total = 0;
|
|
9
|
+
this.counter = 0;
|
|
10
|
+
this.tracker = new Object();
|
|
11
|
+
this.web = new Blockweb(this);
|
|
12
|
+
this.oracle = new Oracle(this);
|
|
13
|
+
|
|
14
|
+
this.start_clock();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
start_clock = () => {
|
|
18
|
+
this.clock = setInterval(() => {
|
|
19
|
+
for (let index in this.tracker) {
|
|
20
|
+
let { sequence, account } = this.stack[index];
|
|
21
|
+
let track = this.tracker[index];
|
|
22
|
+
|
|
23
|
+
let instruction = sequence[track.pointer];
|
|
24
|
+
account.vm.execute(instruction, index);
|
|
25
|
+
track.pointer++;
|
|
26
|
+
|
|
27
|
+
if (track.pointer === sequence.length) {
|
|
28
|
+
delete this.tracker[index];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!Array.from(Object.keys(this.tracker)).length)
|
|
33
|
+
clearInterval(this.clock);
|
|
34
|
+
}, 10);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
set_intiator = (initiator) => {
|
|
38
|
+
this.initiator = initiator;
|
|
39
|
+
this.accounts[this.initiator.name] = this.initiator;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
push = (program) => {
|
|
43
|
+
this.stack[this.total] = program;
|
|
44
|
+
this.tracker[this.total] = {
|
|
45
|
+
pointer: 0,
|
|
46
|
+
hold: false,
|
|
47
|
+
message: (message) => this.message(message, this.total),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
this.total++;
|
|
51
|
+
|
|
52
|
+
if (Array.from(Object.keys(this.tracker)).length === 1) this.start_clock();
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default Manager;
|
package/Objects/Opcodes.js
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
import Arr from "../Datatypes/Array";
|
|
2
|
-
import Num from "../Datatypes/Number";
|
|
3
|
-
import Str from "../Datatypes/String";
|
|
4
|
-
import Twain from "../Datatypes/Twain";
|
|
5
|
-
|
|
6
1
|
class Opcodes {
|
|
7
|
-
|
|
2
|
+
constructor() {
|
|
3
|
+
this.opcodes = new Object();
|
|
4
|
+
}
|
|
8
5
|
|
|
9
|
-
set = (
|
|
10
|
-
this.opcodes[
|
|
6
|
+
set = (opcode, circuit) => {
|
|
7
|
+
this.opcodes[opcode] = circuit;
|
|
11
8
|
};
|
|
12
9
|
|
|
13
10
|
prepare_operation = (opcode, context) => {
|
|
14
11
|
let circ = this.opcodes[opcode];
|
|
15
|
-
circ(context.parent.content_buffer, context);
|
|
16
|
-
};
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
else if (buffer.type === "string") obj = new Str(buffer.value).load();
|
|
23
|
-
else if (buffer.type === "number") obj = new Num(buffer.value).load();
|
|
13
|
+
if (typeof circ !== "function") {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
let buf = context.get_buffer();
|
|
24
17
|
|
|
25
|
-
|
|
18
|
+
let res = circ(context.parent.load(buf.inputs));
|
|
19
|
+
this.stdin(res);
|
|
26
20
|
};
|
|
21
|
+
|
|
22
|
+
stdin = (object) => {};
|
|
27
23
|
}
|
|
28
24
|
|
|
29
25
|
export default Opcodes;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Folder from "./folder";
|
|
2
|
+
|
|
3
|
+
class Oracle {
|
|
4
|
+
constructor(mgr) {
|
|
5
|
+
this.mgr = mgr;
|
|
6
|
+
|
|
7
|
+
this.tree = new Object();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
get = (path, parent, should_break) => {
|
|
11
|
+
if (parent) path = parent.physical_address + `/${path}`;
|
|
12
|
+
|
|
13
|
+
path = path.split("/");
|
|
14
|
+
path.splice(0, 2, `${path[0]}/${path[1]}`);
|
|
15
|
+
|
|
16
|
+
let ini = this.tree[path[0]],
|
|
17
|
+
prior;
|
|
18
|
+
|
|
19
|
+
for (let p = 1; p < path.length; p++) {
|
|
20
|
+
let pth = path[p];
|
|
21
|
+
|
|
22
|
+
prior = ini;
|
|
23
|
+
ini = this.tree[`${prior.physical_address}/${pth}`];
|
|
24
|
+
if (!ini) {
|
|
25
|
+
if (should_break) break;
|
|
26
|
+
|
|
27
|
+
ini = new Folder(pth, prior);
|
|
28
|
+
this.tree[ini.physical_address] = ini;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return ini;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default Oracle;
|