Skip to content

Commit

Permalink
Merge pull request #218 from kcalvinalvin/2024-11-13-remove-udata-fro…
Browse files Browse the repository at this point in the history
…m-msgtx

wire, electrum, netsync, wallet, main: remove udata from MsgTx
  • Loading branch information
kcalvinalvin authored Nov 14, 2024
2 parents 353f565 + ee4f523 commit de02a71
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 18 deletions.
1 change: 0 additions & 1 deletion electrum/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ func handleTransactionBroadcast(s *ElectrumServer, cmd *btcjson.Request, conn ne
Message: "Failed to prove the tx in the utreexo accumulator: " + err.Error(),
}
}
tx.MsgTx().UData = udata

acceptedTxs, err := s.cfg.Mempool.ProcessTransaction(tx, udata, false, false, 0)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion netsync/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,11 @@ out:
msg.reply <- struct{}{}

case *utreexoTxMsg:
sm.handleTxMsg(&msg.utreexoTx.Tx, msg.peer, msg.utreexoTx.MsgUtreexoTx().UData)
sm.handleTxMsg(&msg.utreexoTx.Tx, msg.peer,
&wire.UData{
AccProof: msg.utreexoTx.MsgUtreexoTx().AccProof,
LeafDatas: msg.utreexoTx.MsgUtreexoTx().LeafDatas,
})
msg.reply <- struct{}{}

case *blockMsg:
Expand Down
11 changes: 0 additions & 11 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2786,11 +2786,6 @@ func (s *server) UpdateProofBytesRead(msgTx *wire.MsgTx) error {
s.addProofBytesReceived(uint64(utxoDataSize))
s.addAccBytesReceived(uint64(accSize))

} else if s.chain.IsUtreexoViewActive() {
if msgTx.UData != nil {
s.addProofBytesReceived(uint64(msgTx.UData.SerializeSize()))
s.addAccBytesReceived(uint64(msgTx.UData.SerializeAccSize()))
}
}

return nil
Expand All @@ -2807,12 +2802,6 @@ func (s *server) UpdateProofBytesWritten(msgTx *wire.MsgTx) error {
}
s.addProofBytesSent(uint64(utxoDataSize))
s.addAccBytesSent(uint64(accSize))

} else if s.chain.IsUtreexoViewActive() {
if msgTx.UData != nil {
s.addProofBytesSent(uint64(msgTx.UData.SerializeSize()))
s.addAccBytesSent(uint64(msgTx.UData.SerializeAccSize()))
}
}

return nil
Expand Down
3 changes: 0 additions & 3 deletions wallet/watchonly.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ func (tx RelevantTxData) MarshalJSON() ([]byte, error) {
}

txBuf := bytes.NewBuffer(make([]byte, 0, tx.Tx.SerializeSize()))
tx.Tx.UData = nil
err := tx.Tx.Serialize(txBuf)
if err != nil {
return nil, fmt.Errorf("failed to serialize tx %s. Error %v",
Expand Down Expand Up @@ -963,8 +962,6 @@ func (wm *WatchOnlyWalletManager) filterBlock(block *btcutil.Block) ([]uint32, [
Tx: tx.MsgTx(),
}

// Explicitly set to nil as we won't be fetching the udata from here.
relevantTx.Tx.UData = nil
wm.wallet.RelevantTxs[*tx.Hash()] = relevantTx

inIdx++
Expand Down
1 change: 0 additions & 1 deletion wire/msgtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ type MsgTx struct {
Version int32
TxIn []*TxIn
TxOut []*TxOut
UData *UData
LockTime uint32
}

Expand Down
2 changes: 1 addition & 1 deletion wire/msgutreexotx.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (msg *MsgUtreexoTx) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding
// Go through the TxIns and mark the ones that are not confirmed with a 1 in the LSB.
for i := range msg.TxIn {
msg.TxIn[i].PreviousOutPoint.Index <<= 1
if msg.UData.LeafDatas[i].Equal(emptyLd) {
if msg.LeafDatas[i].Equal(emptyLd) {
msg.TxIn[i].PreviousOutPoint.Index |= 1
}
}
Expand Down

0 comments on commit de02a71

Please sign in to comment.