-
Notifications
You must be signed in to change notification settings - Fork 1
/
snapshot_types.go
65 lines (55 loc) · 1.52 KB
/
snapshot_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package silkworm_go
import "unsafe"
type MemoryMappedRegion struct {
FilePath string
DataHandle unsafe.Pointer
Size int64
}
type MappedHeaderSnapshot struct {
Segment *MemoryMappedRegion
IdxHeaderHash *MemoryMappedRegion
}
type MappedBodySnapshot struct {
Segment *MemoryMappedRegion
IdxBodyNumber *MemoryMappedRegion
}
type MappedTxnSnapshot struct {
Segment *MemoryMappedRegion
IdxTxnHash *MemoryMappedRegion
IdxTxnHash2BlockNum *MemoryMappedRegion
}
type MappedChainSnapshot struct {
Headers *MappedHeaderSnapshot
Bodies *MappedBodySnapshot
Txs *MappedTxnSnapshot
}
func NewMemoryMappedRegion(filePath string, dataHandle unsafe.Pointer, size int64) *MemoryMappedRegion {
region := &MemoryMappedRegion{
FilePath: filePath,
DataHandle: dataHandle,
Size: size,
}
return region
}
func NewMappedHeaderSnapshot(segment, idxHeaderHash *MemoryMappedRegion) *MappedHeaderSnapshot {
snapshot := &MappedHeaderSnapshot{
Segment: segment,
IdxHeaderHash: idxHeaderHash,
}
return snapshot
}
func NewMappedBodySnapshot(segment, idxBodyNumber *MemoryMappedRegion) *MappedBodySnapshot {
snapshot := &MappedBodySnapshot{
Segment: segment,
IdxBodyNumber: idxBodyNumber,
}
return snapshot
}
func NewMappedTxnSnapshot(segment, idxTxnHash, idxTxnHash2BlockNum *MemoryMappedRegion) *MappedTxnSnapshot {
snapshot := &MappedTxnSnapshot{
Segment: segment,
IdxTxnHash: idxTxnHash,
IdxTxnHash2BlockNum: idxTxnHash2BlockNum,
}
return snapshot
}