Files: d9ab14281e683bbcd8f54b5cb7874edbbdd088a7 / message.js
803 bytesRaw
1 | const U256 = require('./deps/u256.js') |
2 | |
3 | module.exports = class Message { |
4 | constructor (opts = {}) { |
5 | const defaults = { |
6 | // call infromation |
7 | to: [], |
8 | from: [], |
9 | data: new Uint8Array(), |
10 | atomic: true, |
11 | // resource info |
12 | gas: new U256(0), |
13 | gasPrices: new U256(0) |
14 | } |
15 | Object.assign(this, defaults, opts) |
16 | this.hops = 0 |
17 | this._vistedKernels = [] |
18 | } |
19 | |
20 | finished () { |
21 | if (this.atomic) { |
22 | this._vistedKernels.pop() |
23 | } |
24 | return new Promise((resolve, reject) => { |
25 | |
26 | }) |
27 | } |
28 | |
29 | nextPort () { |
30 | return this.to[this.hops++] |
31 | } |
32 | |
33 | addVistedKernel (kernel) { |
34 | if (this.atomic) { |
35 | this._vistedKernels.push(kernel) |
36 | } |
37 | } |
38 | |
39 | isCyclic (kernel) { |
40 | return this.sync && this._vistedKernels.some(process => process === kernel) |
41 | } |
42 | } |
43 |
Built with git-ssb-web