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

Add function to delete the ledger data for a channel #2722

Merged
merged 1 commit into from
Jun 29, 2021

Conversation

manish-sethi
Copy link
Contributor

Signed-off-by: manish manish.sethi@gmail.com

Type of change

  • New feature

Description

This PR adds a function that takes the ledger config and deletes the data for a channel

Additional details

This is a basic function that would be invoked in the future PR and the tests will be added in that PR

Related issues

FAB-11334

@manish-sethi manish-sethi requested a review from a team as a code owner June 29, 2021 03:03
Signed-off-by: manish <manish.sethi@gmail.com>
Copy link
Contributor

@cendhu cendhu left a comment

Choose a reason for hiding this comment

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

LGTM. Just a doubt.

)

// removeLedgerData removes the data for a given ledger. This function should be invoked when the peer is not running and the caller should hold the file lock for the KVLedgerProvider
func removeLedgerData(config *ledger.Config, ledgerID string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

As this function creates all providers and removes the data associated with a given ledgerID, shouldn't it take care of deleting the ledgerID from the idStore too?

If not, are we expecting the caller of this function to open the idStore and delete the ledgerID once this function returns success?

Copy link
Contributor

Choose a reason for hiding this comment

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

Got the answer by looking at the code of other commands such as pause, resume. So the caller should take care of acquiring the lock as well as deleting the ledgerID from the idStore

func pauseOrResumeChannel(rootFSPath, ledgerID string, status msgs.Status) error {
fileLock := leveldbhelper.NewFileLock(fileLockPath(rootFSPath))
if err := fileLock.Lock(); err != nil {
return errors.Wrap(err, "as another peer node command is executing,"+
" wait for that command to complete its execution or terminate it before retrying")
}
defer fileLock.Unlock()
idStore, err := openIDStore(LedgerProviderPath(rootFSPath))
if err != nil {
return err
}
defer idStore.db.Close()
return idStore.updateLedgerStatus(ledgerID, status)
}
as done here

@cendhu cendhu merged commit 1ee03b3 into hyperledger:main Jun 29, 2021
@manish-sethi manish-sethi deleted the unjoin branch June 29, 2021 16:42
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