Skip to content

Commit

Permalink
cmd: optimize parseDumpConfig func
Browse files Browse the repository at this point in the history
  • Loading branch information
VM committed Jan 17, 2024
1 parent ccd79af commit 839eae5
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,26 +607,38 @@ func parseDumpConfig(ctx *cli.Context, stack *node.Node) (*state.DumpConfig, eth
arg := ctx.Args().First()
if hashish(arg) {
hash := common.HexToHash(arg)
if contain := triedb.ContainDiffLayer(hash); !contain {
log.Crit("PBSS doesn't contain specified hash", "hash", arg)
}
// if contain := triedb.ContainDiffLayer(hash); !contain {
// log.Crit("PBSS doesn't contain specified hash", "hash", arg)
// }
if number := rawdb.ReadHeaderNumber(db, hash); number != nil {
header = rawdb.ReadHeader(db, hash, *number)
if header == nil {
return nil, nil, common.Hash{}, fmt.Errorf("block_hash %x header not found", hash)
}
} else {
return nil, nil, common.Hash{}, fmt.Errorf("block %x not found", hash)
return nil, nil, common.Hash{}, fmt.Errorf("block_hash %x not found", hash)
}
if contain := triedb.ContainDiffLayer(header.Root); !contain {
log.Crit("PBSS doesn't contain specified hash", "block_hash", arg, "mpt_root", header.Root)
}
} else {
number, err := strconv.ParseUint(arg, 10, 64)
if err != nil {
return nil, nil, common.Hash{}, err
}
if hash := rawdb.ReadCanonicalHash(db, number); hash != (common.Hash{}) {
if contain := triedb.ContainDiffLayer(hash); !contain {
log.Crit("PBSS doesn't contain specified block number", "number", number)
}
// if contain := triedb.ContainDiffLayer(hash); !contain {
// log.Crit("PBSS doesn't contain specified block number", "number", number)
// }
header = rawdb.ReadHeader(db, hash, number)
if header == nil {
return nil, nil, common.Hash{}, fmt.Errorf("block_id %d header not found", number)
}
if contain := triedb.ContainDiffLayer(header.Root); !contain {
log.Crit("PBSS doesn't contain specified block number", "block_height", number, "mpt_root", header.Root)
}
} else {
return nil, nil, common.Hash{}, fmt.Errorf("header for block %d not found", number)
return nil, nil, common.Hash{}, fmt.Errorf("header for block_height %d not found", number)
}
}
} else {
Expand Down

0 comments on commit 839eae5

Please sign in to comment.