Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/sovereign #184

Open
wants to merge 164 commits into
base: rc/v1.7.next1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
4100146
added new interface for simple header
sasurobert Sep 12, 2022
58118f9
Merge branch 'rc/2022-july' into simple-header-interfaces
sasurobert Sep 12, 2022
f352042
new header proto
sasurobert Sep 12, 2022
8abc09e
new header proto
sasurobert Sep 12, 2022
693d2e1
go generate headerWithValidatorStats.pb.go
raduchis Sep 12, 2022
b048d64
new header proto
sasurobert Sep 12, 2022
76a58c4
new header proto and implementation
sasurobert Sep 13, 2022
6b60682
Merge branch 'rc/2022-july' into simple-header-interfaces
iulianpascalau Sep 13, 2022
ca1525b
new header proto and implementation
sasurobert Sep 13, 2022
bbbcc96
Merge remote-tracking branch 'origin/simple-header-interfaces' into s…
sasurobert Sep 13, 2022
9abb87c
new header proto and implementation
sasurobert Sep 14, 2022
dfff257
new interface and set function
sasurobert Sep 14, 2022
4b9858c
Merge remote-tracking branch 'origin/rc/v1.4.0' into simple-header-in…
sasurobert Oct 3, 2022
9437052
Merge branch 'rc/v1.4.0' into simple-header-interfaces
SebastianMarian Nov 25, 2022
a0169d5
Merge branch 'rc/v1.4.0' into simple-header-interfaces
SebastianMarian Dec 5, 2022
ee4469a
Merge branch 'rc/v1.4.0' into simple-header-interfaces
SebastianMarian Dec 21, 2022
15e6dae
Merge branch 'rc/v1.4.0' into simple-header-interfaces
SebastianMarian Jan 16, 2023
76a8d82
* Updated go.mod
SebastianMarian Jan 16, 2023
c9fa8b1
* Updated go.mod
SebastianMarian Jan 16, 2023
9ebe0c9
Merge branch 'feat/rebranding' into simple-header-interfaces
SebastianMarian Jan 16, 2023
846af71
* Fixed imports
SebastianMarian Jan 16, 2023
f8302bb
* Fixed go:generate
SebastianMarian Jan 16, 2023
ca8b5c2
Merge branch 'rc/v1.4.0' into simple-header-interfaces
SebastianMarian Jan 28, 2023
c262ab4
Merge branch 'rc/v1.4.0' into simple-header-interfaces
SebastianMarian Feb 1, 2023
caaf656
Merge branch 'rc/v1.4.0' into simple-header-interfaces
SebastianMarian Feb 3, 2023
633918f
* Fixed after merge
SebastianMarian Feb 3, 2023
6b8252f
* Expanded HeaderHandler interface with ValidatorStatsRootHash setter…
SebastianMarian Feb 20, 2023
40209be
* Added in headerWithValidatorStats implementation, methods SetMetaBl…
SebastianMarian Feb 20, 2023
3568507
Merge branch 'rc/v1.6.0' into simple-header-interfaces
SebastianMarian Mar 8, 2023
866caab
* Added new structures and interfaces needed by sovereign chain
SebastianMarian Mar 15, 2023
5b728dd
fix after review
sasurobert Mar 16, 2023
f898dc7
Merge pull request #97 from multiversx/simple-header-interfaces
sasurobert Mar 16, 2023
bb950b7
Merge branch 'feat/sovereign' into add-new-structures-and-interfaces-…
SebastianMarian Mar 16, 2023
b78e771
* Added new structures and interfaces needed by sovereign chain
SebastianMarian Mar 16, 2023
0301933
* Fixed after review
SebastianMarian Mar 16, 2023
1c443ee
Merge pull request #182 from multiversx/add-new-structures-and-interf…
SebastianMarian Mar 16, 2023
7005f21
* Added validator statistics info handler interface
SebastianMarian Mar 16, 2023
341f432
* Renamed parameter
SebastianMarian Mar 16, 2023
bd1ec26
Merge pull request #185 from multiversx/add-validator-statistics-info…
SebastianMarian Mar 16, 2023
3a3403a
* Refactored shard header extended DTO
SebastianMarian Mar 22, 2023
8702574
* Renamed input parameter
SebastianMarian Mar 22, 2023
3e413d0
* Fixed cycle imports
SebastianMarian Mar 22, 2023
d894919
* Fixed set of incoming mini blocks
SebastianMarian Mar 22, 2023
8a3d5f6
* Added support for sovereign transaction
SebastianMarian Mar 22, 2023
3d1d56e
Merge pull request #187 from multiversx/change-shard-header-extended-dto
SebastianMarian Mar 23, 2023
a28ab4b
Merge branch 'feat/sovereign' into create-sovereign-chain-tx-dto
SebastianMarian Mar 23, 2023
506e228
* Fixed after review
SebastianMarian Mar 23, 2023
6f35754
* Added sovereign chain shard ID
SebastianMarian Mar 24, 2023
9edccb6
Merge pull request #188 from multiversx/create-sovereign-chain-tx-dto
SebastianMarian Mar 27, 2023
b8b6a6b
Merge branch 'feat/outport-block' into merge-outport-into-sovereign
mariusmihaic Mar 31, 2023
aacb0c8
Merge pull request #194 from multiversx/merge-outport-into-sovereign
mariusmihaic Mar 31, 2023
0b33c77
* Moved sovereign chain constants in separated file
SebastianMarian Apr 13, 2023
268d25e
* Fixed after review
SebastianMarian Apr 13, 2023
7ab4681
Merge pull request #199 from multiversx/move-sovereign-chain-constant…
SebastianMarian Apr 14, 2023
283242b
Merge branch 'feat/outport-block' into merge-outport-into-sovereign-2…
mariusmihaic Apr 20, 2023
5747fbe
Merge pull request #201 from multiversx/merge-outport-into-sovereign-…
mariusmihaic Apr 20, 2023
299f334
* Refactor and improve sovereign chain header DTO and interface
SebastianMarian Apr 25, 2023
0852cb7
FEAT: Add incoming logs
mariusmihaic May 3, 2023
a573883
FIX: Create IncomingHeader separate package
mariusmihaic May 4, 2023
8c7d8ad
FIX: Comments
mariusmihaic May 4, 2023
26a3dd1
FIX: Use incoming events instead of logs
mariusmihaic May 4, 2023
bce3602
FIX: Add IsInterfaceNil
mariusmihaic May 10, 2023
e98de4e
FIX: Add IsInterfaceNil
mariusmihaic May 10, 2023
6b74840
Merge pull request #210 from multiversx/MX-14127-incoming-logs
mariusmihaic May 10, 2023
05da1bb
Merge branch 'feat/outport-block' into merge-outport-into-sovereign-1…
mariusmihaic May 19, 2023
8f95e75
Merge pull request #232 from multiversx/merge-outport-into-sovereign-…
mariusmihaic May 19, 2023
d174e1a
Merge branch 'rc/v1.6.0' into merge-rc-into-sovereign-19-march-2023
mariusmihaic May 19, 2023
c33590e
Merge pull request #233 from multiversx/merge-rc-into-sovereign-19-ma…
mariusmihaic May 19, 2023
3101a70
Merge branch 'rc/v1.6.0' into merge-rc-into-sovereign-30-may-2023
mariusmihaic May 30, 2023
441f7ec
Merge pull request #236 from multiversx/merge-rc-into-sovereign-30-ma…
mariusmihaic May 30, 2023
13c0559
FEAT: Json tags
mariusmihaic Jun 6, 2023
83915b1
Merge branch 'feat/sovereign' into refactor-and-improve-sovereign-cha…
mariusmihaic Jun 6, 2023
361a625
Merge pull request #205 from multiversx/refactor-and-improve-sovereig…
mariusmihaic Jun 7, 2023
4f50cca
Merge branch 'rc/v1.6.0' into merge-rc-1-6-into-sovereign-22-jun-2023
mariusmihaic Jun 22, 2023
f38fc38
Merge pull request #237 from multiversx/merge-rc-1-6-into-sovereign-2…
mariusmihaic Jun 22, 2023
b44cc03
Merge branch 'rc/v1.6.0' into merge-rc-1-6-sovereign-3-jul-2023
mariusmihaic Jul 3, 2023
8337305
Merge pull request #240 from multiversx/merge-rc-1-6-sovereign-3-jul-…
mariusmihaic Jul 4, 2023
59f40d2
FEAT: Get + Set shard id in sovereignChainHeader
mariusmihaic Jul 17, 2023
a4ffe12
CLN: Make sovereign chain shard id = 0
mariusmihaic Jul 28, 2023
1c16435
Merge branch 'rc/v1.6.0' into merge-rc-1-6-into-sovereign-14-aug-2023
mariusmihaic Aug 14, 2023
da1d960
Merge pull request #246 from multiversx/merge-rc-1-6-into-sovereign-1…
mariusmihaic Aug 14, 2023
0a6fd1e
Merge branch 'feat/sovereign' into MX-14132-sov-header-shard-id-2
mariusmihaic Aug 14, 2023
009294f
CLN: SetShardID
mariusmihaic Aug 25, 2023
1f82e8e
FIX: GetShardID
mariusmihaic Aug 28, 2023
c6a414d
Merge pull request #247 from multiversx/MX-14132-sov-header-shard-id-2
mariusmihaic Aug 28, 2023
f8c2d02
FEAT: Add sovereign proof incoming mb
mariusmihaic Aug 30, 2023
6819129
FIX: Import cycle
mariusmihaic Aug 30, 2023
90f12ee
FEAT: Extend ShardHeaderExtended interface
mariusmihaic Aug 31, 2023
624c971
Merge branch 'rc/v1.6.0' into merge-rc-1-6-into-sovereign-26-sept-2023
mariusmihaic Sep 26, 2023
c4caa19
FIX: Import cycle
mariusmihaic Sep 26, 2023
2cddf53
Merge pull request #264 from multiversx/merge-rc-1-6-into-sovereign-2…
mariusmihaic Sep 26, 2023
5f47af6
added sovereign header type
bogdan-rosianu Sep 28, 2023
be7f0d9
Merge branch 'feat/sovereign' into MX-14503-sovereign-proof
mariusmihaic Sep 29, 2023
35bb230
Merge pull request #258 from multiversx/MX-14503-sovereign-proof
mariusmihaic Sep 29, 2023
e9bafb2
Merge branch 'feat/sovereign' into add-sovereign-header-outport-type
bogdan-rosianu Sep 29, 2023
f645305
Merge pull request #265 from multiversx/add-sovereign-header-outport-…
mariusmihaic Oct 4, 2023
8a2f422
FEAT: Add outgoing operation hashes in sovereign chain header
mariusmihaic Oct 27, 2023
2ecbe85
FEAT: Extend outgoing operations data struct
mariusmihaic Oct 31, 2023
37c38ce
FEAT: Refactor to use outgoing miniblock header
mariusmihaic Nov 1, 2023
a9d1582
FIX: ShallowClone in SovereignChainHeader
mariusmihaic Nov 3, 2023
932bc4e
FIX: ShallowClone in SovereignChainHeader
mariusmihaic Nov 3, 2023
4f4d7bc
FIX: ShallowClone in SovereignChainHeader
mariusmihaic Nov 3, 2023
0f1e33a
Merge pull request #269 from multiversx/MX-14705-add-hash-outgoing-op…
mariusmihaic Nov 16, 2023
72ed699
FEAT: Outgoing bridge operations proto
mariusmihaic Nov 21, 2023
a96f40e
FEAT: Add aggregated and leader signature
mariusmihaic Nov 27, 2023
d119564
FEAT: Tx hashes response to string
mariusmihaic Nov 28, 2023
9672e1a
FEAT: Replace map with slice of structs
mariusmihaic Dec 4, 2023
ab3aa82
Merge pull request #273 from multiversx/MX-14777-proto-outgoing-bridg…
mariusmihaic Dec 4, 2023
78dc2e6
Merge pull request #272 from multiversx/feat/sov-outgoing-operations
mariusmihaic Jan 18, 2024
a5e0934
Merge branch 'rc/v1.7.0' into merge-rc-1-7-into-sov-18-jan-2024
mariusmihaic Jan 18, 2024
5d14fce
FIX: Go mod
mariusmihaic Jan 18, 2024
661f5af
Merge pull request #283 from multiversx/merge-rc-1-7-into-sov-18-jan-…
mariusmihaic Jan 18, 2024
72a8c67
event data and operation data structs
axenteoctavian Mar 5, 2024
2aded24
removed unnecessary struct
axenteoctavian Mar 6, 2024
9e4b4a8
comments for exported types
axenteoctavian Mar 7, 2024
6e868d6
enum deleted because already exists
axenteoctavian Mar 7, 2024
18ad5f9
comm updated
axenteoctavian Mar 7, 2024
9c061d5
Merge pull request #289 from multiversx/MX-15247-new-sovereign-structs
axenteoctavian Mar 7, 2024
5c316c2
operation data containing the full event data
axenteoctavian Mar 12, 2024
828e0a3
Merge pull request #290 from multiversx/MX-15247-new-sovereign-structs
axenteoctavian Mar 12, 2024
1b566ba
sender address in event data
axenteoctavian Mar 14, 2024
97ee507
Merge pull request #292 from multiversx/MX-15247-new-sovereign-structs
axenteoctavian Mar 14, 2024
24fb7f0
Merge branch 'rc/v1.7.0' into merge-rc-1-7-into-feat-sovereign-25-mar…
mariusmihaic Mar 25, 2024
e35934f
FEAT: Add SetBlockBodyTypeInt32 in sov chain hdr
mariusmihaic Mar 25, 2024
4fced05
FEAT: Add SetBlockBodyTypeInt32 in extended hdr
mariusmihaic Mar 25, 2024
68f8114
FIX: Indentation
mariusmihaic Mar 27, 2024
7bd80a4
Merge pull request #296 from multiversx/merge-rc-1-7-into-feat-sovere…
mariusmihaic Mar 28, 2024
b846b1c
Merge branch 'rc/v1.7.next1' into merge-rc-1-7-next-into-sovereign-28…
mariusmihaic Mar 28, 2024
01e22e9
Merge pull request #297 from multiversx/merge-rc-1-7-next-into-sovere…
mariusmihaic Mar 29, 2024
72b1cac
Merge branch 'rc/v1.7.next1' into merge-rc-1-7-next-into-sovereign-14…
mariusmihaic May 14, 2024
2ee16f8
Merge pull request #303 from multiversx/merge-rc-1-7-next-into-sovere…
mariusmihaic May 15, 2024
9f259f2
Merge branch 'rc/v1.7.next1' into merge-rc-1-7-next-1-into-feat-sover…
mariusmihaic May 31, 2024
8bc5957
Merge pull request #306 from multiversx/merge-rc-1-7-next-1-into-feat…
mariusmihaic May 31, 2024
cd91b61
FEAT: Add sovereign epoch start missing fields
mariusmihaic Jun 18, 2024
94cf0ab
FEAT: Extend sov header interface
mariusmihaic Jun 18, 2024
c7afec5
FIX: Interface signature
mariusmihaic Jun 18, 2024
bdffd3d
FIX: Simplify start of epoch with bool flag
mariusmihaic Jun 19, 2024
22393a7
FEAT: Sovereign chain trigger registry
mariusmihaic Jun 20, 2024
92f76e5
FEAT: MetaTriggerRegistryHandler
mariusmihaic Jun 20, 2024
3d38f8e
Merge pull request #308 from multiversx/MX-15590-add-epoch-start-miss…
mariusmihaic Jul 16, 2024
28d7949
FEAT: Add epoch start economics in sov block
mariusmihaic Jul 18, 2024
7cda53f
FEAT: Extend interface
mariusmihaic Jul 18, 2024
aeae501
FEAT: Extend meta header interface
mariusmihaic Jul 19, 2024
ab81ad8
FEAT: Extend sovereign chain header
mariusmihaic Jul 19, 2024
9028001
Merge pull request #312 from multiversx/MX-15590-economics-sovereign-…
mariusmihaic Aug 5, 2024
9046faf
Merge branch 'rc/v1.7.next1' into merge-rc-1-7-next1-into-sovereign-7…
mariusmihaic Oct 7, 2024
50ac1ae
CLN: Delete sovereign tx
mariusmihaic Oct 7, 2024
b884700
Merge pull request #326 from multiversx/merge-rc-1-7-next1-into-sover…
mariusmihaic Oct 11, 2024
c92f909
FEAT: Add LastFinalizedCrossChainHeader
mariusmihaic Oct 16, 2024
f6bd53c
FEAT: Extend sov header with EpochStartChainDataHandler interfaces
mariusmihaic Oct 18, 2024
0f47aef
Merge pull request #329 from multiversx/MX-15917-save-last-notarized-…
mariusmihaic Oct 24, 2024
6f10707
Merge branch 'rc/v1.7.next1' into merge-rc-1-7-next-into-sovereign-11…
axenteoctavian Nov 11, 2024
b8a9c02
Merge pull request #333 from multiversx/merge-rc-1-7-next-into-sovere…
axenteoctavian Nov 11, 2024
a1d08e6
Merge pull request #294 from multiversx/rc/v1.7.next1
sstanculeanu Nov 13, 2024
e2451e1
token random seq correct validity check
axenteoctavian Nov 19, 2024
a0e4044
Merge pull request #335 from multiversx/MX-15294-random-seq-validity
axenteoctavian Nov 19, 2024
dbb2317
Merge branch 'main' into merge-main-into-sovereign-20-nov
axenteoctavian Nov 20, 2024
16e4df5
Merge pull request #336 from multiversx/merge-main-into-sovereign-20-nov
axenteoctavian Nov 20, 2024
057bcad
FEAT: Extend sovereign EpochStart data interface with correct pointer…
mariusmihaic Dec 9, 2024
25ee3bc
Merge branch 'feat/sovereign' into MX-15667-fix-epoch-start-pointer-r…
mariusmihaic Dec 9, 2024
1a8ee42
CLN: After merge + comms
mariusmihaic Dec 9, 2024
762196f
FIX: Typo
mariusmihaic Dec 9, 2024
5ea61e5
FEAT: Add unit tests sovereignChainHeader_test.go
mariusmihaic Dec 11, 2024
fcd76c0
Merge pull request #337 from multiversx/MX-15667-fix-epoch-start-poin…
mariusmihaic Dec 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions core/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const (
ShardHeaderV1 HeaderType = "Header"
// ShardHeaderV2 defines the type of *block.HeaderV2
ShardHeaderV2 HeaderType = "HeaderV2"
// SovereignChainHeader defines the type of *block.SovereignChainHeader
SovereignChainHeader = "SovereignChainHeader"
)

// NodeType represents the node's role in the network
Expand All @@ -31,12 +33,6 @@ const FileModeUserReadWrite = 0600
// for others
const FileModeReadWrite = 0664

// MetachainShardId will be used to identify a shard ID as metachain
const MetachainShardId = uint32(0xFFFFFFFF)

// AllShardId will be used to identify that a message is for all shards
const AllShardId = uint32(0xFFFFFFF0)

// MegabyteSize represents the size in bytes of a megabyte
const MegabyteSize = 1024 * 1024

Expand Down
13 changes: 13 additions & 0 deletions core/shardIDConstants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package core

// MetachainShardId will be used to identify a shard ID as metachain
const MetachainShardId = uint32(0xFFFFFFFF)

// AllShardId will be used to identify that a message is for all shards
const AllShardId = uint32(0xFFFFFFF0)

// SovereignChainShardId will be used to identify a shard ID as sovereign chain
const SovereignChainShardId = uint32(0)

// MainChainShardId will be used to identify a shard ID as main chain
const MainChainShardId = uint32(0xFFFFFFFD)
50 changes: 42 additions & 8 deletions data/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func (h *Header) SetRootHash(rHash []byte) error {
}

// SetValidatorStatsRootHash sets the root hash for the validator statistics trie
func (h *Header) SetValidatorStatsRootHash(_ []byte) {
func (h *Header) SetValidatorStatsRootHash(_ []byte) error {
return nil
}

// SetPrevHash sets prev hash
Expand All @@ -77,11 +78,6 @@ func (h *Header) SetPrevHash(pvHash []byte) error {
return nil
}

// GetValidatorStatsRootHash returns the root hash for the validator statistics trie
func (h *Header) GetValidatorStatsRootHash() []byte {
return []byte{}
}

// SetPrevRandSeed sets previous random seed
func (h *Header) SetPrevRandSeed(pvRandSeed []byte) error {
if h == nil {
Expand Down Expand Up @@ -396,6 +392,39 @@ func (h *Header) ValidateHeaderVersion() error {
return nil
}

// Clone creates a clones the miniblock
func (m *MiniBlock) Clone() data.MiniBlockHandler {
if m == nil {
return nil
}

return m.DeepClone()
}

// IsInterfaceNil returns true if underlying object is nil
func (m *MiniBlock) IsInterfaceNil() bool {
return m == nil
}

// SetMiniBlocks will set a new set of miniblocks
func (b *Body) SetMiniBlocks(miniBlocks []data.MiniBlockHandler) error {
if b == nil {
return data.ErrNilPointerReceiver
}

b.MiniBlocks = make([]*MiniBlock, len(miniBlocks))
for i, mb := range miniBlocks {
mbHandlerClone := mb.Clone()
mbClone, ok := mbHandlerClone.(*MiniBlock)
if !ok {
return data.ErrWrongTypeAssertion
}
b.MiniBlocks[i] = mbClone
}

return nil
}

// IntegrityAndValidity checks if data is valid
func (b *Body) IntegrityAndValidity() error {
if b == nil {
Expand Down Expand Up @@ -427,8 +456,8 @@ func (b *Body) IsInterfaceNil() bool {
return b == nil
}

// Clone the underlying data
func (mb *MiniBlock) Clone() *MiniBlock {
// DeepClone the underlying data
func (mb *MiniBlock) DeepClone() *MiniBlock {
if mb == nil {
return nil
}
Expand Down Expand Up @@ -594,6 +623,11 @@ func (h *Header) GetAdditionalData() headerVersionData.HeaderAdditionalData {
return nil
}

// GetValidatorStatsRootHash returns the root hash for the validator statistics trie
func (h *Header) GetValidatorStatsRootHash() []byte {
return []byte{}
}

// CheckFieldsForNil checks a predefined set of fields for nil values
func (h *Header) CheckFieldsForNil() error {
if h == nil {
Expand Down
2 changes: 1 addition & 1 deletion data/block/block.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ enum Type {
InvalidBlock = 120;
ReceiptBlock = 150;
RewardsBlock = 255;
}
};

enum ProcessingType {
Normal = 0;
Expand Down
10 changes: 10 additions & 0 deletions data/block/blockV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ func (hv2 *HeaderV2) SetRootHash(rHash []byte) error {
return hv2.Header.SetRootHash(rHash)
}

// SetValidatorStatsRootHash sets the root hash for the validator statistics trie
func (hv2 *HeaderV2) SetValidatorStatsRootHash(_ []byte) error {
return nil
}

// SetPrevHash sets prev hash
func (hv2 *HeaderV2) SetPrevHash(pvHash []byte) error {
if hv2 == nil {
Expand Down Expand Up @@ -640,6 +645,11 @@ func (hv2 *HeaderV2) GetAdditionalData() headerVersionData.HeaderAdditionalData
return additionalVersionData
}

// GetValidatorStatsRootHash returns the root hash for the validator statistics trie
func (hv2 *HeaderV2) GetValidatorStatsRootHash() []byte {
return []byte{}
}

// CheckFieldsForNil checks a predefined set of fields for nil values
func (hv2 *HeaderV2) CheckFieldsForNil() error {
if hv2 == nil {
Expand Down
20 changes: 20 additions & 0 deletions data/block/emptySovereignHeaderCreator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package block

import "github.com/multiversx/mx-chain-core-go/data"

type emptySovereignHeaderCreator struct{}

// NewEmptySovereignHeaderCreator is able to create empty sovereign header instances
func NewEmptySovereignHeaderCreator() *emptySovereignHeaderCreator {
return &emptySovereignHeaderCreator{}
}

// CreateNewHeader creates a new empty sovereign header
func (creator *emptySovereignHeaderCreator) CreateNewHeader() data.HeaderHandler {
return &SovereignChainHeader{}
}

// IsInterfaceNil returns true if there is no value under the interface
func (creator *emptySovereignHeaderCreator) IsInterfaceNil() bool {
return creator == nil
}
15 changes: 15 additions & 0 deletions data/block/emptySovereignHeaderCreator_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package block

import (
"testing"

"github.com/stretchr/testify/require"
)

func Test_emptySovereignHeaderCreator_CreateNewHeader(t *testing.T) {
creator := NewEmptySovereignHeaderCreator()
require.False(t, creator.IsInterfaceNil())

hdr := creator.CreateNewHeader()
require.IsType(t, &SovereignChainHeader{}, hdr)
}
Loading
Loading