mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 18:10:34 +01:00
567fa9ed10
Previously the chainbackend connected to the miner using a permanent connection, which would retry the connection when it’s disconnected. It would leave multiple connections between the chainbackend and the miner, causing difficulties in debugging. Currently, there are two occasions when disconnection happens. One happens when running the open channel reorg test, the miner is connected/disconnected multiple times on purpose. The other happens when the chainbackend receives a MSG_WITNESS_TX type from the miner, which would be considered as an invalid type and disconnects the miner. With the latter one being fixed in btcd, the chainbackend will still be disconnected from the miner if it reaches the ban score by requesting too many notfound messages in a short time which is why the `--nobanning` flag is added.
56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
// +build neutrino
|
|
|
|
package lntest
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/btcsuite/btcd/chaincfg"
|
|
)
|
|
|
|
// NeutrinoBackendConfig is an implementation of the BackendConfig interface
|
|
// backed by a neutrino node.
|
|
type NeutrinoBackendConfig struct {
|
|
minerAddr string
|
|
}
|
|
|
|
// A compile time assertion to ensure NeutrinoBackendConfig meets the
|
|
// BackendConfig interface.
|
|
var _ BackendConfig = (*NeutrinoBackendConfig)(nil)
|
|
|
|
// GenArgs returns the arguments needed to be passed to LND at startup for
|
|
// using this node as a chain backend.
|
|
func (b NeutrinoBackendConfig) GenArgs() []string {
|
|
var args []string
|
|
args = append(args, "--bitcoin.node=neutrino")
|
|
args = append(args, "--neutrino.connect="+b.minerAddr)
|
|
return args
|
|
}
|
|
|
|
// ConnectMiner is called to establish a connection to the test miner.
|
|
func (b NeutrinoBackendConfig) ConnectMiner() error {
|
|
return nil
|
|
}
|
|
|
|
// DisconnectMiner is called to disconnect the miner.
|
|
func (b NeutrinoBackendConfig) DisconnectMiner() error {
|
|
return fmt.Errorf("unimplemented")
|
|
}
|
|
|
|
// Name returns the name of the backend type.
|
|
func (b NeutrinoBackendConfig) Name() string {
|
|
return "neutrino"
|
|
}
|
|
|
|
// NewBackend starts and returns a NeutrinoBackendConfig for the node.
|
|
func NewBackend(miner string, _ *chaincfg.Params) (
|
|
*NeutrinoBackendConfig, func() error, error) {
|
|
|
|
bd := &NeutrinoBackendConfig{
|
|
minerAddr: miner,
|
|
}
|
|
|
|
cleanUp := func() error { return nil }
|
|
return bd, cleanUp, nil
|
|
}
|