-
Notifications
You must be signed in to change notification settings - Fork 199
/
interceptedRewardTxDataFactory.go
68 lines (61 loc) · 2.29 KB
/
interceptedRewardTxDataFactory.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
66
67
68
package factory
import (
"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/ElrondNetwork/elrond-go-core/hashing"
"github.com/ElrondNetwork/elrond-go-core/marshal"
"github.com/ElrondNetwork/elrond-go/process"
"github.com/ElrondNetwork/elrond-go/process/rewardTransaction"
"github.com/ElrondNetwork/elrond-go/sharding"
)
var _ process.InterceptedDataFactory = (*interceptedRewardTxDataFactory)(nil)
type interceptedRewardTxDataFactory struct {
protoMarshalizer marshal.Marshalizer
hasher hashing.Hasher
pubkeyConverter core.PubkeyConverter
shardCoordinator sharding.Coordinator
}
// NewInterceptedRewardTxDataFactory creates an instance of interceptedRewardTxDataFactory
func NewInterceptedRewardTxDataFactory(argument *ArgInterceptedDataFactory) (*interceptedRewardTxDataFactory, error) {
if argument == nil {
return nil, process.ErrNilArgumentStruct
}
if check.IfNil(argument.CoreComponents) {
return nil, process.ErrNilCoreComponentsHolder
}
if check.IfNil(argument.CoreComponents.InternalMarshalizer()) {
return nil, process.ErrNilMarshalizer
}
if check.IfNil(argument.CoreComponents.TxMarshalizer()) {
return nil, process.ErrNilMarshalizer
}
if check.IfNil(argument.CoreComponents.Hasher()) {
return nil, process.ErrNilHasher
}
if check.IfNil(argument.CoreComponents.AddressPubKeyConverter()) {
return nil, process.ErrNilPubkeyConverter
}
if check.IfNil(argument.ShardCoordinator) {
return nil, process.ErrNilShardCoordinator
}
return &interceptedRewardTxDataFactory{
protoMarshalizer: argument.CoreComponents.InternalMarshalizer(),
hasher: argument.CoreComponents.Hasher(),
pubkeyConverter: argument.CoreComponents.AddressPubKeyConverter(),
shardCoordinator: argument.ShardCoordinator,
}, nil
}
// Create creates instances of InterceptedData by unmarshalling provided buffer
func (irtdf *interceptedRewardTxDataFactory) Create(buff []byte) (process.InterceptedData, error) {
return rewardTransaction.NewInterceptedRewardTransaction(
buff,
irtdf.protoMarshalizer,
irtdf.hasher,
irtdf.pubkeyConverter,
irtdf.shardCoordinator,
)
}
// IsInterfaceNil returns true if there is no value under the interface
func (irtdf *interceptedRewardTxDataFactory) IsInterfaceNil() bool {
return irtdf == nil
}