Update dependencies

- uses newer version of go-ethereum required for go1.11
This commit is contained in:
Rob Mulholand
2018-09-13 16:14:35 -05:00
parent 939ead0c82
commit 560305f601
2356 changed files with 331656 additions and 128304 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ one entity can have the database open at a time (for most database backends),
and that entity will be btcd.
When a client wants programmatic access to the data provided by btcd, they'll
likely want to use the [btcrpcclient](https://github.com/btcsuite/btcrpcclient)
likely want to use the [rpcclient](https://github.com/btcsuite/btcd/tree/master/rpcclient)
package which makes use of the [JSON-RPC API](https://github.com/btcsuite/btcd/tree/master/docs/json_rpc_api.md).
However, this package could be extremely useful for any applications requiring
+1
View File
@@ -4,6 +4,7 @@ ffldb
[![Build Status](https://travis-ci.org/btcsuite/btcd.png?branch=master)](https://travis-ci.org/btcsuite/btcd)
[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
[![GoDoc](https://godoc.org/github.com/btcsuite/btcd/database/ffldb?status.png)](http://godoc.org/github.com/btcsuite/btcd/database/ffldb)
=======
Package ffldb implements a driver for the database package that uses leveldb for
the backing metadata and flat files for block storage.
+11 -69
View File
@@ -1255,27 +1255,11 @@ func (tx *transaction) fetchBlockRow(hash *chainhash.Hash) ([]byte, error) {
//
// This function is part of the database.Tx interface implementation.
func (tx *transaction) FetchBlockHeader(hash *chainhash.Hash) ([]byte, error) {
// Ensure transaction state is valid.
if err := tx.checkClosed(); err != nil {
return nil, err
}
// When the block is pending to be written on commit return the bytes
// from there.
if idx, exists := tx.pendingBlocks[*hash]; exists {
blockBytes := tx.pendingBlockData[idx].bytes
return blockBytes[0:blockHdrSize:blockHdrSize], nil
}
// Fetch the block index row and slice off the header. Notice the use
// of the cap on the subslice to prevent the caller from accidentally
// appending into the db data.
blockRow, err := tx.fetchBlockRow(hash)
if err != nil {
return nil, err
}
endOffset := blockLocSize + blockHdrSize
return blockRow[blockLocSize:endOffset:endOffset], nil
return tx.FetchBlockRegion(&database.BlockRegion{
Hash: hash,
Offset: 0,
Len: blockHdrSize,
})
}
// FetchBlockHeaders returns the raw serialized bytes for the block headers
@@ -1294,41 +1278,13 @@ func (tx *transaction) FetchBlockHeader(hash *chainhash.Hash) ([]byte, error) {
//
// This function is part of the database.Tx interface implementation.
func (tx *transaction) FetchBlockHeaders(hashes []chainhash.Hash) ([][]byte, error) {
// Ensure transaction state is valid.
if err := tx.checkClosed(); err != nil {
return nil, err
}
// NOTE: This could check for the existence of all blocks before loading
// any of the headers which would be faster in the failure case, however
// callers will not typically be calling this function with invalid
// values, so optimize for the common case.
// Load the headers.
headers := make([][]byte, len(hashes))
regions := make([]database.BlockRegion, len(hashes))
for i := range hashes {
hash := &hashes[i]
// When the block is pending to be written on commit return the
// bytes from there.
if idx, exists := tx.pendingBlocks[*hash]; exists {
blkBytes := tx.pendingBlockData[idx].bytes
headers[i] = blkBytes[0:blockHdrSize:blockHdrSize]
continue
}
// Fetch the block index row and slice off the header. Notice
// the use of the cap on the subslice to prevent the caller
// from accidentally appending into the db data.
blockRow, err := tx.fetchBlockRow(hash)
if err != nil {
return nil, err
}
endOffset := blockLocSize + blockHdrSize
headers[i] = blockRow[blockLocSize:endOffset:endOffset]
regions[i].Hash = &hashes[i]
regions[i].Offset = 0
regions[i].Len = blockHdrSize
}
return headers, nil
return tx.FetchBlockRegions(regions)
}
// FetchBlock returns the raw serialized bytes for the block identified by the
@@ -1656,19 +1612,6 @@ func (tx *transaction) close() {
}
}
// serializeBlockRow serializes a block row into a format suitable for storage
// into the block index.
func serializeBlockRow(blockLoc blockLocation, blockHdr []byte) []byte {
// The serialized block index row format is:
//
// [0:blockLocSize] Block location
// [blockLocSize:blockLocSize+blockHdrSize] Block header
serializedRow := make([]byte, blockLocSize+blockHdrSize)
copy(serializedRow, serializeBlockLoc(blockLoc))
copy(serializedRow[blockHdrOffset:], blockHdr)
return serializedRow
}
// writePendingAndCommit writes pending block data to the flat block files,
// updates the metadata with their locations as well as the new current write
// location, and commits the metadata to the memory database cache. It also
@@ -1706,8 +1649,7 @@ func (tx *transaction) writePendingAndCommit() error {
// includes the location information needed to locate the block
// on the filesystem as well as the block header since they are
// so commonly needed.
blockHdr := blockData.bytes[0:blockHdrSize]
blockRow := serializeBlockRow(location, blockHdr)
blockRow := serializeBlockLoc(location)
err = tx.blockIdxBucket.Put(blockData.hash[:], blockRow)
if err != nil {
rollback()