/
epochStartShardDataHandler.go
139 lines (104 loc) · 3.28 KB
/
epochStartShardDataHandler.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package block
import "github.com/ThotaGopichandThota/gn-core2/data"
// GetPendingMiniBlockHeaderHandlers returns the pending miniBlock header handlers
func (essd *EpochStartShardData) GetPendingMiniBlockHeaderHandlers() []data.MiniBlockHeaderHandler {
if essd == nil {
return nil
}
pendingMbHeaderHandlers := make([]data.MiniBlockHeaderHandler, len(essd.PendingMiniBlockHeaders))
for i := range essd.PendingMiniBlockHeaders {
pendingMbHeaderHandlers[i] = &essd.PendingMiniBlockHeaders[i]
}
return pendingMbHeaderHandlers
}
// SetShardID sets the epoch start shardData shardID
func (essd *EpochStartShardData) SetShardID(shardID uint32) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
essd.ShardID = shardID
return nil
}
// SetEpoch sets the epoch start shardData epoch
func (essd *EpochStartShardData) SetEpoch(epoch uint32) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
essd.Epoch = epoch
return nil
}
// SetRound sets the epoch start shardData round
func (essd *EpochStartShardData) SetRound(round uint64) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
essd.Round = round
return nil
}
// SetNonce sets the epoch start shardData nonce
func (essd *EpochStartShardData) SetNonce(nonce uint64) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
essd.Nonce = nonce
return nil
}
// SetHeaderHash sets the epoch start shardData header hash
func (essd *EpochStartShardData) SetHeaderHash(hash []byte) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
essd.HeaderHash = hash
return nil
}
// SetRootHash sets the epoch start shardData root hash
func (essd *EpochStartShardData) SetRootHash(rootHash []byte) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
essd.RootHash = rootHash
return nil
}
// SetFirstPendingMetaBlock sets the epoch start shardData first pending metaBlock
func (essd *EpochStartShardData) SetFirstPendingMetaBlock(metaBlock []byte) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
essd.FirstPendingMetaBlock = metaBlock
return nil
}
// SetLastFinishedMetaBlock sets the epoch start shardData last finished metaBlock
func (essd *EpochStartShardData) SetLastFinishedMetaBlock(lastFinishedMetaBlock []byte) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
essd.LastFinishedMetaBlock = lastFinishedMetaBlock
return nil
}
// SetPendingMiniBlockHeaders sets the epoch start shardData pending miniBlock headers
func (essd *EpochStartShardData) SetPendingMiniBlockHeaders(miniBlockHeaderHandlers []data.MiniBlockHeaderHandler) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
pendingMiniBlockHeaders := make([]MiniBlockHeader, len(miniBlockHeaderHandlers))
for i := range miniBlockHeaderHandlers {
mbHeader, ok := miniBlockHeaderHandlers[i].(*MiniBlockHeader)
if !ok {
return data.ErrInvalidTypeAssertion
}
if mbHeader == nil {
return data.ErrNilPointerDereference
}
pendingMiniBlockHeaders[i] = *mbHeader
}
essd.PendingMiniBlockHeaders = pendingMiniBlockHeaders
return nil
}
// SetScheduledRootHash sets the scheduled root hash
func (essd *EpochStartShardData) SetScheduledRootHash(schRootHash []byte) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
essd.ScheduledRootHash = schRootHash
return nil
}