mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-13 11:09:23 +01:00
server+lntest: extract ErrServerNotActive error
This commit is contained in:
parent
fd906475dd
commit
955d143c1b
3 changed files with 14 additions and 15 deletions
|
@ -13,17 +13,17 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc/grpclog"
|
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/integration/rpctest"
|
"github.com/btcsuite/btcd/integration/rpctest"
|
||||||
"github.com/btcsuite/btcd/txscript"
|
"github.com/btcsuite/btcd/txscript"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
|
"github.com/lightningnetwork/lnd"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
|
"google.golang.org/grpc/grpclog"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultCSV is the CSV delay (remotedelay) we will start our test nodes with.
|
// DefaultCSV is the CSV delay (remotedelay) we will start our test nodes with.
|
||||||
|
@ -395,7 +395,7 @@ func (n *NetworkHarness) connect(ctx context.Context,
|
||||||
tryconnect:
|
tryconnect:
|
||||||
if _, err := a.ConnectPeer(ctx, req); err != nil {
|
if _, err := a.ConnectPeer(ctx, req); err != nil {
|
||||||
// If the chain backend is still syncing, retry.
|
// If the chain backend is still syncing, retry.
|
||||||
if strings.Contains(err.Error(), "still syncing") {
|
if err == lnd.ErrServerNotActive {
|
||||||
select {
|
select {
|
||||||
case <-time.After(100 * time.Millisecond):
|
case <-time.After(100 * time.Millisecond):
|
||||||
goto tryconnect
|
goto tryconnect
|
||||||
|
|
18
rpcserver.go
18
rpcserver.go
|
@ -1257,8 +1257,7 @@ func (r *rpcServer) ConnectPeer(ctx context.Context,
|
||||||
// The server hasn't yet started, so it won't be able to service any of
|
// The server hasn't yet started, so it won't be able to service any of
|
||||||
// our requests, so we'll bail early here.
|
// our requests, so we'll bail early here.
|
||||||
if !r.server.Started() {
|
if !r.server.Started() {
|
||||||
return nil, fmt.Errorf("chain backend is still syncing, server " +
|
return nil, ErrServerNotActive
|
||||||
"not active yet")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if in.Addr == nil {
|
if in.Addr == nil {
|
||||||
|
@ -1311,8 +1310,7 @@ func (r *rpcServer) DisconnectPeer(ctx context.Context,
|
||||||
rpcsLog.Debugf("[disconnectpeer] from peer(%s)", in.PubKey)
|
rpcsLog.Debugf("[disconnectpeer] from peer(%s)", in.PubKey)
|
||||||
|
|
||||||
if !r.server.Started() {
|
if !r.server.Started() {
|
||||||
return nil, fmt.Errorf("chain backend is still syncing, server " +
|
return nil, ErrServerNotActive
|
||||||
"not active yet")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// First we'll validate the string passed in within the request to
|
// First we'll validate the string passed in within the request to
|
||||||
|
@ -1398,8 +1396,7 @@ func (r *rpcServer) OpenChannel(in *lnrpc.OpenChannelRequest,
|
||||||
in.LocalFundingAmount, in.PushSat)
|
in.LocalFundingAmount, in.PushSat)
|
||||||
|
|
||||||
if !r.server.Started() {
|
if !r.server.Started() {
|
||||||
return fmt.Errorf("chain backend is still syncing, server " +
|
return ErrServerNotActive
|
||||||
"not active yet")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
localFundingAmt := btcutil.Amount(in.LocalFundingAmount)
|
localFundingAmt := btcutil.Amount(in.LocalFundingAmount)
|
||||||
|
@ -1558,8 +1555,7 @@ func (r *rpcServer) OpenChannelSync(ctx context.Context,
|
||||||
// syncing, as otherwise we may not be able to obtain the relevant
|
// syncing, as otherwise we may not be able to obtain the relevant
|
||||||
// notifications.
|
// notifications.
|
||||||
if !r.server.Started() {
|
if !r.server.Started() {
|
||||||
return nil, fmt.Errorf("chain backend is still syncing, server " +
|
return nil, ErrServerNotActive
|
||||||
"not active yet")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creation of channels before the wallet syncs up is currently
|
// Creation of channels before the wallet syncs up is currently
|
||||||
|
@ -3205,8 +3201,7 @@ func (r *rpcServer) sendPayment(stream *paymentStream) error {
|
||||||
// syncing as we may be trying to sent a payment over a "stale"
|
// syncing as we may be trying to sent a payment over a "stale"
|
||||||
// channel.
|
// channel.
|
||||||
if !r.server.Started() {
|
if !r.server.Started() {
|
||||||
return fmt.Errorf("chain backend is still syncing, server " +
|
return ErrServerNotActive
|
||||||
"not active yet")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(roasbeef): check payment filter to see if already used?
|
// TODO(roasbeef): check payment filter to see if already used?
|
||||||
|
@ -3396,8 +3391,7 @@ func (r *rpcServer) sendPaymentSync(ctx context.Context,
|
||||||
// syncing as we may be trying to sent a payment over a "stale"
|
// syncing as we may be trying to sent a payment over a "stale"
|
||||||
// channel.
|
// channel.
|
||||||
if !r.server.Started() {
|
if !r.server.Started() {
|
||||||
return nil, fmt.Errorf("chain backend is still syncing, server " +
|
return nil, ErrServerNotActive
|
||||||
"not active yet")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// First we'll attempt to map the proto describing the next payment to
|
// First we'll attempt to map the proto describing the next payment to
|
||||||
|
|
|
@ -89,6 +89,11 @@ var (
|
||||||
// given peer.
|
// given peer.
|
||||||
ErrPeerNotConnected = errors.New("peer is not connected")
|
ErrPeerNotConnected = errors.New("peer is not connected")
|
||||||
|
|
||||||
|
// ErrServerNotActive indicates that the server has started but hasn't
|
||||||
|
// fully finished the startup process.
|
||||||
|
ErrServerNotActive = errors.New("server is still in the process of " +
|
||||||
|
"starting")
|
||||||
|
|
||||||
// ErrServerShuttingDown indicates that the server is in the process of
|
// ErrServerShuttingDown indicates that the server is in the process of
|
||||||
// gracefully exiting.
|
// gracefully exiting.
|
||||||
ErrServerShuttingDown = errors.New("server is shutting down")
|
ErrServerShuttingDown = errors.New("server is shutting down")
|
||||||
|
|
Loading…
Add table
Reference in a new issue