godprotocol 1.0.751 → 1.0.753
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/Objects/Account.js +13 -16
- package/Objects/Manager.js +16 -1
- package/package.json +1 -1
package/Objects/Account.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Aircode from "../Aircode/main";
|
|
2
|
+
import start from "../Index";
|
|
2
3
|
import { hash } from "../utils/hash";
|
|
3
4
|
import { post_request } from "../utils/services";
|
|
4
5
|
import Chain from "./Chain";
|
|
@@ -47,35 +48,33 @@ class Account extends Filesystem {
|
|
|
47
48
|
return account || this;
|
|
48
49
|
};
|
|
49
50
|
|
|
50
|
-
manage_buffer = () => {
|
|
51
|
+
manage_buffer = (cb) => {
|
|
51
52
|
let call_session = `${Date.now()}-${Math.random()}`;
|
|
52
|
-
this.mine_buffer[call_session] = [];
|
|
53
|
+
this.mine_buffer[call_session] = { blocks: [], cb };
|
|
53
54
|
|
|
54
55
|
return call_session;
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
buff = (block, pid) => {
|
|
58
|
-
let
|
|
59
|
-
if (!
|
|
59
|
+
let bf = this.mine_buffer[pid];
|
|
60
|
+
if (!bf) return;
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
bf.blocks.push(block.stringify());
|
|
62
63
|
};
|
|
63
64
|
|
|
64
|
-
flush_buffer = (
|
|
65
|
-
let
|
|
65
|
+
flush_buffer = (pid) => {
|
|
66
|
+
let buff = this.mine_buffer[pid];
|
|
66
67
|
|
|
67
|
-
cb && cb(blocks);
|
|
68
|
+
buff.cb && buff.cb(buff.blocks);
|
|
68
69
|
delete this.mine_buffer[pid];
|
|
69
70
|
};
|
|
70
71
|
|
|
71
72
|
load = ({ instructions, account }, cb) => {
|
|
72
73
|
account = this.get_account(account);
|
|
73
74
|
|
|
74
|
-
let pid = account.manage_buffer();
|
|
75
|
+
let pid = account.manage_buffer(cb);
|
|
75
76
|
|
|
76
77
|
this.manager.push({ sequence: instructions, account, pid });
|
|
77
|
-
|
|
78
|
-
account.flush_buffer(cb, pid);
|
|
79
78
|
};
|
|
80
79
|
|
|
81
80
|
parse = ({ physical_address, account, query }, cb) => {
|
|
@@ -92,19 +91,17 @@ class Account extends Filesystem {
|
|
|
92
91
|
run = ({ account, query, physical_address }, cb) => {
|
|
93
92
|
account = this.get_account(account);
|
|
94
93
|
|
|
95
|
-
let pid = account.manage_buffer();
|
|
94
|
+
let pid = account.manage_buffer(cb);
|
|
96
95
|
|
|
97
96
|
let context = physical_address
|
|
98
97
|
? this.manager.web.get({ physical_address }, true)
|
|
99
98
|
: account.vm.get_context();
|
|
100
99
|
|
|
101
|
-
if (!context) return account.flush_buffer(
|
|
100
|
+
if (!context) return account.flush_buffer(pid);
|
|
102
101
|
|
|
103
102
|
let blk = query ? context.explore(query) : context.get_block(0);
|
|
104
103
|
|
|
105
104
|
blk && this.manager.push({ sequence: blk.data, account, pid });
|
|
106
|
-
|
|
107
|
-
account.flush_buffer(cb, pid);
|
|
108
105
|
};
|
|
109
106
|
|
|
110
107
|
add_server = (server) => {
|
|
@@ -167,7 +164,7 @@ class Account extends Filesystem {
|
|
|
167
164
|
let account = this.accounts[name] || this.manager.accounts[name];
|
|
168
165
|
|
|
169
166
|
if (!account) {
|
|
170
|
-
account =
|
|
167
|
+
account = start(name, server);
|
|
171
168
|
this.accounts[account.name] = account;
|
|
172
169
|
this.manager.accounts[account.name] = account;
|
|
173
170
|
}
|
package/Objects/Manager.js
CHANGED
|
@@ -21,8 +21,15 @@ class Manager {
|
|
|
21
21
|
track.account.vm.execute(instruction, track);
|
|
22
22
|
track.pointer++;
|
|
23
23
|
|
|
24
|
+
if (track.breakpoint.slice(-1)[0] === track.pointer) {
|
|
25
|
+
track.account.flush_buffer(track.pid);
|
|
26
|
+
track.pid = track.pids.splice(-1)[0];
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
if (track.pointer === track.sequence.length) {
|
|
25
30
|
this.total--;
|
|
31
|
+
track.account.flush_buffer(track.pid);
|
|
32
|
+
|
|
26
33
|
delete this.tracks[account];
|
|
27
34
|
}
|
|
28
35
|
}
|
|
@@ -38,12 +45,20 @@ class Manager {
|
|
|
38
45
|
let track = this.tracks[program.account.name];
|
|
39
46
|
|
|
40
47
|
if (!track) {
|
|
41
|
-
track = {
|
|
48
|
+
track = {
|
|
49
|
+
...program,
|
|
50
|
+
sequence: [...program.sequence],
|
|
51
|
+
pointer: 0,
|
|
52
|
+
pids: [program.pid],
|
|
53
|
+
breakpoint: new Array(),
|
|
54
|
+
};
|
|
42
55
|
this.tracks[track.account.name] = track;
|
|
43
56
|
this.total++;
|
|
44
57
|
this.total === 1 && this.start_clock();
|
|
45
58
|
} else {
|
|
59
|
+
track.breakpoint.push(track.pointer + 1);
|
|
46
60
|
track.sequence.splice(track.pointer + 1, 0, ...program.sequence);
|
|
61
|
+
track.pids.push(program.pid);
|
|
47
62
|
}
|
|
48
63
|
};
|
|
49
64
|
}
|