-
Notifications
You must be signed in to change notification settings - Fork 95
/
feat_sender.go
53 lines (41 loc) · 1.29 KB
/
feat_sender.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
package iotago
import (
"cmp"
"github.com/iotaledger/hive.go/serializer/v2"
)
// SenderFeature is a feature which associates an output
// with a sender address. The sender address needs to be unlocked in the transaction
// for the SenderFeature to be valid.
type SenderFeature struct {
Address Address `serix:""`
}
func (s *SenderFeature) Clone() Feature {
return &SenderFeature{Address: s.Address.Clone()}
}
func (s *SenderFeature) StorageScore(storageScoreStruct *StorageScoreStructure, f StorageScoreFunc) StorageScore {
if f != nil {
return f(storageScoreStruct)
}
return s.Address.StorageScore(storageScoreStruct, nil)
}
func (s *SenderFeature) WorkScore(_ *WorkScoreParameters) (WorkScore, error) {
// we do not need to charge for a signature check here as this is covered by the unlock that must be provided.
return 0, nil
}
func (s *SenderFeature) Compare(other Feature) int {
return cmp.Compare(s.Type(), other.Type())
}
func (s *SenderFeature) Equal(other Feature) bool {
otherFeat, is := other.(*SenderFeature)
if !is {
return false
}
return s.Address.Equal(otherFeat.Address)
}
func (s *SenderFeature) Type() FeatureType {
return FeatureSender
}
func (s *SenderFeature) Size() int {
// FeatureType + Address
return serializer.SmallTypeDenotationByteSize + s.Address.Size()
}