-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #315 from multiversx/MX-16238-tx-hash-extractor
tx hashes extractor implementation
- Loading branch information
Showing
24 changed files
with
286 additions
and
50 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
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
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,24 @@ | ||
package mock | ||
|
||
import ( | ||
coreData "github.com/multiversx/mx-chain-core-go/data" | ||
) | ||
|
||
// TxHashExtractorMock - | ||
type TxHashExtractorMock struct { | ||
ExtractExecutedTxHashesCalled func(mbIndex int, mbTxHashes [][]byte, header coreData.HeaderHandler) [][]byte | ||
} | ||
|
||
// ExtractExecutedTxHashes - | ||
func (the *TxHashExtractorMock) ExtractExecutedTxHashes(mbIndex int, mbTxHashes [][]byte, header coreData.HeaderHandler) [][]byte { | ||
if the.ExtractExecutedTxHashesCalled != nil { | ||
return the.ExtractExecutedTxHashesCalled(mbIndex, mbTxHashes, header) | ||
} | ||
|
||
return make([][]byte, 0) | ||
} | ||
|
||
// IsInterfaceNil returns true if there is no value under the interface | ||
func (the *TxHashExtractorMock) IsInterfaceNil() bool { | ||
return the == 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
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
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,8 @@ | ||
package transactions | ||
|
||
import ( | ||
"errors" | ||
) | ||
|
||
// ErrNilTxHashExtractor signals that a nil tx hash extractor has been provided | ||
var ErrNilTxHashExtractor = errors.New("nil tx hash extractor") |
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
22 changes: 22 additions & 0 deletions
22
process/elasticproc/transactions/sovereignTxHashExtractor.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,22 @@ | ||
package transactions | ||
|
||
import ( | ||
coreData "github.com/multiversx/mx-chain-core-go/data" | ||
) | ||
|
||
type sovereignTxHashExtractor struct{} | ||
|
||
// NewSovereignTxHashExtractor creates a new sovereign tx hash extractor | ||
func NewSovereignTxHashExtractor() *sovereignTxHashExtractor { | ||
return &sovereignTxHashExtractor{} | ||
} | ||
|
||
// ExtractExecutedTxHashes returns directly the provided mini block tx hashes | ||
func (the *sovereignTxHashExtractor) ExtractExecutedTxHashes(_ int, mbTxHashes [][]byte, _ coreData.HeaderHandler) [][]byte { | ||
return mbTxHashes | ||
} | ||
|
||
// IsInterfaceNil returns true if there is no value under the interface | ||
func (the *sovereignTxHashExtractor) IsInterfaceNil() bool { | ||
return the == nil | ||
} |
23 changes: 23 additions & 0 deletions
23
process/elasticproc/transactions/sovereignTxHashExtractor_test.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,23 @@ | ||
package transactions | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestNewSovereignTxHashExtractor(t *testing.T) { | ||
t.Parallel() | ||
|
||
sthe := NewSovereignTxHashExtractor() | ||
require.False(t, sthe.IsInterfaceNil()) | ||
} | ||
|
||
func TestSovereignTxHashExtractor_ExtractExecutedTxHashes(t *testing.T) { | ||
t.Parallel() | ||
|
||
sthe := NewSovereignTxHashExtractor() | ||
mbTxHashes := [][]byte{[]byte("hash1"), []byte("hash2")} | ||
txHashes := sthe.ExtractExecutedTxHashes(0, mbTxHashes, nil) | ||
require.Equal(t, mbTxHashes, txHashes) | ||
} |
Oops, something went wrong.