func loadBlocks(filename string) (blocks []*soterutil.Block, err error) {
	filename = filepath.Join("testdata/", filename)
	var network = wire.MainNet
	var dr io.Reader
	var fi io.ReadCloser
	fi, err = os.Open(filename)
	if err != nil {
		return
	}
	if strings.HasSuffix(filename, ".bz2") {
		dr = bzip2.NewReader(fi)
	} else {
		dr = fi
	}
	defer fi.Close()
	var block *soterutil.Block
	err = nil
	for height := int64(1); err == nil; height++ {
		var rintbuf uint32
		err = binary.Read(dr, binary.LittleEndian, &rintbuf)
		if err == io.EOF {
			height--
			err = nil
			break
		}
		if err != nil {
			break
		}
		if rintbuf != uint32(network) {
			break
		}
		err = binary.Read(dr, binary.LittleEndian, &rintbuf)
		blocklen := rintbuf
		rbytes := make([]byte, blocklen)
		dr.Read(rbytes)
		block, err = soterutil.NewBlockFromBytes(rbytes)
		if err != nil {
			return
		}
		blocks = append(blocks, block)
	}
	return
}
loadBlocks reads files containing bitcoin block data (gzipped but otherwise
in the format bitcoind writes) from disk and returns them as an array of
soterutil.Block.  This is largely borrowed from the test code in btcdb.
package blockchain
import (
	"compress/bzip2"
	"encoding/binary"
	"fmt"
	"io"
	"os"
	"path/filepath"
	"strings"
	"time"
	"github.com/soteria-dag/soterd/chaincfg"
	"github.com/soteria-dag/soterd/chaincfg/chainhash"
	"github.com/soteria-dag/soterd/database"
	_ "github.com/soteria-dag/soterd/database/ffldb"
	"github.com/soteria-dag/soterd/soterutil"
	"github.com/soteria-dag/soterd/txscript"
	"github.com/soteria-dag/soterd/wire"
)
const (
	testDbType = "ffldb"
	testDbRoot = "testdbs"
	blockDataNet = wire.MainNet
)
func fileExists(name string) bool {
	if _, err := os.Stat(name); err != nil {
		if os.IsNotExist(err) {
			return false
		}
	}
	return true
}
func isSupportedDbType(dbType string) bool {
	supportedDrivers := database.SupportedDrivers()
	for _, driver := range supportedDrivers {
		if dbType == driver {
			return true
		}
	}
	return false
}