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

[filedao] remove checkMasterChainDBFile() #3463

Merged
merged 2 commits into from
Jun 27, 2022

Conversation

dustinxie
Copy link
Member

@dustinxie dustinxie commented Jun 22, 2022

Description

checkMasterChainDBFile() is redundant, so remove it

Fixes #3450

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • make test
  • fullsync
  • [] Other test (please specify)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@dustinxie dustinxie requested a review from a team as a code owner June 22, 2022 19:37
}

switch header.Version {
case FileLegacyAuxiliary:
// default chain db file is legacy format, but not master, the master file has been corrupted
return nil, ErrFileInvalid
Copy link
Member Author

@dustinxie dustinxie Jun 22, 2022

Choose a reason for hiding this comment

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

this is the only case (from removed func) that needs to be taken care of here

default:
panic(fmt.Errorf("corrupted file version: %s", h.Version))
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

most code are redundant with those above, so remove it

@codecov
Copy link

codecov bot commented Jun 22, 2022

Codecov Report

Merging #3463 (2c8ef82) into master (5a9bfa0) will increase coverage by 0.00%.
The diff coverage is 60.00%.

@@           Coverage Diff           @@
##           master    #3463   +/-   ##
=======================================
  Coverage   75.11%   75.11%           
=======================================
  Files         243      243           
  Lines       22522    22514    -8     
=======================================
- Hits        16918    16912    -6     
+ Misses       4681     4680    -1     
+ Partials      923      922    -1     
Impacted Files Coverage Δ
blockchain/filedao/filedao_util.go 87.95% <ø> (+0.99%) ⬆️
blockchain/filedao/filedao.go 69.06% <60.00%> (+0.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a9bfa0...2c8ef82. Read the comment docs.

header, err := checkMasterChainDBFile(cfg.DbPath)
if err == ErrFileInvalid || err == ErrFileCantAccess {
header, err := readFileHeader(cfg.DbPath, FileAll)
switch err {
Copy link
Member

@Liuhaai Liuhaai Jun 22, 2022

Choose a reason for hiding this comment

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

[deleted]

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

Copy link
Member

Choose a reason for hiding this comment

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

The original pattern would be better

if err != nil && err != ErrFileNotExist {
		return nil, err
}

if err == ErrFileNotExist {}

@dustinxie dustinxie merged commit 388be8c into iotexproject:master Jun 27, 2022
pocockn added a commit to pocockn/iotex-core that referenced this pull request Jul 4, 2022
* upstream/master: (24 commits)
  account type with zero init nonce (iotexproject#3387)
  [api] Separate Server and Server Handler (iotexproject#3485)
  [ioctl] Build hdwallet derive command line into new ioctl (iotexproject#3418)
  [ioctl] Build hdwallet create command line into new ioctl (iotexproject#3470)
  [makefile] add go mod tidy (iotexproject#3471)
  [api] update chain metrics (iotexproject#3484)
  remove config.EVMNetworkID() (iotexproject#3460)
  [filedao] remove checkMasterChainDBFile() (iotexproject#3463)
  [api] add crashlog (iotexproject#3456)
  [api] Move generateBlockMeta to grpcserver.go (iotexproject#3303)
  [ioctl] Build action hash command line into new ioctl (iotexproject#3425)
  [ioctl] Build hdwallet export command line into new ioctl (iotexproject#3423)
  [ioctl] Refactor nodereward command in new ioctl (iotexproject#3416)
  [ioctl] Cleanup TestNewNodeDelegateCmd (iotexproject#3421)
  [blockchain] Remove BoltDBDaoOption (iotexproject#3465)
  remove InMemDaoOption (iotexproject#3464)
  [action] add evm london test (iotexproject#3402)
  [ioctl] create main for ioctl/newcmd (iotexproject#3296)
  [ioctl] Build block bucket command line into new ioctl (iotexproject#3386)
  [ioctl] Build hdwallet import command line into new ioctl (iotexproject#3419)
  ...
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.

unreachable code
3 participants