-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEAT: Intercepted sovereign block header with mb headers checker
- Loading branch information
1 parent
c5f11d7
commit cd563fb
Showing
6 changed files
with
69 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package interceptedBlocks | ||
|
||
import "errors" | ||
|
||
var errNilInterceptedBlockHeader = errors.New("nil intercepted block header provided") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
process/block/interceptedBlocks/interceptedSovereignBlockHeader.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package interceptedBlocks | ||
|
||
import ( | ||
"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-go/sharding" | ||
) | ||
|
||
type interceptedSovereignBlockHeader struct { | ||
*InterceptedHeader | ||
} | ||
|
||
// NewSovereignInterceptedBlockHeader creates a new intercepted sovereign block header | ||
func NewSovereignInterceptedBlockHeader(blockHeaderInterceptor *InterceptedHeader) (*interceptedSovereignBlockHeader, error) { | ||
if check.IfNil(blockHeaderInterceptor) { | ||
return nil, errNilInterceptedBlockHeader | ||
} | ||
|
||
sovInterceptedBlock := &interceptedSovereignBlockHeader{ | ||
blockHeaderInterceptor, | ||
} | ||
|
||
sovInterceptedBlock.mbHeadersChecker = sovInterceptedBlock | ||
return sovInterceptedBlock, nil | ||
} | ||
|
||
func (isbh *interceptedSovereignBlockHeader) checkMiniBlocksHeaders(mbHeaders []data.MiniBlockHeaderHandler, coordinator sharding.Coordinator) error { | ||
return checkMiniBlocksHeaders(mbHeaders, coordinator, core.MainChainShardId) | ||
} | ||
|
||
// IsInterfaceNil returns true if there is no value under the interface | ||
func (isbh *interceptedSovereignBlockHeader) IsInterfaceNil() bool { | ||
return isbh == nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package interceptedBlocks | ||
|
||
import ( | ||
"github.com/multiversx/mx-chain-core-go/data" | ||
"github.com/multiversx/mx-chain-go/sharding" | ||
) | ||
|
||
type mbHeadersChecker interface { | ||
checkMiniBlocksHeaders(mbHeaders []data.MiniBlockHeaderHandler, coordinator sharding.Coordinator) error | ||
} |