git ssb

0+

wanderer🌟 / js-primea-hypervisor



Tree: 7465ee54b512e6772d88465794c551333e42ecfe

Files: 7465ee54b512e6772d88465794c551333e42ecfe / deps / rootVertex.js

1475 bytesRaw
1const KernelVertex = require('./kernelVertex')
2const Kernel = require('../')
3const Precompiles = require('../precomiles/precompile.js')
4const Address = require('./address')
5
6const identityAddress = new Address('0x0000000000000000000000000000000000000004')
7const meteringAddress = new Address('0x000000000000000000000000000000000000000A')
8const transcompilerAddress = new Address('0x000000000000000000000000000000000000000B')
9
10module.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
22class 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
38KernelVertex.codeHandler = (code) => {
39 return KernelVertex['default']
40}
41
42KernelVertex.codeHandles = {
43 'default': Kernel
44}
45
46// KernelVertex.linkHander = (link) => {
47// }
48
49// KernelVertex.linkHanders = {
50// }
51

Built with git-ssb-web