Skip to content

Commit 3730196

Browse files
committed
main: fix csn serve tx bug
Fixes a bug where a csn would crash upon serving a tx to a peer.
1 parent 786b620 commit 3730196

File tree

1 file changed

+34
-23
lines changed

1 file changed

+34
-23
lines changed

server.go

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,35 +1529,46 @@ func (s *server) pushTxMsg(sp *serverPeer, hash *chainhash.Hash, doneChan chan<-
15291529
return err
15301530
}
15311531

1532-
leafDatas, err := blockchain.TxToDelLeaves(tx, s.chain)
1533-
if err != nil {
1534-
chanLog.Errorf(err.Error())
1535-
if doneChan != nil {
1536-
doneChan <- struct{}{}
1537-
}
1538-
return err
1539-
}
1540-
1541-
var ud *wire.UData
1542-
15431532
// We already checked that at least one is active. Pick one and
15441533
// generate the UData.
15451534
if s.utreexoProofIndex != nil {
1546-
ud, err = s.utreexoProofIndex.GenerateUData(leafDatas)
1535+
leafDatas, err := blockchain.TxToDelLeaves(tx, s.chain)
1536+
if err != nil {
1537+
chanLog.Errorf(err.Error())
1538+
if doneChan != nil {
1539+
doneChan <- struct{}{}
1540+
}
1541+
return err
1542+
}
1543+
ud, err := s.utreexoProofIndex.GenerateUData(leafDatas)
1544+
if err != nil {
1545+
chanLog.Errorf(err.Error())
1546+
if doneChan != nil {
1547+
doneChan <- struct{}{}
1548+
}
1549+
return err
1550+
}
1551+
tx.MsgTx().UData = ud
1552+
15471553
} else if s.flatUtreexoProofIndex != nil {
1548-
ud, err = s.flatUtreexoProofIndex.GenerateUData(leafDatas)
1549-
} else {
1550-
ud, err = s.chain.GenerateUData(leafDatas)
1551-
}
1552-
if err != nil {
1553-
chanLog.Errorf(err.Error())
1554-
if doneChan != nil {
1555-
doneChan <- struct{}{}
1554+
leafDatas, err := blockchain.TxToDelLeaves(tx, s.chain)
1555+
if err != nil {
1556+
chanLog.Errorf(err.Error())
1557+
if doneChan != nil {
1558+
doneChan <- struct{}{}
1559+
}
1560+
return err
15561561
}
1557-
return err
1562+
ud, err := s.flatUtreexoProofIndex.GenerateUData(leafDatas)
1563+
if err != nil {
1564+
chanLog.Errorf(err.Error())
1565+
if doneChan != nil {
1566+
doneChan <- struct{}{}
1567+
}
1568+
return err
1569+
}
1570+
tx.MsgTx().UData = ud
15581571
}
1559-
1560-
tx.MsgTx().UData = ud
15611572
}
15621573

15631574
// Once we have fetched data wait for any previous operation to finish.

0 commit comments

Comments
 (0)