-
Notifications
You must be signed in to change notification settings - Fork 198
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
EN-10574 Get block by round #3430
Conversation
Codecov Report
@@ Coverage Diff @@
## development #3430 +/- ##
===============================================
+ Coverage 73.85% 73.89% +0.04%
===============================================
Files 581 581
Lines 73907 74278 +371
===============================================
+ Hits 54583 54888 +305
- Misses 14945 15003 +58
- Partials 4379 4387 +8
Continue to review full report at Codecov.
|
@@ -9,6 +9,8 @@ import ( | |||
"github.com/ElrondNetwork/elrond-go/config" | |||
"github.com/ElrondNetwork/elrond-go/dataRetriever" | |||
"github.com/ElrondNetwork/elrond-go/dblookupext/factory" | |||
"github.com/ElrondNetwork/elrond-go/process" | |||
mock2 "github.com/ElrondNetwork/elrond-go/process/mock" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mock2 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider replacing mock2
with processorMock
alias
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed it to processMock
node/blockAPI/metaBlock.go
Outdated
@@ -65,6 +65,21 @@ func (mbp *metaAPIBlockProcessor) GetBlockByHash(hash []byte, withTxs bool) (*ap | |||
return mbp.computeStatusAndPutInBlock(blockAPI, dataRetriever.MetaHdrNonceHashDataUnit) | |||
} | |||
|
|||
// GetBlockByRound will return a shard APIBlock by round |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// GetBlockByRound will return a meta
APIBlock by round
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, fixed it here and for GetBlockByHash
as well
@@ -9,6 +9,8 @@ import ( | |||
"github.com/ElrondNetwork/elrond-go/config" | |||
"github.com/ElrondNetwork/elrond-go/dataRetriever" | |||
"github.com/ElrondNetwork/elrond-go/dblookupext/factory" | |||
"github.com/ElrondNetwork/elrond-go/process" | |||
mock2 "github.com/ElrondNetwork/elrond-go/process/mock" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider replacing mock2
with processorMock
alias
@@ -35,6 +35,15 @@ func (n *Node) GetBlockByNonce(nonce uint64, withTxs bool) (*api.Block, error) { | |||
return apiBlockProcessor.GetBlockByNonce(nonce, withTxs) | |||
} | |||
|
|||
func (n *Node) GetBlockByRound(round uint64, withTxs bool) (*api.Block, error) { | |||
apiBlockProcessor, err := n.createAPIBlockProcessor() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@miiu96 please check this. Why do we need to create an apiBlockProcessor for each request? We should definitely change this.
# Conflicts: # api/groups/blockGroup.go # api/groups/blockGroup_test.go # api/mock/facade.go # facade/disabled/disabledNodeFacade_test.go
dataRetriever/interface.go
Outdated
// MetaHdrRoundHashDataUnit is the meta header round-hash storage data pair unit identifier | ||
MetaHdrRoundHashDataUnit UnitType = 49 | ||
// ShardHdrRoundHashDataUnit is the shard round-hash storage data unit identifier | ||
ShardHdrRoundHashDataUnit UnitType = 50 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's put this on the 200 value (or even better ~400 as to allow the creation of 256 shards) and place it after the ShardHdrNonceHashDataUnit definition. MetaHdrRoundHashDataUnit can be 19. Adjust the comment below to include the ShardHdrNonceHashDataUnit.
@@ -94,12 +94,12 @@ func TestNewHistoryRepository(t *testing.T) { | |||
require.NotNil(t, repo) | |||
} | |||
|
|||
func TestHistoryRepository_RecordBlock_InvalidBlockRoundByNonceStorer_ExpectError(t *testing.T) { | |||
func TestHistoryRepository_RecordBlock_InvalidBlockRoundByHashStorer_ExpectError(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too many _ in name. To align with the rest of the project, please rename this to:
TestHistoryRepository_RecordBlockInvalidBlockRoundByHashStorerExpectError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed it to be consistent with the rest of the tests
createdStorers = append(createdStorers, blockRoundByNonceUnit) | ||
chainStorer.AddStorer(dataRetriever.RoundNonceUnit, blockRoundByNonceUnit) | ||
createdStorers = append(createdStorers, blockHashByRoundUnit) | ||
chainStorer.AddStorer(hashByRoundUnitData, blockHashByRoundUnit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, one question here: why do we need a different value for blockHashByRoundUnit (according to the shard in which the node is operating) but we always open the same storer from the same path? This can be simplified by stating a hardcoded value in dataretrieve/interface.go for this unit type (not added to the shard ID value), something like 19 or 20 or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System tests passed.
/by-round/:round
route to get block by round with optionalwithTxs
query paramputRoundByNonce
in(hr *historyRepository) RecordBlock
GetBlockByNonce(nonce, withTxs)