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

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