@@ -24,14 +24,22 @@ import (
24
24
25
25
const WasmSchemaVersion byte = 0x01
26
26
27
+ const WasmPrefixLen = 3
28
+
29
+ // WasmKeyLen = CompiledWasmCodePrefix + moduleHash
30
+ const WasmKeyLen = WasmPrefixLen + common .HashLength
31
+
32
+ type WasmPrefix = [WasmPrefixLen ]byte
33
+ type WasmKey = [WasmKeyLen ]byte
34
+
27
35
var (
28
36
wasmSchemaVersionKey = []byte ("WasmSchemaVersion" )
29
37
30
38
// 0x00 prefix to avoid conflicts when wasmdb is not separate database
31
- activatedAsmWavmPrefix = [] byte {0x00 , 'w' , 'w' } // (prefix, moduleHash) -> stylus module (wavm)
32
- activatedAsmArmPrefix = [] byte {0x00 , 'w' , 'r' } // (prefix, moduleHash) -> stylus asm for ARM system
33
- activatedAsmX86Prefix = [] byte {0x00 , 'w' , 'x' } // (prefix, moduleHash) -> stylus asm for x86 system
34
- activatedAsmHostPrefix = [] byte {0x00 , 'w' , 'h' } // (prefix, moduleHash) -> stylus asm for system other then ARM and x86
39
+ activatedAsmWavmPrefix = WasmPrefix {0x00 , 'w' , 'w' } // (prefix, moduleHash) -> stylus module (wavm)
40
+ activatedAsmArmPrefix = WasmPrefix {0x00 , 'w' , 'r' } // (prefix, moduleHash) -> stylus asm for ARM system
41
+ activatedAsmX86Prefix = WasmPrefix {0x00 , 'w' , 'x' } // (prefix, moduleHash) -> stylus asm for x86 system
42
+ activatedAsmHostPrefix = WasmPrefix {0x00 , 'w' , 'h' } // (prefix, moduleHash) -> stylus asm for system other then ARM and x86
35
43
)
36
44
37
45
func DeprecatedPrefixesV0 () (keyPrefixes [][]byte , keyLength int ) {
@@ -42,15 +50,10 @@ func DeprecatedPrefixesV0() (keyPrefixes [][]byte, keyLength int) {
42
50
}, 3 + 32
43
51
}
44
52
45
- // WasmKeyLen = CompiledWasmCodePrefix + moduleHash
46
- const WasmKeyLen = 3 + common .HashLength
47
-
48
- type WasmKey = [WasmKeyLen ]byte
49
-
50
53
// key = prefix + moduleHash
51
- func activatedKey (prefix [] byte , moduleHash common.Hash ) WasmKey {
54
+ func activatedKey (prefix WasmPrefix , moduleHash common.Hash ) WasmKey {
52
55
var key WasmKey
53
- copy (key [:3 ], prefix )
54
- copy (key [3 :], moduleHash [:])
56
+ copy (key [:WasmPrefixLen ], prefix [:] )
57
+ copy (key [WasmPrefixLen :], moduleHash [:])
55
58
return key
56
59
}
0 commit comments