2014-01-09 06:54:52 +01:00
|
|
|
// Copyright (c) 2013-2014 Conformal Systems LLC.
|
2013-08-03 17:20:05 +02:00
|
|
|
// Use of this source code is governed by an ISC
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package ldb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2014-07-03 02:47:24 +02:00
|
|
|
|
2013-08-03 17:20:05 +02:00
|
|
|
"github.com/conformal/btcdb"
|
|
|
|
"github.com/conformal/btcwire"
|
|
|
|
)
|
|
|
|
|
|
|
|
// FetchSha returns the datablock and pver for the given ShaHash.
|
|
|
|
// This is a testing only interface.
|
|
|
|
func FetchSha(db btcdb.Db, sha *btcwire.ShaHash) (buf []byte, pver uint32,
|
|
|
|
blkid int64, err error) {
|
|
|
|
sqldb, ok := db.(*LevelDb)
|
|
|
|
if !ok {
|
2014-09-16 20:43:09 +02:00
|
|
|
err = fmt.Errorf("invalid data type")
|
2013-08-03 17:20:05 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
buf, blkid, err = sqldb.fetchSha(sha)
|
|
|
|
return
|
|
|
|
}
|