This commit is contained in:
Dave Collins 2013-09-09 15:50:13 -05:00
parent 30f2003301
commit 85553133ce
3 changed files with 10 additions and 12 deletions

View file

@ -45,8 +45,8 @@ type LevelDb struct {
// leveldb pieces
lDb *leveldb.DB
ro *opt.ReadOptions
wo *opt.WriteOptions
ro *opt.ReadOptions
wo *opt.WriteOptions
lbatch *leveldb.Batch
@ -134,7 +134,7 @@ func openDB(dbpath string, flag opt.OptionsFlag) (pbdb btcdb.Db, err error) {
var tlDb *leveldb.DB
defer func() {
if err == nil {
db.lDb = tlDb
db.lDb = tlDb
db.txUpdateMap = map[btcwire.ShaHash]*txUpdateObj{}
@ -200,12 +200,12 @@ func (db *LevelDb) Close() {
func (db *LevelDb) DropAfterBlockBySha(sha *btcwire.ShaHash) (rerr error) {
db.dbLock.Lock()
defer db.dbLock.Unlock()
defer func () {
defer func() {
if rerr == nil {
rerr = db.processBatches()
}
} ()
}()
startheight := db.nextBlock - 1
@ -256,12 +256,11 @@ func (db *LevelDb) DropAfterBlockBySha(sha *btcwire.ShaHash) (rerr error) {
func (db *LevelDb) InsertBlock(block *btcutil.Block) (height int64, rerr error) {
db.dbLock.Lock()
defer db.dbLock.Unlock()
defer func () {
defer func() {
if rerr == nil {
rerr = db.processBatches()
}
} ()
}()
blocksha, err := block.Sha()
if err != nil {

View file

@ -282,7 +282,6 @@ func testBackout(t *testing.T, mode int) {
}
}
var savedblocks []*btcutil.Block
func loadBlocks(t *testing.T, file string) (blocks []*btcutil.Block, err error) {