Skip to content

Commit 5984187

Browse files
authored
Merge pull request #428 from multiversx/shard-trigger-v3
Add shard trigger registry v3
2 parents a053bc6 + 2b266c6 commit 5984187

File tree

4 files changed

+759
-47
lines changed

4 files changed

+759
-47
lines changed

data/block/trigger.go

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,100 @@ func (strV2 *ShardTriggerRegistryV2) SetEpochStartHeaderHandler(epochStartHeader
196196
return nil
197197
}
198198

199+
// GetEpochStartHeaderHandler returns the epoch start headerHandler
200+
func (strV3 *ShardTriggerRegistryV3) GetEpochStartHeaderHandler() data.HeaderHandler {
201+
if strV3 == nil {
202+
return nil
203+
}
204+
return strV3.GetEpochStartShardHeader()
205+
}
206+
207+
// SetIsEpochStart sets the isEpochStart flag
208+
func (strV3 *ShardTriggerRegistryV3) SetIsEpochStart(isEpochStart bool) error {
209+
if strV3 == nil {
210+
return data.ErrNilPointerReceiver
211+
}
212+
strV3.IsEpochStart = isEpochStart
213+
return nil
214+
}
215+
216+
// SetNewEpochHeaderReceived sets the neeEpochHeaderReceived flag
217+
func (strV3 *ShardTriggerRegistryV3) SetNewEpochHeaderReceived(newEpochHeaderReceived bool) error {
218+
if strV3 == nil {
219+
return data.ErrNilPointerReceiver
220+
}
221+
strV3.NewEpochHeaderReceived = newEpochHeaderReceived
222+
return nil
223+
}
224+
225+
// SetEpoch sets the epoch
226+
func (strV3 *ShardTriggerRegistryV3) SetEpoch(epoch uint32) error {
227+
if strV3 == nil {
228+
return data.ErrNilPointerReceiver
229+
}
230+
strV3.Epoch = epoch
231+
return nil
232+
}
233+
234+
// SetMetaEpoch sets the metaChain epoch
235+
func (strV3 *ShardTriggerRegistryV3) SetMetaEpoch(metaEpoch uint32) error {
236+
if strV3 == nil {
237+
return data.ErrNilPointerReceiver
238+
}
239+
strV3.MetaEpoch = metaEpoch
240+
return nil
241+
}
242+
243+
// SetCurrentRoundIndex sets the current round index
244+
func (strV3 *ShardTriggerRegistryV3) SetCurrentRoundIndex(roundIndex int64) error {
245+
if strV3 == nil {
246+
return data.ErrNilPointerReceiver
247+
}
248+
strV3.CurrentRoundIndex = roundIndex
249+
return nil
250+
}
251+
252+
// SetEpochStartRound sets the epoch start round
253+
func (strV3 *ShardTriggerRegistryV3) SetEpochStartRound(startRound uint64) error {
254+
if strV3 == nil {
255+
return data.ErrNilPointerReceiver
256+
}
257+
strV3.EpochStartRound = startRound
258+
return nil
259+
}
260+
261+
// SetEpochFinalityAttestingRound sets the epoch finality attesting round
262+
func (strV3 *ShardTriggerRegistryV3) SetEpochFinalityAttestingRound(finalityAttestingRound uint64) error {
263+
if strV3 == nil {
264+
return data.ErrNilPointerReceiver
265+
}
266+
strV3.EpochFinalityAttestingRound = finalityAttestingRound
267+
return nil
268+
}
269+
270+
// SetEpochMetaBlockHash sets the epoch metaChain block hash
271+
func (strV3 *ShardTriggerRegistryV3) SetEpochMetaBlockHash(epochMetaBlockHash []byte) error {
272+
if strV3 == nil {
273+
return data.ErrNilPointerReceiver
274+
}
275+
strV3.EpochMetaBlockHash = epochMetaBlockHash
276+
return nil
277+
}
278+
279+
// SetEpochStartHeaderHandler sets the epoch start header
280+
func (strV3 *ShardTriggerRegistryV3) SetEpochStartHeaderHandler(epochStartHeaderHandler data.HeaderHandler) error {
281+
if strV3 == nil {
282+
return data.ErrNilPointerReceiver
283+
}
284+
285+
var ok bool
286+
strV3.EpochStartShardHeader, ok = epochStartHeaderHandler.(*HeaderV3)
287+
if !ok {
288+
return data.ErrInvalidTypeAssertion
289+
}
290+
return nil
291+
}
292+
199293
// GetEpochChangeProposed returns false for legacy meta registry
200294
func (m *MetaTriggerRegistry) GetEpochChangeProposed() bool {
201295
return false

0 commit comments

Comments
 (0)