-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsovereignChainHeader.go
More file actions
889 lines (697 loc) · 21.8 KB
/
Copy pathsovereignChainHeader.go
File metadata and controls
889 lines (697 loc) · 21.8 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. sovereignChainHeader.proto
package block
import (
"fmt"
"math/big"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/data"
"github.com/multiversx/mx-chain-core-go/data/headerVersionData"
)
// GetAdditionalData returns nil for the sovereign chain header
func (sch *SovereignChainHeader) GetAdditionalData() headerVersionData.HeaderAdditionalData {
return nil
}
// HasScheduledMiniBlocks returns false for the sovereign chain header
func (sch *SovereignChainHeader) HasScheduledMiniBlocks() bool {
return false
}
// SetScheduledRootHash does nothing and returns nil for the sovereign chain header
func (sch *SovereignChainHeader) SetScheduledRootHash(_ []byte) error {
return nil
}
// SetAdditionalData does nothing and returns nil for the sovereign chain header
func (sch *SovereignChainHeader) SetAdditionalData(_ headerVersionData.HeaderAdditionalData) error {
return nil
}
// ShallowClone returns a clone of the object
func (sch *SovereignChainHeader) ShallowClone() data.HeaderHandler {
if sch == nil || sch.Header == nil {
return nil
}
internalHeaderCopy := *sch.Header
headerCopy := *sch
headerCopy.Header = &internalHeaderCopy
if !check.IfNil(sch.OutGoingMiniBlockHeader) {
internalOutGoingMbHeader := *sch.OutGoingMiniBlockHeader
headerCopy.OutGoingMiniBlockHeader = &internalOutGoingMbHeader
}
return &headerCopy
}
// GetShardID returns internal header shard id
func (sch *SovereignChainHeader) GetShardID() uint32 {
if sch == nil {
return 0
}
return sch.Header.ShardID
}
// GetNonce returns the header nonce
func (sch *SovereignChainHeader) GetNonce() uint64 {
if sch == nil {
return 0
}
return sch.Header.GetNonce()
}
// GetEpoch returns the header epoch
func (sch *SovereignChainHeader) GetEpoch() uint32 {
if sch == nil {
return 0
}
return sch.Header.GetEpoch()
}
// GetRound returns the header round
func (sch *SovereignChainHeader) GetRound() uint64 {
if sch == nil {
return 0
}
return sch.Header.GetRound()
}
// GetRootHash returns the header root hash
func (sch *SovereignChainHeader) GetRootHash() []byte {
if sch == nil {
return nil
}
return sch.Header.GetRootHash()
}
// GetPrevHash returns the header previous header hash
func (sch *SovereignChainHeader) GetPrevHash() []byte {
if sch == nil {
return nil
}
return sch.Header.GetPrevHash()
}
// GetPrevRandSeed returns the header previous random seed
func (sch *SovereignChainHeader) GetPrevRandSeed() []byte {
if sch == nil {
return nil
}
return sch.Header.GetPrevRandSeed()
}
// GetRandSeed returns the header random seed
func (sch *SovereignChainHeader) GetRandSeed() []byte {
if sch == nil {
return nil
}
return sch.Header.GetRandSeed()
}
// GetPubKeysBitmap returns the header public key bitmap for the aggregated signatures
func (sch *SovereignChainHeader) GetPubKeysBitmap() []byte {
if sch == nil {
return nil
}
return sch.Header.GetPubKeysBitmap()
}
// GetSignature returns the header aggregated signature
func (sch *SovereignChainHeader) GetSignature() []byte {
if sch == nil {
return nil
}
return sch.Header.GetSignature()
}
// GetLeaderSignature returns the leader signature on top of the finalized (signed) header
func (sch *SovereignChainHeader) GetLeaderSignature() []byte {
if sch == nil {
return nil
}
return sch.Header.GetLeaderSignature()
}
// GetChainID returns the chain ID
func (sch *SovereignChainHeader) GetChainID() []byte {
if sch == nil {
return nil
}
return sch.Header.GetChainID()
}
// GetSoftwareVersion returns the header software version
func (sch *SovereignChainHeader) GetSoftwareVersion() []byte {
if sch == nil {
return nil
}
return sch.Header.GetSoftwareVersion()
}
// GetTimeStamp returns the header timestamp
func (sch *SovereignChainHeader) GetTimeStamp() uint64 {
if sch == nil {
return 0
}
return sch.Header.GetTimeStamp()
}
// GetTxCount returns the number of txs included in the block
func (sch *SovereignChainHeader) GetTxCount() uint32 {
if sch == nil {
return 0
}
return sch.Header.GetTxCount()
}
// GetReceiptsHash returns the header receipt hash
func (sch *SovereignChainHeader) GetReceiptsHash() []byte {
if sch == nil {
return nil
}
return sch.Header.GetReceiptsHash()
}
// GetAccumulatedFees returns the block accumulated fees
func (sch *SovereignChainHeader) GetAccumulatedFees() *big.Int {
if sch == nil {
return nil
}
return sch.Header.GetAccumulatedFees()
}
// GetDeveloperFees returns the block developer fees
func (sch *SovereignChainHeader) GetDeveloperFees() *big.Int {
if sch == nil {
return nil
}
return sch.Header.GetDeveloperFees()
}
// GetReserved returns the reserved field
func (sch *SovereignChainHeader) GetReserved() []byte {
if sch == nil {
return nil
}
return sch.Header.GetReserved()
}
// GetMetaBlockHashes returns the metaBlock hashes
func (sch *SovereignChainHeader) GetMetaBlockHashes() [][]byte {
if sch == nil {
return nil
}
return sch.Header.GetMetaBlockHashes()
}
// GetEpochStartMetaHash returns the epoch start metaBlock hash
func (sch *SovereignChainHeader) GetEpochStartMetaHash() []byte {
if sch == nil {
return nil
}
return sch.Header.GetEpochStartMetaHash()
}
// SetNonce sets the header nonce
func (sch *SovereignChainHeader) SetNonce(n uint64) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetNonce(n)
}
// SetEpoch sets the header epoch
func (sch *SovereignChainHeader) SetEpoch(e uint32) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetEpoch(e)
}
// SetRound sets the header round
func (sch *SovereignChainHeader) SetRound(r uint64) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetRound(r)
}
// SetRootHash sets the root hash
func (sch *SovereignChainHeader) SetRootHash(rHash []byte) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetRootHash(rHash)
}
// SetPrevHash sets the previous hash
func (sch *SovereignChainHeader) SetPrevHash(pvHash []byte) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetPrevHash(pvHash)
}
// SetPrevRandSeed sets the previous random seed
func (sch *SovereignChainHeader) SetPrevRandSeed(pvRandSeed []byte) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetPrevRandSeed(pvRandSeed)
}
// SetRandSeed sets the random seed
func (sch *SovereignChainHeader) SetRandSeed(randSeed []byte) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetRandSeed(randSeed)
}
// SetPubKeysBitmap sets the public key bitmap
func (sch *SovereignChainHeader) SetPubKeysBitmap(pkbm []byte) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetPubKeysBitmap(pkbm)
}
// SetSignature sets the header signature
func (sch *SovereignChainHeader) SetSignature(sg []byte) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetSignature(sg)
}
// SetLeaderSignature sets the leader's signature
func (sch *SovereignChainHeader) SetLeaderSignature(sg []byte) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetLeaderSignature(sg)
}
// SetChainID sets the chain ID on which this block is valid on
func (sch *SovereignChainHeader) SetChainID(chainID []byte) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetChainID(chainID)
}
// SetSoftwareVersion sets the software version of the header
func (sch *SovereignChainHeader) SetSoftwareVersion(version []byte) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetSoftwareVersion(version)
}
// SetTimeStamp sets the header timestamp
func (sch *SovereignChainHeader) SetTimeStamp(ts uint64) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetTimeStamp(ts)
}
// SetAccumulatedFees sets the accumulated fees in the header
func (sch *SovereignChainHeader) SetAccumulatedFees(value *big.Int) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetAccumulatedFees(value)
}
// SetDeveloperFees sets the developer fees in the header
func (sch *SovereignChainHeader) SetDeveloperFees(value *big.Int) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetDeveloperFees(value)
}
// SetTxCount sets the transaction count of the block associated with this header
func (sch *SovereignChainHeader) SetTxCount(txCount uint32) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetTxCount(txCount)
}
// SetShardID sets the shard id
func (sch *SovereignChainHeader) SetShardID(shardID uint32) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetShardID(shardID)
}
// SetValidatorStatsRootHash sets the root hash for the validator statistics trie
func (sch *SovereignChainHeader) SetValidatorStatsRootHash(rootHash []byte) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
sch.ValidatorStatsRootHash = rootHash
return nil
}
// SetExtendedShardHeaderHashes sets the extended shard header hashes
func (sch *SovereignChainHeader) SetExtendedShardHeaderHashes(hdrHashes [][]byte) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
sch.ExtendedShardHeaderHashes = hdrHashes
return nil
}
// GetMiniBlockHeadersWithDst returns the miniblocks headers hashes for the destination shard
func (sch *SovereignChainHeader) GetMiniBlockHeadersWithDst(destId uint32) map[string]uint32 {
if sch == nil {
return nil
}
return sch.Header.GetMiniBlockHeadersWithDst(destId)
}
// GetOrderedCrossMiniblocksWithDst gets all the cross miniblocks with the given destination shard ID, ordered in a
// chronological way, taking into consideration the round in which they were created/executed in the sender shard
func (sch *SovereignChainHeader) GetOrderedCrossMiniblocksWithDst(destId uint32) []*data.MiniBlockInfo {
if sch == nil {
return nil
}
return sch.Header.GetOrderedCrossMiniblocksWithDst(destId)
}
// GetMiniBlockHeadersHashes gets the miniBlock hashes
func (sch *SovereignChainHeader) GetMiniBlockHeadersHashes() [][]byte {
if sch == nil {
return nil
}
return sch.Header.GetMiniBlockHeadersHashes()
}
// MapMiniBlockHashesToShards gets the map of miniBlock hashes and sender IDs
func (sch *SovereignChainHeader) MapMiniBlockHashesToShards() map[string]uint32 {
if sch == nil {
return nil
}
return sch.Header.MapMiniBlockHashesToShards()
}
// IsInterfaceNil returns true if there is no value under the interface
func (sch *SovereignChainHeader) IsInterfaceNil() bool {
return sch == nil
}
// IsStartOfEpochBlock returns false for the sovereign chain header
func (sch *SovereignChainHeader) IsStartOfEpochBlock() bool {
if sch == nil {
return false
}
return sch.IsStartOfEpoch
}
// GetBlockBodyTypeInt32 returns the blockBody type as int32
func (sch *SovereignChainHeader) GetBlockBodyTypeInt32() int32 {
if sch == nil {
return -1
}
return sch.Header.GetBlockBodyTypeInt32()
}
// GetMiniBlockHeaderHandlers returns the miniBlock headers as an array of miniBlock header handlers
func (sch *SovereignChainHeader) GetMiniBlockHeaderHandlers() []data.MiniBlockHeaderHandler {
if sch == nil {
return nil
}
return sch.Header.GetMiniBlockHeaderHandlers()
}
// SetMiniBlockHeaderHandlers sets the miniBlock headers from the given miniBlock header handlers
func (sch *SovereignChainHeader) SetMiniBlockHeaderHandlers(mbHeaderHandlers []data.MiniBlockHeaderHandler) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetMiniBlockHeaderHandlers(mbHeaderHandlers)
}
// SetReceiptsHash sets the receipts hash
func (sch *SovereignChainHeader) SetReceiptsHash(hash []byte) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetReceiptsHash(hash)
}
// SetMetaBlockHashes sets the metaBlock hashes
func (sch *SovereignChainHeader) SetMetaBlockHashes(hashes [][]byte) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetMetaBlockHashes(hashes)
}
// SetEpochStartMetaHash sets the epoch start metaBlock hash
func (sch *SovereignChainHeader) SetEpochStartMetaHash(hash []byte) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetEpochStartMetaHash(hash)
}
// HasScheduledSupport returns false for the sovereign chain header
func (sch *SovereignChainHeader) HasScheduledSupport() bool {
return false
}
// ValidateHeaderVersion does extra validation for the header version
func (sch *SovereignChainHeader) ValidateHeaderVersion() error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return nil
}
// CheckFieldsForNil checks a predefined set of fields for nil values
func (sch *SovereignChainHeader) CheckFieldsForNil() error {
if sch == nil {
return data.ErrNilPointerReceiver
}
err := sch.Header.CheckFieldsForNil()
if err != nil {
return err
}
if sch.ValidatorStatsRootHash == nil {
return fmt.Errorf("%w in sch.ValidatorStatsRootHash", data.ErrNilValue)
}
return nil
}
// GetOutGoingMiniBlockHeaderHandler returns the outgoing mini block header
func (sch *SovereignChainHeader) GetOutGoingMiniBlockHeaderHandler() data.OutGoingMiniBlockHeaderHandler {
if sch == nil {
return nil
}
return sch.GetOutGoingMiniBlockHeader()
}
// SetOutGoingMiniBlockHeaderHandler returns the outgoing mini block header
func (sch *SovereignChainHeader) SetOutGoingMiniBlockHeaderHandler(mbHeader data.OutGoingMiniBlockHeaderHandler) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
if check.IfNil(mbHeader) {
sch.OutGoingMiniBlockHeader = nil
return nil
}
sch.OutGoingMiniBlockHeader = &OutGoingMiniBlockHeader{
Hash: mbHeader.GetHash(),
OutGoingOperationsHash: mbHeader.GetOutGoingOperationsHash(),
AggregatedSignatureOutGoingOperations: mbHeader.GetAggregatedSignatureOutGoingOperations(),
LeaderSignatureOutGoingOperations: mbHeader.GetLeaderSignatureOutGoingOperations(),
}
return nil
}
// SetBlockBodyTypeInt32 sets the blockBodyType in the header
func (sch *SovereignChainHeader) SetBlockBodyTypeInt32(blockBodyType int32) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return sch.Header.SetBlockBodyTypeInt32(blockBodyType)
}
// SetStartOfEpochHeader sets the bool flag for epoch start header
func (sch *SovereignChainHeader) SetStartOfEpochHeader() error {
if sch == nil {
return data.ErrNilPointerReceiver
}
sch.IsStartOfEpoch = true
return nil
}
// SetDevFeesInEpoch sets the developer fees in the header
func (sch *SovereignChainHeader) SetDevFeesInEpoch(value *big.Int) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
if value == nil {
return data.ErrInvalidValue
}
if sch.DevFeesInEpoch == nil {
sch.DevFeesInEpoch = big.NewInt(0)
}
sch.DevFeesInEpoch.Set(value)
return nil
}
// SetAccumulatedFeesInEpoch sets the epoch accumulated fees in the header
func (sch *SovereignChainHeader) SetAccumulatedFeesInEpoch(value *big.Int) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
if value == nil {
return data.ErrInvalidValue
}
if sch.AccumulatedFeesInEpoch == nil {
sch.AccumulatedFeesInEpoch = big.NewInt(0)
}
sch.AccumulatedFeesInEpoch.Set(value)
return nil
}
// GetEpochStartHandler returns epoch start header handler as for metachain, but with last finalized headers from main chain, if found.
func (sch *SovereignChainHeader) GetEpochStartHandler() data.EpochStartHandler {
if sch == nil {
return nil
}
return &sch.EpochStart
}
// GetLastFinalizedCrossChainHeaderHandler returns the last finalized cross chain header data
func (sch *SovereignChainHeader) GetLastFinalizedCrossChainHeaderHandler() data.EpochStartChainDataHandler {
if sch == nil {
return nil
}
return &sch.EpochStart.LastFinalizedCrossChainHeader
}
// SetLastFinalizedCrossChainHeaderHandler sets the last finalized cross chain header handler
func (sch *SovereignChainHeader) SetLastFinalizedCrossChainHeaderHandler(crossChainData data.EpochStartChainDataHandler) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
sch.EpochStart.LastFinalizedCrossChainHeader = EpochStartCrossChainData{
ShardID: crossChainData.GetShardID(),
Epoch: crossChainData.GetEpoch(),
Round: crossChainData.GetRound(),
Nonce: crossChainData.GetNonce(),
HeaderHash: crossChainData.GetHeaderHash(),
}
return nil
}
// GetShardInfoHandlers returns empty slice
func (sch *SovereignChainHeader) GetShardInfoHandlers() []data.ShardDataHandler {
if sch == nil {
return nil
}
return make([]data.ShardDataHandler, 0)
}
// SetShardInfoHandlers does nothing
func (sch *SovereignChainHeader) SetShardInfoHandlers(_ []data.ShardDataHandler) error {
if sch == nil {
return data.ErrNilPointerReceiver
}
return nil
}
// SetHash returns the hash
func (omb *OutGoingMiniBlockHeader) SetHash(hash []byte) error {
if omb == nil {
return data.ErrNilPointerReceiver
}
omb.Hash = hash
return nil
}
// SetOutGoingOperationsHash returns the outgoing operations hash
func (omb *OutGoingMiniBlockHeader) SetOutGoingOperationsHash(hash []byte) error {
if omb == nil {
return data.ErrNilPointerReceiver
}
omb.OutGoingOperationsHash = hash
return nil
}
// SetLeaderSignatureOutGoingOperations returns the leader signature
func (omb *OutGoingMiniBlockHeader) SetLeaderSignatureOutGoingOperations(sig []byte) error {
if omb == nil {
return data.ErrNilPointerReceiver
}
omb.LeaderSignatureOutGoingOperations = sig
return nil
}
// SetAggregatedSignatureOutGoingOperations returns the aggregated signature
func (omb *OutGoingMiniBlockHeader) SetAggregatedSignatureOutGoingOperations(sig []byte) error {
if omb == nil {
return data.ErrNilPointerReceiver
}
omb.AggregatedSignatureOutGoingOperations = sig
return nil
}
// IsInterfaceNil checks if the underlying interface is nil
func (omb *OutGoingMiniBlockHeader) IsInterfaceNil() bool {
return omb == nil
}
// SetShardID sets the epoch start shardID
func (essd *EpochStartCrossChainData) SetShardID(shardID uint32) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
essd.ShardID = shardID
return nil
}
// SetEpoch sets the epoch start epoch
func (essd *EpochStartCrossChainData) SetEpoch(epoch uint32) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
essd.Epoch = epoch
return nil
}
// SetRound sets the epoch start round
func (essd *EpochStartCrossChainData) SetRound(round uint64) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
essd.Round = round
return nil
}
// SetNonce sets the epoch start nonce
func (essd *EpochStartCrossChainData) SetNonce(nonce uint64) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
essd.Nonce = nonce
return nil
}
// SetHeaderHash sets the epoch start header hash
func (essd *EpochStartCrossChainData) SetHeaderHash(hash []byte) error {
if essd == nil {
return data.ErrNilPointerReceiver
}
essd.HeaderHash = hash
return nil
}
// GetRootHash returns nothing
func (essd *EpochStartCrossChainData) GetRootHash() []byte {
return nil
}
// GetFirstPendingMetaBlock returns nothing
func (essd *EpochStartCrossChainData) GetFirstPendingMetaBlock() []byte {
return nil
}
// GetLastFinishedMetaBlock returns nothing
func (essd *EpochStartCrossChainData) GetLastFinishedMetaBlock() []byte {
return nil
}
// GetPendingMiniBlockHeaderHandlers returns empty slice
func (essd *EpochStartCrossChainData) GetPendingMiniBlockHeaderHandlers() []data.MiniBlockHeaderHandler {
return make([]data.MiniBlockHeaderHandler, 0)
}
// SetRootHash does nothing
func (essd *EpochStartCrossChainData) SetRootHash([]byte) error {
return nil
}
// SetFirstPendingMetaBlock does nothing
func (essd *EpochStartCrossChainData) SetFirstPendingMetaBlock([]byte) error {
return nil
}
// SetLastFinishedMetaBlock does nothing
func (essd *EpochStartCrossChainData) SetLastFinishedMetaBlock([]byte) error {
return nil
}
// SetPendingMiniBlockHeaders does nothing
func (essd *EpochStartCrossChainData) SetPendingMiniBlockHeaders(_ []data.MiniBlockHeaderHandler) error {
return nil
}
// GetLastFinalizedHeaderHandlers returns last cross main chain finalized header in a slice w.r.t to the interface
func (m *EpochStartSovereign) GetLastFinalizedHeaderHandlers() []data.EpochStartShardDataHandler {
if m == nil {
return nil
}
epochStartShardData := make([]data.EpochStartShardDataHandler, 0)
if m.LastFinalizedCrossChainHeader.ShardID == core.MainChainShardId {
epochStartShardData = append(epochStartShardData, &m.LastFinalizedCrossChainHeader)
}
return epochStartShardData
}
// GetEconomicsHandler returns the economics
func (m *EpochStartSovereign) GetEconomicsHandler() data.EconomicsHandler {
if m == nil {
return nil
}
return &m.Economics
}
// SetLastFinalizedHeaders sets epoch start data for main chain chain only
func (m *EpochStartSovereign) SetLastFinalizedHeaders(epochStartShardDataHandlers []data.EpochStartShardDataHandler) error {
if m == nil {
return data.ErrNilPointerReceiver
}
for _, epochStartShardData := range epochStartShardDataHandlers {
if epochStartShardData.GetShardID() == core.MainChainShardId {
m.LastFinalizedCrossChainHeader = EpochStartCrossChainData{
ShardID: epochStartShardData.GetShardID(),
Epoch: epochStartShardData.GetEpoch(),
Round: epochStartShardData.GetRound(),
Nonce: epochStartShardData.GetNonce(),
HeaderHash: epochStartShardData.GetHeaderHash(),
}
}
}
return nil
}
// SetEconomics sets economics
func (m *EpochStartSovereign) SetEconomics(economicsHandler data.EconomicsHandler) error {
if m == nil {
return data.ErrNilPointerReceiver
}
ec, ok := economicsHandler.(*Economics)
if !ok {
return data.ErrInvalidTypeAssertion
}
if ec == nil {
return data.ErrNilPointerDereference
}
m.Economics = *ec
return nil
}