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

Added RetrieveBlockByNumber into blockledger #2635

Merged
merged 1 commit into from
Jun 7, 2021

Conversation

Param-S
Copy link
Contributor

@Param-S Param-S commented Jun 2, 2021

Description

GetBlock is used for retrieving a block in ConfigBlockOrPanic
which has overhead of Iterator. It is now simplified by exposing
a BlockStore function RetrieveBlockByNumber.

Signed-off-by: Parameswaran Selvam parselva@in.ibm.com

Type of change

  • Improvement (improvement to code, performance, etc)
  • Test update

@Param-S
Copy link
Contributor Author

Param-S commented Jun 2, 2021

as per @manish-sethi input #2594 (comment) created a new PR for main.

Copy link
Contributor

@manish-sethi manish-sethi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Param-S - LGTM. Just a couple nit comments

@@ -93,6 +94,7 @@ func (fl *FileLedger) Iterator(startPosition *ab.SeekPosition) (blockledger.Iter

iterator, err := fl.blockStore.RetrieveBlocks(startingBlockNumber)
if err != nil {
logger.Warnf("Failed to initialize block iterator from blockNum = [%d] with error = (%v)", startingBlockNumber, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have been preferring to use the following function for logging

Suggested change
logger.Warnf("Failed to initialize block iterator from blockNum = [%d] with error = (%v)", startingBlockNumber, err)
logger.Warnw("Failed to initialize block iterator", "blockNum", startingBlockNumber, "error", err)

Comment on lines 1802 to 1804
assert.Panics(t, func() {
ConfigBlockOrPanic(l)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • better to use require instead of assert
  • Wherever possible better to use PanicsWithValue so you could test for the exact error message expected

GetBlock is used for retrieving a block in ConfigBlockOrPanic
which has overhead of Iterator. It is now simplified by exposing
a BlockStore function RetrieveBlockByNumber.

Signed-off-by: Parameswaran Selvam <parselva@in.ibm.com>
@manish-sethi manish-sethi merged commit 85ae90c into hyperledger:main Jun 7, 2021
Param-S added a commit to Param-S/fabric that referenced this pull request Jun 7, 2021
GetBlock is used for retrieving a block in ConfigBlockOrPanic
which has overhead of Iterator. It is now simplified by exposing
a BlockStore function RetrieveBlockByNumber.

Signed-off-by: Parameswaran Selvam <parselva@in.ibm.com>
manish-sethi pushed a commit that referenced this pull request Jun 7, 2021
…2648)

* FAB-18276 Ch.Part.API: extractSystemChannel must skip empty ledger (#2023)

- orderer/common/server/main.go extractSystemChannel() panics when
it hits an empty ledger.

- In addition this method is not covered with unit tests at all.

- Remove some dead code.

Signed-off-by: Yoav Tock <tock@il.ibm.com>
Change-Id: Ie13156784d2ec600e3f97d34f20f6836b28f7662

* Added RetrieveBlockByNumber into blockledger (#2635)

GetBlock is used for retrieving a block in ConfigBlockOrPanic
which has overhead of Iterator. It is now simplified by exposing
a BlockStore function RetrieveBlockByNumber.

Signed-off-by: Parameswaran Selvam <parselva@in.ibm.com>

Co-authored-by: Yoav Tock <tock@il.ibm.com>
@Param-S
Copy link
Contributor Author

Param-S commented Jun 8, 2021

@Mergifyio backport release-2.3

@mergify
Copy link

mergify bot commented Jun 8, 2021

Command backport release-2.3: success

Backports have been created

mergify bot pushed a commit that referenced this pull request Jun 8, 2021
GetBlock is used for retrieving a block in ConfigBlockOrPanic
which has overhead of Iterator. It is now simplified by exposing
a BlockStore function RetrieveBlockByNumber.

Signed-off-by: Parameswaran Selvam <parselva@in.ibm.com>
(cherry picked from commit 85ae90c)
manish-sethi pushed a commit that referenced this pull request Jun 8, 2021
GetBlock is used for retrieving a block in ConfigBlockOrPanic
which has overhead of Iterator. It is now simplified by exposing
a BlockStore function RetrieveBlockByNumber.

Signed-off-by: Parameswaran Selvam <parselva@in.ibm.com>
(cherry picked from commit 85ae90c)

Co-authored-by: Parameswaran Selvam <Param-S@users.noreply.github.com>
C0rWin pushed a commit to C0rWin/fabric that referenced this pull request Sep 24, 2022
…rledger#2657)

GetBlock is used for retrieving a block in ConfigBlockOrPanic
which has overhead of Iterator. It is now simplified by exposing
a BlockStore function RetrieveBlockByNumber.

Signed-off-by: Parameswaran Selvam <parselva@in.ibm.com>
(cherry picked from commit 85ae90c)

Co-authored-by: Parameswaran Selvam <Param-S@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants