-
Notifications
You must be signed in to change notification settings - Fork 151
/
unreferenced_block.go
46 lines (35 loc) · 1.07 KB
/
unreferenced_block.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
package storage
import (
"encoding/binary"
"github.com/iotaledger/hive.go/objectstorage"
iotago "github.com/iotaledger/iota.go/v3"
)
type UnreferencedBlock struct {
objectstorage.StorableObjectFlags
latestMilestoneIndex iotago.MilestoneIndex
blockID iotago.BlockID
}
func NewUnreferencedBlock(msIndex iotago.MilestoneIndex, blockID iotago.BlockID) *UnreferencedBlock {
return &UnreferencedBlock{
latestMilestoneIndex: msIndex,
blockID: blockID,
}
}
func (t *UnreferencedBlock) LatestMilestoneIndex() iotago.MilestoneIndex {
return t.latestMilestoneIndex
}
func (t *UnreferencedBlock) BlockID() iotago.BlockID {
return t.blockID
}
// ObjectStorage interface
func (t *UnreferencedBlock) Update(_ objectstorage.StorableObject) {
// do nothing, since the object is identical (consists of key only)
}
func (t *UnreferencedBlock) ObjectStorageKey() []byte {
key := make([]byte, 4)
binary.LittleEndian.PutUint32(key, t.latestMilestoneIndex)
return append(key, t.blockID[:]...)
}
func (t *UnreferencedBlock) ObjectStorageValue() []byte {
return nil
}