Changed TxIn.PreviousOutpoint to TxIn.PreviousOutPoint after btcwire API change.
This commit is contained in:
parent
02647404fa
commit
1bbd1e9cba
4 changed files with 19 additions and 19 deletions
14
mempool.go
14
mempool.go
|
@ -340,7 +340,7 @@ func checkInputsStandard(tx *btcutil.Tx, txStore btcchain.TxStore) error {
|
||||||
// It is safe to elide existence and index checks here since
|
// It is safe to elide existence and index checks here since
|
||||||
// they have already been checked prior to calling this
|
// they have already been checked prior to calling this
|
||||||
// function.
|
// function.
|
||||||
prevOut := txIn.PreviousOutpoint
|
prevOut := txIn.PreviousOutPoint
|
||||||
originTx := txStore[prevOut.Hash].Tx.MsgTx()
|
originTx := txStore[prevOut.Hash].Tx.MsgTx()
|
||||||
originPkScript := originTx.TxOut[prevOut.Index].PkScript
|
originPkScript := originTx.TxOut[prevOut.Index].PkScript
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ func (mp *txMemPool) removeOrphan(txHash *btcwire.ShaHash) {
|
||||||
|
|
||||||
// Remove the reference from the previous orphan index.
|
// Remove the reference from the previous orphan index.
|
||||||
for _, txIn := range tx.MsgTx().TxIn {
|
for _, txIn := range tx.MsgTx().TxIn {
|
||||||
originTxHash := txIn.PreviousOutpoint.Hash
|
originTxHash := txIn.PreviousOutPoint.Hash
|
||||||
if orphans, exists := mp.orphansByPrev[originTxHash]; exists {
|
if orphans, exists := mp.orphansByPrev[originTxHash]; exists {
|
||||||
for e := orphans.Front(); e != nil; e = e.Next() {
|
for e := orphans.Front(); e != nil; e = e.Next() {
|
||||||
if e.Value.(*btcutil.Tx) == tx {
|
if e.Value.(*btcutil.Tx) == tx {
|
||||||
|
@ -485,7 +485,7 @@ func (mp *txMemPool) addOrphan(tx *btcutil.Tx) {
|
||||||
|
|
||||||
mp.orphans[*tx.Sha()] = tx
|
mp.orphans[*tx.Sha()] = tx
|
||||||
for _, txIn := range tx.MsgTx().TxIn {
|
for _, txIn := range tx.MsgTx().TxIn {
|
||||||
originTxHash := txIn.PreviousOutpoint.Hash
|
originTxHash := txIn.PreviousOutPoint.Hash
|
||||||
if mp.orphansByPrev[originTxHash] == nil {
|
if mp.orphansByPrev[originTxHash] == nil {
|
||||||
mp.orphansByPrev[originTxHash] = list.New()
|
mp.orphansByPrev[originTxHash] = list.New()
|
||||||
}
|
}
|
||||||
|
@ -610,7 +610,7 @@ func (mp *txMemPool) removeTransaction(tx *btcutil.Tx) {
|
||||||
// by the pool.
|
// by the pool.
|
||||||
if txDesc, exists := mp.pool[*txHash]; exists {
|
if txDesc, exists := mp.pool[*txHash]; exists {
|
||||||
for _, txIn := range txDesc.Tx.MsgTx().TxIn {
|
for _, txIn := range txDesc.Tx.MsgTx().TxIn {
|
||||||
delete(mp.outpoints, txIn.PreviousOutpoint)
|
delete(mp.outpoints, txIn.PreviousOutPoint)
|
||||||
}
|
}
|
||||||
delete(mp.pool, *txHash)
|
delete(mp.pool, *txHash)
|
||||||
mp.lastUpdated = time.Now()
|
mp.lastUpdated = time.Now()
|
||||||
|
@ -642,7 +642,7 @@ func (mp *txMemPool) RemoveDoubleSpends(tx *btcutil.Tx) {
|
||||||
defer mp.Unlock()
|
defer mp.Unlock()
|
||||||
|
|
||||||
for _, txIn := range tx.MsgTx().TxIn {
|
for _, txIn := range tx.MsgTx().TxIn {
|
||||||
if txRedeemer, ok := mp.outpoints[txIn.PreviousOutpoint]; ok {
|
if txRedeemer, ok := mp.outpoints[txIn.PreviousOutPoint]; ok {
|
||||||
if !txRedeemer.Sha().IsEqual(tx.Sha()) {
|
if !txRedeemer.Sha().IsEqual(tx.Sha()) {
|
||||||
mp.removeTransaction(txRedeemer)
|
mp.removeTransaction(txRedeemer)
|
||||||
}
|
}
|
||||||
|
@ -665,7 +665,7 @@ func (mp *txMemPool) addTransaction(tx *btcutil.Tx, height, fee int64) {
|
||||||
Fee: fee,
|
Fee: fee,
|
||||||
}
|
}
|
||||||
for _, txIn := range tx.MsgTx().TxIn {
|
for _, txIn := range tx.MsgTx().TxIn {
|
||||||
mp.outpoints[txIn.PreviousOutpoint] = tx
|
mp.outpoints[txIn.PreviousOutPoint] = tx
|
||||||
}
|
}
|
||||||
mp.lastUpdated = time.Now()
|
mp.lastUpdated = time.Now()
|
||||||
}
|
}
|
||||||
|
@ -678,7 +678,7 @@ func (mp *txMemPool) addTransaction(tx *btcutil.Tx, height, fee int64) {
|
||||||
// This function MUST be called with the mempool lock held (for reads).
|
// This function MUST be called with the mempool lock held (for reads).
|
||||||
func (mp *txMemPool) checkPoolDoubleSpend(tx *btcutil.Tx) error {
|
func (mp *txMemPool) checkPoolDoubleSpend(tx *btcutil.Tx) error {
|
||||||
for _, txIn := range tx.MsgTx().TxIn {
|
for _, txIn := range tx.MsgTx().TxIn {
|
||||||
if txR, exists := mp.outpoints[txIn.PreviousOutpoint]; exists {
|
if txR, exists := mp.outpoints[txIn.PreviousOutPoint]; exists {
|
||||||
str := fmt.Sprintf("transaction %v in the pool "+
|
str := fmt.Sprintf("transaction %v in the pool "+
|
||||||
"already spends the same coins", txR.Sha())
|
"already spends the same coins", txR.Sha())
|
||||||
return txRuleError(btcwire.RejectDuplicate, str)
|
return txRuleError(btcwire.RejectDuplicate, str)
|
||||||
|
|
10
mining.go
10
mining.go
|
@ -231,7 +231,7 @@ func createCoinbaseTx(coinbaseScript []byte, nextBlockHeight int64, addr btcutil
|
||||||
tx.AddTxIn(&btcwire.TxIn{
|
tx.AddTxIn(&btcwire.TxIn{
|
||||||
// Coinbase transactions have no inputs, so previous outpoint is
|
// Coinbase transactions have no inputs, so previous outpoint is
|
||||||
// zero hash and max index.
|
// zero hash and max index.
|
||||||
PreviousOutpoint: *btcwire.NewOutPoint(&btcwire.ShaHash{},
|
PreviousOutPoint: *btcwire.NewOutPoint(&btcwire.ShaHash{},
|
||||||
btcwire.MaxPrevOutIndex),
|
btcwire.MaxPrevOutIndex),
|
||||||
SignatureScript: coinbaseScript,
|
SignatureScript: coinbaseScript,
|
||||||
Sequence: btcwire.MaxTxInSequenceNum,
|
Sequence: btcwire.MaxTxInSequenceNum,
|
||||||
|
@ -287,8 +287,8 @@ func calcPriority(tx *btcutil.Tx, serializedTxSize int, inputValueAge float64) f
|
||||||
// the store at the provided height.
|
// the store at the provided height.
|
||||||
func spendTransaction(txStore btcchain.TxStore, tx *btcutil.Tx, height int64) error {
|
func spendTransaction(txStore btcchain.TxStore, tx *btcutil.Tx, height int64) error {
|
||||||
for _, txIn := range tx.MsgTx().TxIn {
|
for _, txIn := range tx.MsgTx().TxIn {
|
||||||
originHash := &txIn.PreviousOutpoint.Hash
|
originHash := &txIn.PreviousOutPoint.Hash
|
||||||
originIndex := txIn.PreviousOutpoint.Index
|
originIndex := txIn.PreviousOutPoint.Index
|
||||||
if originTx, exists := txStore[*originHash]; exists {
|
if originTx, exists := txStore[*originHash]; exists {
|
||||||
originTx.Spent[originIndex] = true
|
originTx.Spent[originIndex] = true
|
||||||
}
|
}
|
||||||
|
@ -523,8 +523,8 @@ mempoolLoop:
|
||||||
prioItem := &txPrioItem{tx: txDesc.Tx}
|
prioItem := &txPrioItem{tx: txDesc.Tx}
|
||||||
inputValueAge := float64(0.0)
|
inputValueAge := float64(0.0)
|
||||||
for _, txIn := range tx.MsgTx().TxIn {
|
for _, txIn := range tx.MsgTx().TxIn {
|
||||||
originHash := &txIn.PreviousOutpoint.Hash
|
originHash := &txIn.PreviousOutPoint.Hash
|
||||||
originIndex := txIn.PreviousOutpoint.Index
|
originIndex := txIn.PreviousOutPoint.Index
|
||||||
txData, exists := txStore[*originHash]
|
txData, exists := txStore[*originHash]
|
||||||
if !exists || txData.Err != nil || txData.Tx == nil {
|
if !exists || txData.Err != nil || txData.Tx == nil {
|
||||||
if !mempool.HaveTransaction(originHash) {
|
if !mempool.HaveTransaction(originHash) {
|
||||||
|
|
|
@ -833,8 +833,8 @@ func createVinList(mtx *btcwire.MsgTx) ([]btcjson.Vin, error) {
|
||||||
if btcchain.IsCoinBase(tx) {
|
if btcchain.IsCoinBase(tx) {
|
||||||
vinList[i].Coinbase = hex.EncodeToString(v.SignatureScript)
|
vinList[i].Coinbase = hex.EncodeToString(v.SignatureScript)
|
||||||
} else {
|
} else {
|
||||||
vinList[i].Txid = v.PreviousOutpoint.Hash.String()
|
vinList[i].Txid = v.PreviousOutPoint.Hash.String()
|
||||||
vinList[i].Vout = v.PreviousOutpoint.Index
|
vinList[i].Vout = v.PreviousOutPoint.Index
|
||||||
|
|
||||||
disbuf, err := btcscript.DisasmString(v.SignatureScript)
|
disbuf, err := btcscript.DisasmString(v.SignatureScript)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1606,7 +1606,7 @@ func (state *gbtWorkState) blockTemplateResult(useCoinbaseValue bool, submitOld
|
||||||
// when mutiple inputs reference the same transaction.
|
// when mutiple inputs reference the same transaction.
|
||||||
dependsMap := make(map[int64]struct{})
|
dependsMap := make(map[int64]struct{})
|
||||||
for _, txIn := range tx.TxIn {
|
for _, txIn := range tx.TxIn {
|
||||||
if idx, ok := txIndex[txIn.PreviousOutpoint.Hash]; ok {
|
if idx, ok := txIndex[txIn.PreviousOutPoint.Hash]; ok {
|
||||||
dependsMap[idx] = struct{}{}
|
dependsMap[idx] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2306,7 +2306,7 @@ func handleGetRawMempool(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{
|
||||||
Depends: make([]string, 0),
|
Depends: make([]string, 0),
|
||||||
}
|
}
|
||||||
for _, txIn := range desc.Tx.MsgTx().TxIn {
|
for _, txIn := range desc.Tx.MsgTx().TxIn {
|
||||||
hash := &txIn.PreviousOutpoint.Hash
|
hash := &txIn.PreviousOutPoint.Hash
|
||||||
if s.server.txMemPool.HaveTransaction(hash) {
|
if s.server.txMemPool.HaveTransaction(hash) {
|
||||||
mpd.Depends = append(mpd.Depends,
|
mpd.Depends = append(mpd.Depends,
|
||||||
hash.String())
|
hash.String())
|
||||||
|
|
|
@ -688,7 +688,7 @@ func (m *wsNotificationManager) notifyForTxIns(ops map[btcwire.OutPoint]map[chan
|
||||||
txHex := ""
|
txHex := ""
|
||||||
wscNotified := make(map[chan struct{}]struct{})
|
wscNotified := make(map[chan struct{}]struct{})
|
||||||
for _, txIn := range tx.MsgTx().TxIn {
|
for _, txIn := range tx.MsgTx().TxIn {
|
||||||
prevOut := &txIn.PreviousOutpoint
|
prevOut := &txIn.PreviousOutPoint
|
||||||
if cmap, ok := ops[*prevOut]; ok {
|
if cmap, ok := ops[*prevOut]; ok {
|
||||||
if txHex == "" {
|
if txHex == "" {
|
||||||
txHex = txHexString(tx)
|
txHex = txHexString(tx)
|
||||||
|
@ -1484,8 +1484,8 @@ func rescanBlock(wsc *wsClient, lookups *rescanKeys, blk *btcutil.Block) {
|
||||||
recvNotified := false
|
recvNotified := false
|
||||||
|
|
||||||
for _, txin := range tx.MsgTx().TxIn {
|
for _, txin := range tx.MsgTx().TxIn {
|
||||||
if _, ok := lookups.unspent[txin.PreviousOutpoint]; ok {
|
if _, ok := lookups.unspent[txin.PreviousOutPoint]; ok {
|
||||||
delete(lookups.unspent, txin.PreviousOutpoint)
|
delete(lookups.unspent, txin.PreviousOutPoint)
|
||||||
|
|
||||||
if spentNotified {
|
if spentNotified {
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Reference in a new issue