lnwallet/reservation: s/Unlock/RUnlock, fix panic caused by double unlock

This commit is contained in:
Olaoluwa Osuntokun 2015-11-28 18:20:57 -06:00
parent b36de8768d
commit 42ba1a5394

View File

@ -16,7 +16,7 @@ type ChannelReservation struct {
ReserveAmount btcutil.Amount
MinFeePerKb btcutil.Amount
sync.RWMutex // All fields below owned by the wallet.
sync.RWMutex // All fields below owned by the lnwallet.
theirInputs []*wire.TxIn
ourInputs []*wire.TxIn
@ -59,7 +59,7 @@ func newChannelReservation(t FundingType, fundingAmt btcutil.Amount,
// OurFunds...
func (r *ChannelReservation) OurFunds() ([]*wire.TxIn, []*wire.TxOut, *btcec.PublicKey) {
r.RLock()
defer r.Unlock()
defer r.RUnlock()
return r.ourInputs, r.ourChange, r.ourKey.PubKey()
}
@ -80,14 +80,15 @@ func (r *ChannelReservation) AddFunds(theirInputs []*wire.TxIn, theirChangeOutpu
// OurSigs...
func (r *ChannelReservation) OurSigs() [][]byte {
r.RLock()
defer r.Unlock()
defer r.RUnlock()
return r.ourSigs
}
// TheirFunds...
// TODO(roasbeef): return error if accessors not yet populated?
func (r *ChannelReservation) TheirFunds() ([]*wire.TxIn, []*wire.TxOut, *btcec.PublicKey) {
r.RLock()
defer r.Unlock()
defer r.RUnlock()
return r.theirInputs, r.theirChange, r.theirKey
}
@ -107,7 +108,7 @@ func (r *ChannelReservation) CompleteReservation(theirSigs [][]byte) error {
// FinalFundingTransaction...
func (r *ChannelReservation) FinalFundingTx() *btcutil.Tx {
r.RLock()
defer r.Unlock()
defer r.RUnlock()
return r.completedFundingTx
}