-
Notifications
You must be signed in to change notification settings - Fork 95
/
input_block_issuance_credit.go
49 lines (38 loc) · 1.28 KB
/
input_block_issuance_credit.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
package iotago
import (
"bytes"
"cmp"
"github.com/iotaledger/hive.go/serializer/v2"
)
type BlockIssuanceCreditInput struct {
AccountID AccountID `serix:""`
}
func (b *BlockIssuanceCreditInput) Clone() ContextInput {
return &BlockIssuanceCreditInput{
AccountID: b.AccountID,
}
}
func (b *BlockIssuanceCreditInput) Type() ContextInputType {
return ContextInputBlockIssuanceCredit
}
func (b *BlockIssuanceCreditInput) IsReadOnly() bool {
return true
}
func (b *BlockIssuanceCreditInput) Size() int {
// ContextInputType + AccountID
return serializer.OneByte + AccountIDLength
}
func (b *BlockIssuanceCreditInput) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error) {
// context inputs require invocation of informations in the node, so requires extra work.
return workScoreParameters.ContextInput, nil
}
func (b *BlockIssuanceCreditInput) Compare(other ContextInput) int {
typeCompare := cmp.Compare(b.Type(), other.Type())
if typeCompare != 0 {
return typeCompare
}
// Causes any two BIC Inputs with the same account ID to be considered duplicates.
//nolint:forcetypeassert // we can safely assume that this is a BlockIssuanceCreditInput
otherBICInput := other.(*BlockIssuanceCreditInput)
return bytes.Compare(b.AccountID[:], otherBICInput.AccountID[:])
}