lnwallet: make BlockChainIO.GetUTXO take cancel chan
Use quit channels as cancel chan for call to GetUTXO.
This commit is contained in:
parent
beb5d14ed9
commit
10070ecab7
@ -131,7 +131,7 @@ func (*mockChainIO) GetBestBlock() (*chainhash.Hash, int32, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (*mockChainIO) GetUtxo(op *wire.OutPoint, _ []byte,
|
func (*mockChainIO) GetUtxo(op *wire.OutPoint, _ []byte,
|
||||||
heightHint uint32) (*wire.TxOut, error) {
|
heightHint uint32, _ <-chan struct{}) (*wire.TxOut, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ func (b *BtcWallet) GetBestBlock() (*chainhash.Hash, int32, error) {
|
|||||||
//
|
//
|
||||||
// This method is a part of the lnwallet.BlockChainIO interface.
|
// This method is a part of the lnwallet.BlockChainIO interface.
|
||||||
func (b *BtcWallet) GetUtxo(op *wire.OutPoint, pkScript []byte,
|
func (b *BtcWallet) GetUtxo(op *wire.OutPoint, pkScript []byte,
|
||||||
heightHint uint32) (*wire.TxOut, error) {
|
heightHint uint32, cancel <-chan struct{}) (*wire.TxOut, error) {
|
||||||
|
|
||||||
switch backend := b.chain.(type) {
|
switch backend := b.chain.(type) {
|
||||||
|
|
||||||
|
@ -268,8 +268,10 @@ type BlockChainIO interface {
|
|||||||
// script that the outpoint creates. In the case that the output is in
|
// script that the outpoint creates. In the case that the output is in
|
||||||
// the UTXO set, then the output corresponding to that output is
|
// the UTXO set, then the output corresponding to that output is
|
||||||
// returned. Otherwise, a non-nil error will be returned.
|
// returned. Otherwise, a non-nil error will be returned.
|
||||||
GetUtxo(op *wire.OutPoint, pkScript []byte,
|
// As for some backends this call can initiate a rescan, the passed
|
||||||
heightHint uint32) (*wire.TxOut, error)
|
// cancel channel can be closed to abort the call.
|
||||||
|
GetUtxo(op *wire.OutPoint, pkScript []byte, heightHint uint32,
|
||||||
|
cancel <-chan struct{}) (*wire.TxOut, error)
|
||||||
|
|
||||||
// GetBlockHash returns the hash of the block in the best blockchain
|
// GetBlockHash returns the hash of the block in the best blockchain
|
||||||
// at the given height.
|
// at the given height.
|
||||||
|
@ -974,7 +974,7 @@ func (l *LightningWallet) handleFundingCounterPartySigs(msg *addCounterPartySigs
|
|||||||
}
|
}
|
||||||
output, err := l.Cfg.ChainIO.GetUtxo(
|
output, err := l.Cfg.ChainIO.GetUtxo(
|
||||||
&txin.PreviousOutPoint,
|
&txin.PreviousOutPoint,
|
||||||
pkScript, 0,
|
pkScript, 0, l.quit,
|
||||||
)
|
)
|
||||||
if output == nil {
|
if output == nil {
|
||||||
msg.err <- fmt.Errorf("input to funding tx "+
|
msg.err <- fmt.Errorf("input to funding tx "+
|
||||||
|
2
mock.go
2
mock.go
@ -212,7 +212,7 @@ func (m *mockChainIO) GetBestBlock() (*chainhash.Hash, int32, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (*mockChainIO) GetUtxo(op *wire.OutPoint, _ []byte,
|
func (*mockChainIO) GetUtxo(op *wire.OutPoint, _ []byte,
|
||||||
heightHint uint32) (*wire.TxOut, error) {
|
heightHint uint32, _ <-chan struct{}) (*wire.TxOut, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,8 @@ func (m *mockChain) addUtxo(op wire.OutPoint, out *wire.TxOut) {
|
|||||||
m.utxos[op] = *out
|
m.utxos[op] = *out
|
||||||
m.Unlock()
|
m.Unlock()
|
||||||
}
|
}
|
||||||
func (m *mockChain) GetUtxo(op *wire.OutPoint, _ []byte, _ uint32) (*wire.TxOut, error) {
|
func (m *mockChain) GetUtxo(op *wire.OutPoint, _ []byte, _ uint32,
|
||||||
|
_ <-chan struct{}) (*wire.TxOut, error) {
|
||||||
m.RLock()
|
m.RLock()
|
||||||
defer m.RUnlock()
|
defer m.RUnlock()
|
||||||
|
|
||||||
|
@ -1113,6 +1113,7 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
|
|||||||
// been closed so we'll ignore it.
|
// been closed so we'll ignore it.
|
||||||
chanUtxo, err := r.cfg.Chain.GetUtxo(
|
chanUtxo, err := r.cfg.Chain.GetUtxo(
|
||||||
fundingPoint, fundingPkScript, channelID.BlockHeight,
|
fundingPoint, fundingPkScript, channelID.BlockHeight,
|
||||||
|
r.quit,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.rejectMtx.Lock()
|
r.rejectMtx.Lock()
|
||||||
|
@ -245,7 +245,7 @@ func (m *mockChainIO) GetBestBlock() (*chainhash.Hash, int32, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockChainIO) GetUtxo(op *wire.OutPoint, pkScript []byte,
|
func (m *mockChainIO) GetUtxo(op *wire.OutPoint, pkScript []byte,
|
||||||
heightHint uint32) (*wire.TxOut, error) {
|
heightHint uint32, _ <-chan struct{}) (*wire.TxOut, error) {
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user