This commit is contained in:
Dale Rahn 2013-08-22 09:32:23 -04:00
parent 840708a3e7
commit b4c6a5b8ab
3 changed files with 11 additions and 15 deletions

View file

@ -90,7 +90,6 @@ out:
}
}
if height == 248 {
}
newheight, err := db.InsertBlock(block)

View file

@ -156,7 +156,6 @@ out:
}
}
// now that db is populated, do some additional test
testFetchRangeHeight(t, db, blocks)
@ -365,8 +364,7 @@ func loadBlocks(t *testing.T, file string) (blocks []*btcutil.Block, err error)
return
}
func testFetchRangeHeight(t *testing.T, db btcdb.Db, blocks []*btcutil.Block) () {
func testFetchRangeHeight(t *testing.T, db btcdb.Db, blocks []*btcutil.Block) {
var testincrement int64 = 50
var testcnt int64 = 100
@ -396,8 +394,8 @@ func testFetchRangeHeight(t *testing.T, db btcdb.Db, blocks []*btcutil.Block) ()
}
if endheight == btcdb.AllShas {
if int64(len(shalist)) != nBlocks - startheight {
t.Errorf("FetchRangeHeight: expected A %v shas, got %v", nBlocks - startheight, len(shalist))
if int64(len(shalist)) != nBlocks-startheight {
t.Errorf("FetchRangeHeight: expected A %v shas, got %v", nBlocks-startheight, len(shalist))
}
} else {
if int64(len(shalist)) != testcnt {
@ -412,5 +410,4 @@ func testFetchRangeHeight(t *testing.T, db btcdb.Db, blocks []*btcutil.Block) ()
}
}
}

View file

@ -576,7 +576,7 @@ func (db *SqliteDb) DropAfterBlockBySha(sha *btcwire.ShaHash) (err error) {
return db.delFromDB(keepidx)
}
func (db *SqliteDb) delFromDB(keepidx int64) (error) {
func (db *SqliteDb) delFromDB(keepidx int64) error {
tx := &db.txState
_, err := tx.tx.Exec("DELETE FROM txtmp WHERE blockid > ?", keepidx)
if err != nil {
@ -659,7 +659,7 @@ func (db *SqliteDb) InsertBlock(block *btcutil.Block) (int64, error) {
}
}
err = db.delFromDB(newheight -1)
err = db.delFromDB(newheight - 1)
if err != nil {
log.Warnf("Error during block insert unwind %v %v", blocksha, err)
}