-
Notifications
You must be signed in to change notification settings - Fork 95
/
input_commitment.go
41 lines (32 loc) · 1 KB
/
input_commitment.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
package iotago
import (
"cmp"
"github.com/iotaledger/hive.go/serializer/v2"
)
type CommitmentInput struct {
CommitmentID CommitmentID `serix:""`
}
func (c *CommitmentInput) Clone() ContextInput {
return &CommitmentInput{
CommitmentID: c.CommitmentID,
}
}
func (c *CommitmentInput) Type() ContextInputType {
return ContextInputCommitment
}
func (c *CommitmentInput) IsReadOnly() bool {
return true
}
func (c *CommitmentInput) Size() int {
// ContextInputType + CommitmentID
return serializer.OneByte + CommitmentIDLength
}
func (c *CommitmentInput) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error) {
// context inputs require invocation of informations in the node, so requires extra work.
return workScoreParameters.ContextInput, nil
}
func (c *CommitmentInput) Compare(other ContextInput) int {
// At most one commitment input is allowed.
// If we compare based only on the type, we achieve lexical order and "at most one" semantics.
return cmp.Compare(c.Type(), other.Type())
}