From b4c6a5b8abe7fa009747ee37a4704c4be6886d90 Mon Sep 17 00:00:00 2001 From: Dale Rahn <drahn@conformal.com> Date: Thu, 22 Aug 2013 09:32:23 -0400 Subject: [PATCH] fmt --- sqlite3/insertfail_test.go | 7 +++---- sqlite3/operational_test.go | 13 +++++-------- sqlite3/sqlite.go | 6 +++--- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/sqlite3/insertfail_test.go b/sqlite3/insertfail_test.go index e956617f..18961443 100644 --- a/sqlite3/insertfail_test.go +++ b/sqlite3/insertfail_test.go @@ -50,7 +50,7 @@ func failtestOperationalMode(t *testing.T, mode int) { t.Errorf("not right type") } case dbTmNoVerify: // validated block - // no point in testing this + // no point in testing this return } @@ -72,7 +72,7 @@ out: block := blocks[height] mblock := block.MsgBlock() - blockname, _ := block.Sha() + blockname, _ := block.Sha() if height == 248 { // time to corrupt the datbase, to see if it leaves the block or tx in the db @@ -90,7 +90,6 @@ out: } } - if height == 248 { } newheight, err := db.InsertBlock(block) @@ -120,7 +119,7 @@ out: t.Errorf("block still present after failed insert") } // if we got here with no error, testing was successful - break out + break out } if newheight != height { t.Errorf("height mismatch expect %v returned %v", height, newheight) diff --git a/sqlite3/operational_test.go b/sqlite3/operational_test.go index 6caae7f5..8132f91b 100644 --- a/sqlite3/operational_test.go +++ b/sqlite3/operational_test.go @@ -152,11 +152,10 @@ out: blkSha, _ := block.Sha() if *newSha != *blkSha { - t.Errorf("Newest block sha does not match freshly inserted one %v %v ", newSha, blkSha) + t.Errorf("Newest block sha does not match freshly inserted one %v %v ", newSha, blkSha) } } - // now that db is populated, do some additional test testFetchRangeHeight(t, db, blocks) @@ -365,11 +364,10 @@ 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 + var testcnt int64 = 100 shanames := make([]*btcwire.ShaHash, len(blocks)) @@ -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) () } } - } diff --git a/sqlite3/sqlite.go b/sqlite3/sqlite.go index 5b6a79c6..8f68d352 100644 --- a/sqlite3/sqlite.go +++ b/sqlite3/sqlite.go @@ -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 { @@ -649,7 +649,7 @@ func (db *SqliteDb) InsertBlock(block *btcutil.Block) (int64, error) { if success { return } - + for txidx := 0; txidx <= txinsertidx; txidx++ { tx := mblock.Transactions[txidx] @@ -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) }