Skip to content

Commit

Permalink
core: improved chainDb using sequential keys
Browse files Browse the repository at this point in the history
  • Loading branch information
zsfelfoldi committed Jun 7, 2016
1 parent 5a458da commit f9917c8
Show file tree
Hide file tree
Showing 24 changed files with 726 additions and 365 deletions.
2 changes: 1 addition & 1 deletion cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func dump(ctx *cli.Context) {
for _, arg := range ctx.Args() {
var block *types.Block
if hashish(arg) {
block = chain.GetBlock(common.HexToHash(arg))
block = chain.GetBlockByHash(common.HexToHash(arg))
} else {
num, _ := strconv.Atoi(arg)
block = chain.GetBlockByNumber(uint64(num))
Expand Down
2 changes: 1 addition & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ func MustMakeChainConfig(ctx *cli.Context) *core.ChainConfig {

// MustMakeChainConfigFromDb reads the chain configuration from the given database.
func MustMakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *core.ChainConfig {
genesis := core.GetBlock(db, core.GetCanonicalHash(db, 0))
genesis := core.GetBlock(db, core.GetCanonicalHash(db, 0), 0)

if genesis != nil {
// Existing genesis block, use stored config if available.
Expand Down
10 changes: 5 additions & 5 deletions core/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@ func makeChainForBench(db ethdb.Database, full bool, count uint64) {
hash = header.Hash()
WriteHeader(db, header)
WriteCanonicalHash(db, hash, n)
WriteTd(db, hash, big.NewInt(int64(n+1)))
WriteTd(db, hash, n, big.NewInt(int64(n+1)))
if full || n == 0 {
block := types.NewBlockWithHeader(header)
WriteBody(db, hash, block.Body())
WriteBlockReceipts(db, hash, nil)
WriteBody(db, hash, n, block.Body())
WriteBlockReceipts(db, hash, n, nil)
}
}
}
Expand Down Expand Up @@ -287,8 +287,8 @@ func benchReadChain(b *testing.B, full bool, count uint64) {
header := chain.GetHeaderByNumber(n)
if full {
hash := header.Hash()
GetBody(db, hash)
GetBlockReceipts(db, hash)
GetBody(db, hash, n)
GetBlockReceipts(db, hash, n)
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (v *BlockValidator) ValidateBlock(block *types.Block) error {
return &KnownBlockError{block.Number(), block.Hash()}
}
}
parent := v.bc.GetBlock(block.ParentHash())
parent := v.bc.GetBlock(block.ParentHash(), block.NumberU64()-1)
if parent == nil {
return ParentError(block.ParentHash())
}
Expand Down
Loading

0 comments on commit f9917c8

Please sign in to comment.