Gofmt.
This commit is contained in:
parent
3bc401fed1
commit
fc11da9ca0
4 changed files with 28 additions and 31 deletions
|
@ -5,7 +5,7 @@
|
|||
package ldb
|
||||
|
||||
import (
|
||||
//"fmt"
|
||||
//"fmt"
|
||||
)
|
||||
|
||||
// InvalidateTxCache clear/release all cached transactions.
|
||||
|
|
|
@ -23,7 +23,7 @@ func Test_dupTx(t *testing.T) {
|
|||
_ = os.RemoveAll(dbnamever)
|
||||
db, err := btcdb.CreateDB("leveldb", dbname)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to open test database %v", err)
|
||||
t.Errorf("Failed to open test database %v", err)
|
||||
return
|
||||
}
|
||||
defer os.RemoveAll(dbname)
|
||||
|
@ -75,7 +75,6 @@ out:
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
newheight, err := db.InsertBlock(block)
|
||||
if err != nil {
|
||||
t.Errorf("failed to insert block %v err %v", height, err)
|
||||
|
@ -116,7 +115,7 @@ out:
|
|||
|
||||
hash, _ := btcwire.NewShaHashFromStr("df2b060fa2e5e9c8ed5eaf6a45c13753ec8c63282b2688322eba40cd98ea067a")
|
||||
|
||||
po := btcwire.NewOutPoint(hash, 0)
|
||||
po := btcwire.NewOutPoint(hash, 0)
|
||||
txI := btcwire.NewTxIn(po, []byte("garbage"))
|
||||
txO := btcwire.NewTxOut(50000000, []byte("garbageout"))
|
||||
|
||||
|
@ -133,7 +132,7 @@ out:
|
|||
for _, lr := range listReply {
|
||||
if lr.Err != nil {
|
||||
t.Errorf("sha %v spent %v err %v\n", lr.Sha,
|
||||
lr.TxSpent, lr.Err)
|
||||
lr.TxSpent, lr.Err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +147,7 @@ out:
|
|||
for _, lr := range listReply {
|
||||
if lr.Err != btcdb.TxShaMissing {
|
||||
t.Errorf("sha %v spent %v err %v\n", lr.Sha,
|
||||
lr.TxSpent, lr.Err)
|
||||
lr.TxSpent, lr.Err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,8 +159,8 @@ out:
|
|||
} else {
|
||||
for _, lr := range txReply {
|
||||
if lr.Err != nil {
|
||||
fmt.Errorf("stx %v spent %v err %v\n", lr.Sha,
|
||||
lr.TxSpent, lr.Err)
|
||||
fmt.Errorf("stx %v spent %v err %v\n", lr.Sha,
|
||||
lr.TxSpent, lr.Err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ type LevelDb struct {
|
|||
lastBlkSha btcwire.ShaHash
|
||||
lastBlkIdx int64
|
||||
|
||||
txUpdateMap map[btcwire.ShaHash]*txUpdateObj
|
||||
txUpdateMap map[btcwire.ShaHash]*txUpdateObj
|
||||
txSpentUpdateMap map[btcwire.ShaHash]*spentTxUpdate
|
||||
}
|
||||
|
||||
|
@ -379,7 +379,7 @@ func (db *LevelDb) InsertBlock(block *btcutil.Block) (height int64, rerr error)
|
|||
}
|
||||
if txsha.IsEqual(dupsha) {
|
||||
// marking TxOut[0] as spent
|
||||
po := btcwire.NewOutPoint(dupsha, 0)
|
||||
po := btcwire.NewOutPoint(dupsha, 0)
|
||||
txI := btcwire.NewTxIn(po, []byte("garbage"))
|
||||
|
||||
var spendtx btcwire.MsgTx
|
||||
|
@ -397,7 +397,7 @@ func (db *LevelDb) InsertBlock(block *btcutil.Block) (height int64, rerr error)
|
|||
}
|
||||
if txsha.IsEqual(dupsha) {
|
||||
// marking TxOut[0] as spent
|
||||
po := btcwire.NewOutPoint(dupsha, 0)
|
||||
po := btcwire.NewOutPoint(dupsha, 0)
|
||||
txI := btcwire.NewTxIn(po, []byte("garbage"))
|
||||
|
||||
var spendtx btcwire.MsgTx
|
||||
|
@ -501,13 +501,13 @@ func (db *LevelDb) setclearSpentData(txsha *btcwire.ShaHash, idx uint32, set boo
|
|||
}
|
||||
|
||||
// need to reslice the list to exclude the most recent.
|
||||
sTx := spentTxList [len(spentTxList) -1]
|
||||
spentTxList [len(spentTxList) -1] = nil
|
||||
if len (spentTxList) == 1 {
|
||||
sTx := spentTxList[len(spentTxList)-1]
|
||||
spentTxList[len(spentTxList)-1] = nil
|
||||
if len(spentTxList) == 1 {
|
||||
// write entry to delete tx from spent pool
|
||||
// XXX
|
||||
} else {
|
||||
spentTxList = spentTxList [:len(spentTxList)-1]
|
||||
spentTxList = spentTxList[:len(spentTxList)-1]
|
||||
// XXX format sTxList and set update Table
|
||||
}
|
||||
|
||||
|
@ -551,7 +551,7 @@ func (db *LevelDb) setclearSpentData(txsha *btcwire.ShaHash, idx uint32, set boo
|
|||
if fullySpent {
|
||||
var txSu *spentTxUpdate
|
||||
// Look up Tx in fully spent table
|
||||
if txSuOld, ok := db.txSpentUpdateMap[*txsha] ; ok {
|
||||
if txSuOld, ok := db.txSpentUpdateMap[*txsha]; ok {
|
||||
txSu = txSuOld
|
||||
} else {
|
||||
var txSuStore spentTxUpdate
|
||||
|
|
14
ldb/tx.go
14
ldb/tx.go
|
@ -9,8 +9,8 @@ import (
|
|||
"encoding/binary"
|
||||
"fmt"
|
||||
"github.com/conformal/btcdb"
|
||||
"github.com/conformal/goleveldb/leveldb"
|
||||
"github.com/conformal/btcwire"
|
||||
"github.com/conformal/goleveldb/leveldb"
|
||||
)
|
||||
|
||||
type txUpdateObj struct {
|
||||
|
@ -31,7 +31,7 @@ type spentTx struct {
|
|||
delete bool
|
||||
}
|
||||
type spentTxUpdate struct {
|
||||
txl []*spentTx
|
||||
txl []*spentTx
|
||||
delete bool
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ func (db *LevelDb) getTxFullySpent(txsha *btcwire.ShaHash) ([]*spentTx, error) {
|
|||
|
||||
for i := range spentTxList {
|
||||
var sTx spentTx
|
||||
var blkHeight int64
|
||||
var blkHeight int64
|
||||
var txOff, txLen, numTxO int32
|
||||
|
||||
err := binary.Read(txR, binary.LittleEndian, &blkHeight)
|
||||
|
@ -275,7 +275,7 @@ func (db *LevelDb) FetchTxByShaList(txShaList []*btcwire.ShaHash) []*btcdb.TxLis
|
|||
stx := sTxList[idx]
|
||||
|
||||
tx, blockSha, _, _, err = db.fetchTxDataByLoc(
|
||||
stx.blkHeight, stx.txoff, stx.txlen, []byte{})
|
||||
stx.blkHeight, stx.txoff, stx.txlen, []byte{})
|
||||
if err == nil {
|
||||
btxspent = make([]bool, len(tx.TxOut))
|
||||
for i := range btxspent {
|
||||
|
@ -384,13 +384,12 @@ func (db *LevelDb) FetchTxBySha(txsha *btcwire.ShaHash) ([]*btcdb.TxListReply, e
|
|||
replylen += len(sTxList)
|
||||
}
|
||||
|
||||
replies := make ([]*btcdb.TxListReply, replylen)
|
||||
|
||||
replies := make([]*btcdb.TxListReply, replylen)
|
||||
|
||||
if fSerr == nil {
|
||||
for _, stx := range sTxList {
|
||||
tx, blksha, _, _, err := db.fetchTxDataByLoc(
|
||||
stx.blkHeight, stx.txoff, stx.txlen, []byte{})
|
||||
stx.blkHeight, stx.txoff, stx.txlen, []byte{})
|
||||
if err != nil {
|
||||
if err != leveldb.ErrNotFound {
|
||||
return []*btcdb.TxListReply{}, err
|
||||
|
@ -419,4 +418,3 @@ func (db *LevelDb) FetchTxBySha(txsha *btcwire.ShaHash) ([]*btcdb.TxListReply, e
|
|||
}
|
||||
return replies, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue