Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Change markasdead txns function to updateheight
Browse files Browse the repository at this point in the history
  • Loading branch information
cpacia committed Apr 8, 2017
1 parent 93b4285 commit 3e72022
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bitcoin/listeners/wallet_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (l *WalletListener) OnTransactionReceived(cb spvwallet.TransactionCallback)
OrderId: metadata.OrderId,
Thumbnail: metadata.Thumbnail,
Height: cb.Height,
CanBumpFee: true,
CanBumpFee: cb.Value > 0,
}
l.broadcast <- n
}
Expand Down
6 changes: 3 additions & 3 deletions repo/db/txns.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,19 @@ func (t *TxnsDB) Delete(txid *chainhash.Hash) error {
return nil
}

func (t *TxnsDB) MarkAsDead(txid chainhash.Hash) error {
func (t *TxnsDB) UpdateHeight(txid chainhash.Hash, height int) error {
t.lock.Lock()
defer t.lock.Unlock()
tx, err := t.db.Begin()
if err != nil {
return err
}
stmt, err := tx.Prepare("update txns set height=-1 where txid=?")
stmt, err := tx.Prepare("update txns set height=? where txid=?")
if err != nil {
return err
}
defer stmt.Close()
_, err = stmt.Exec(txid.String())
_, err = stmt.Exec(height, txid.String())
if err != nil {
tx.Rollback()
return err
Expand Down
6 changes: 3 additions & 3 deletions repo/db/txns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestDeleteTxns(t *testing.T) {
}
}

func TestTxnsDB_MarkAsDead(t *testing.T) {
func TestTxnsDB_UpdateHeight(t *testing.T) {
tx := wire.NewMsgTx(wire.TxVersion)
txHex := "0100000001cbfe4948ebc9113244b802a96e4940fa063c0455a16ca1f39a1e1db03837d9c701000000da004830450221008994e3dba54cb0ea23ca008d0e361b4339ee7b44b5e9101f6837e6a1a89ce044022051be859c68a547feaf60ffacc43f528cf2963c088bde33424d859274505e3f450147304402206cd4ef92cc7f2862c67810479013330fcafe4d468f1370563d4dff6be5bcbedc02207688a09163e615bc82299a29e987e1d718cb99a91d46a1ab13d18c0f6e616a1601475221024760c9ba5fa6241da6ee8601f0266f0e0592f53735703f0feaae23eda6673ae821038cfa8e97caaafbe21455803043618440c28c501ec32d6ece6865003165a0d4d152aeffffffff029ae2c700000000001976a914f72f20a739ec3c3df1a1fd7eff122d13bd5ca39188acb64784240000000017a9140be09225644b4cfdbb472028d8ccaf6df736025c8700000000"
raw, _ := hex.DecodeString(txHex)
Expand All @@ -142,12 +142,12 @@ func TestTxnsDB_MarkAsDead(t *testing.T) {
if err != nil {
t.Error(err)
}
err = txdb.MarkAsDead(tx.TxHash())
err = txdb.UpdateHeight(tx.TxHash(), -1)
if err != nil {
t.Error(err)
}
_, txn, err := txdb.Get(tx.TxHash())
if txn.Height != -1 {
t.Error("Txn db failed to mark as dead")
t.Error("Txn db failed to update height")
}
}
4 changes: 2 additions & 2 deletions vendor/github.com/OpenBazaar/spvwallet/datastore.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/OpenBazaar/spvwallet/sortsignsend.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions vendor/github.com/OpenBazaar/spvwallet/txstore.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3e72022

Please sign in to comment.