mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-04 08:50:20 +02:00
multi: new bitcoind rpcpolling backend for itests
This commit is contained in:
parent
7509af1a70
commit
e789107e1f
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -259,6 +259,8 @@ jobs:
|
|||||||
args: backend=bitcoind
|
args: backend=bitcoind
|
||||||
- name: bitcoind-notxindex
|
- name: bitcoind-notxindex
|
||||||
args: backend="bitcoind notxindex"
|
args: backend="bitcoind notxindex"
|
||||||
|
- name: bitcoind-rpcpolling
|
||||||
|
args: backend="bitcoind rpcpolling"
|
||||||
- name: bitcoind-etcd
|
- name: bitcoind-etcd
|
||||||
args: backend=bitcoind dbbackend=etcd
|
args: backend=bitcoind dbbackend=etcd
|
||||||
- name: bitcoind-postgres
|
- name: bitcoind-postgres
|
||||||
|
@ -507,7 +507,7 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
|
|||||||
// version 0.17.0) we make sure lnd subscribes to the correct
|
// version 0.17.0) we make sure lnd subscribes to the correct
|
||||||
// zmq events. We do this to avoid a situation in which we are
|
// zmq events. We do this to avoid a situation in which we are
|
||||||
// not notified of new transactions or blocks.
|
// not notified of new transactions or blocks.
|
||||||
if ver >= 170000 {
|
if ver >= 170000 && !bitcoindMode.RPCPolling {
|
||||||
zmqPubRawBlockURL, err := url.Parse(bitcoindMode.ZMQPubRawBlock)
|
zmqPubRawBlockURL, err := url.Parse(bitcoindMode.ZMQPubRawBlock)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
18
config.go
18
config.go
@ -1777,11 +1777,19 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If all of RPCUser, RPCPass, ZMQBlockHost, and ZMQTxHost are
|
if conf.RPCUser != "" && conf.RPCPass != "" {
|
||||||
// set, we assume those parameters are good to use.
|
// If all of RPCUser, RPCPass, ZMQBlockHost, and
|
||||||
if conf.RPCUser != "" && conf.RPCPass != "" &&
|
// ZMQTxHost are set, we assume those parameters are
|
||||||
conf.ZMQPubRawBlock != "" && conf.ZMQPubRawTx != "" {
|
// good to use.
|
||||||
return nil
|
if conf.ZMQPubRawBlock != "" && conf.ZMQPubRawTx != "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// If RPCUser and RPCPass are set and RPCPolling is
|
||||||
|
// enabled, we assume the parameters are good to use.
|
||||||
|
if conf.RPCPolling {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the daemon name for displaying proper errors.
|
// Get the daemon name for displaying proper errors.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//go:build bitcoind && !notxindex
|
//go:build bitcoind && !notxindex && !rpcpolling
|
||||||
// +build bitcoind,!notxindex
|
// +build bitcoind,!notxindex,!rpcpolling
|
||||||
|
|
||||||
package lntest
|
package lntest
|
||||||
|
|
||||||
@ -19,5 +19,5 @@ func NewBackend(miner string, netParams *chaincfg.Params) (
|
|||||||
"-disablewallet",
|
"-disablewallet",
|
||||||
}
|
}
|
||||||
|
|
||||||
return newBackend(miner, netParams, extraArgs)
|
return newBackend(miner, netParams, extraArgs, false)
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ type BitcoindBackendConfig struct {
|
|||||||
zmqTxPath string
|
zmqTxPath string
|
||||||
p2pPort int
|
p2pPort int
|
||||||
rpcClient *rpcclient.Client
|
rpcClient *rpcclient.Client
|
||||||
|
rpcPolling bool
|
||||||
|
|
||||||
// minerAddr is the p2p address of the miner to connect to.
|
// minerAddr is the p2p address of the miner to connect to.
|
||||||
minerAddr string
|
minerAddr string
|
||||||
@ -46,10 +47,19 @@ func (b BitcoindBackendConfig) GenArgs() []string {
|
|||||||
args = append(args, fmt.Sprintf("--bitcoind.rpchost=%v", b.rpcHost))
|
args = append(args, fmt.Sprintf("--bitcoind.rpchost=%v", b.rpcHost))
|
||||||
args = append(args, fmt.Sprintf("--bitcoind.rpcuser=%v", b.rpcUser))
|
args = append(args, fmt.Sprintf("--bitcoind.rpcuser=%v", b.rpcUser))
|
||||||
args = append(args, fmt.Sprintf("--bitcoind.rpcpass=%v", b.rpcPass))
|
args = append(args, fmt.Sprintf("--bitcoind.rpcpass=%v", b.rpcPass))
|
||||||
args = append(args, fmt.Sprintf("--bitcoind.zmqpubrawblock=%v",
|
|
||||||
b.zmqBlockPath))
|
if b.rpcPolling {
|
||||||
args = append(args, fmt.Sprintf("--bitcoind.zmqpubrawtx=%v",
|
args = append(args, fmt.Sprintf("--bitcoind.rpcpolling"))
|
||||||
b.zmqTxPath))
|
args = append(args,
|
||||||
|
fmt.Sprintf("--bitcoind.blockpollinginterval=10ms"))
|
||||||
|
args = append(args,
|
||||||
|
fmt.Sprintf("--bitcoind.txpollinginterval=10ms"))
|
||||||
|
} else {
|
||||||
|
args = append(args, fmt.Sprintf("--bitcoind.zmqpubrawblock=%v",
|
||||||
|
b.zmqBlockPath))
|
||||||
|
args = append(args, fmt.Sprintf("--bitcoind.zmqpubrawtx=%v",
|
||||||
|
b.zmqTxPath))
|
||||||
|
}
|
||||||
|
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
@ -76,8 +86,8 @@ func (b BitcoindBackendConfig) Name() string {
|
|||||||
|
|
||||||
// newBackend starts a bitcoind node with the given extra parameters and returns
|
// newBackend starts a bitcoind node with the given extra parameters and returns
|
||||||
// a BitcoindBackendConfig for that node.
|
// a BitcoindBackendConfig for that node.
|
||||||
func newBackend(miner string, netParams *chaincfg.Params, extraArgs []string) (
|
func newBackend(miner string, netParams *chaincfg.Params, extraArgs []string,
|
||||||
*BitcoindBackendConfig, func() error, error) {
|
rpcPolling bool) (*BitcoindBackendConfig, func() error, error) {
|
||||||
|
|
||||||
baseLogDir := fmt.Sprintf(logDirPattern, GetLogDir())
|
baseLogDir := fmt.Sprintf(logDirPattern, GetLogDir())
|
||||||
if netParams != &chaincfg.RegressionNetParams {
|
if netParams != &chaincfg.RegressionNetParams {
|
||||||
@ -192,6 +202,7 @@ func newBackend(miner string, netParams *chaincfg.Params, extraArgs []string) (
|
|||||||
p2pPort: p2pPort,
|
p2pPort: p2pPort,
|
||||||
rpcClient: client,
|
rpcClient: client,
|
||||||
minerAddr: miner,
|
minerAddr: miner,
|
||||||
|
rpcPolling: rpcPolling,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &bd, cleanUp, nil
|
return &bd, cleanUp, nil
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//go:build bitcoind && notxindex
|
//go:build bitcoind && notxindex && !rpcpolling
|
||||||
// +build bitcoind,notxindex
|
// +build bitcoind,notxindex,!rpcpolling
|
||||||
|
|
||||||
package lntest
|
package lntest
|
||||||
|
|
||||||
@ -18,5 +18,5 @@ func NewBackend(miner string, netParams *chaincfg.Params) (
|
|||||||
"-disablewallet",
|
"-disablewallet",
|
||||||
}
|
}
|
||||||
|
|
||||||
return newBackend(miner, netParams, extraArgs)
|
return newBackend(miner, netParams, extraArgs, false)
|
||||||
}
|
}
|
||||||
|
23
lntest/bitcoind_rpcpolling.go
Normal file
23
lntest/bitcoind_rpcpolling.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
//go:build bitcoind && rpcpolling
|
||||||
|
// +build bitcoind,rpcpolling
|
||||||
|
|
||||||
|
package lntest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewBackend starts a bitcoind node without the txindex enabled and returns a
|
||||||
|
// BitoindBackendConfig for that node.
|
||||||
|
func NewBackend(miner string, netParams *chaincfg.Params) (
|
||||||
|
*BitcoindBackendConfig, func() error, error) {
|
||||||
|
|
||||||
|
extraArgs := []string{
|
||||||
|
"-debug",
|
||||||
|
"-regtest",
|
||||||
|
"-txindex",
|
||||||
|
"-disablewallet",
|
||||||
|
}
|
||||||
|
|
||||||
|
return newBackend(miner, netParams, extraArgs, true)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user