Files: d9ab14281e683bbcd8f54b5cb7874edbbdd088a7 / deps / rootVertex.js
1475 bytesRaw
1 | const KernelVertex = require('./kernelVertex') |
2 | const Kernel = require('../') |
3 | const Precompiles = require('../precomiles/precompile.js') |
4 | const Address = require('./address') |
5 | |
6 | const identityAddress = new Address('0x0000000000000000000000000000000000000004') |
7 | const meteringAddress = new Address('0x000000000000000000000000000000000000000A') |
8 | const transcompilerAddress = new Address('0x000000000000000000000000000000000000000B') |
9 | |
10 | module.exports = class RootKernelVertex extends KernelVertex { |
11 | constructor (opts) { |
12 | super(opts) |
13 | if (opts.root) { |
14 | this.set(identityAddress.toArray(), new PrecomileVertex(Precompiles.identity)) |
15 | this.set(meteringAddress.toArray(), new PrecomileVertex(Precompiles.meteringInjector)) |
16 | this.set(transcompilerAddress.toArray(), new PrecomileVertex(Precompiles.transcompiler)) |
17 | this.kernel = new Kernel({state: this}) |
18 | } |
19 | } |
20 | } |
21 | |
22 | class PrecomileVertex extends KernelVertex { |
23 | /** |
24 | * Creates a Vertex for precomiles. This will alwasy return false when hashed |
25 | * so that its contents will never be stored in the merkle trie run serialized |
26 | */ |
27 | constructor (precomiled) { |
28 | super() |
29 | this.kernel = precomiled |
30 | } |
31 | |
32 | hash () { |
33 | return false |
34 | } |
35 | } |
36 | |
37 | // detects the correct kernel to load given some code |
38 | KernelVertex.codeHandler = (code) => { |
39 | return KernelVertex['default'] |
40 | } |
41 | |
42 | KernelVertex.codeHandles = { |
43 | 'default': Kernel |
44 | } |
45 | |
46 | // KernelVertex.linkHander = (link) => { |
47 | // } |
48 | |
49 | // KernelVertex.linkHanders = { |
50 | // } |
51 |
Built with git-ssb-web