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

blockchain: Remove unused dump function. #1001

Merged
merged 1 commit into from
Jan 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions blockchain/chainio.go
Original file line number Diff line number Diff line change
Expand Up @@ -1726,43 +1726,6 @@ func (b *BlockChain) HeightRange(startHeight, endHeight int64) ([]chainhash.Hash
return hashList, err
}

// DumpBlockChain dumps the blockchain to a map of height --> serialized bytes.
// Mainly used for generating tests.
func DumpBlockChain(db database.DB, height int64) (map[int64][]byte, error) {
blockchain := make(map[int64][]byte)
var hash chainhash.Hash
err := db.View(func(dbTx database.Tx) error {
for i := int64(0); i <= height; i++ {
// Fetch blocks and put them in the map
var serializedHeight [4]byte
dbnamespace.ByteOrder.PutUint32(serializedHeight[:], uint32(height))

meta := dbTx.Metadata()
heightIndex := meta.Bucket(dbnamespace.HeightIndexBucketName)
hashBytes := heightIndex.Get(serializedHeight[:])
if hashBytes == nil {
return fmt.Errorf("no block at height %d exists", height)
}
copy(hash[:], hashBytes)

blockBLocal, err := dbTx.FetchBlock(&hash)
if err != nil {
return err
}
blockB := make([]byte, len(blockBLocal))
copy(blockB, blockBLocal)
blockchain[i] = blockB
}

return nil
})
if err != nil {
return nil, err
}

return blockchain, err
}

// -----------------------------------------------------------------------------
// The threshold state consists of individual threshold cache buckets for each
// cache id under one main threshold state bucket. Each threshold cache bucket
Expand Down