routing+discovery: uniform error codes in routing
This commit is contained in:
5 files changed
+45
-32
No files matched your search
+17
-13
@@ -1113,8 +1113,11 @@ func (d *AuthenticatedGossiper) networkHandler() {
|
|||||||
announcement.msg,
|
announcement.msg,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != routing.ErrVBarrierShuttingDown &&
|
if !routing.IsError(
|
||||||
err != routing.ErrParentValidationFailed {
|
err,
|
||||||
|
routing.ErrVBarrierShuttingDown,
|
||||||
|
routing.ErrParentValidationFailed,
|
||||||
|
) {
|
||||||
log.Warnf("unexpected error "+
|
log.Warnf("unexpected error "+
|
||||||
"during validation "+
|
"during validation "+
|
||||||
"barrier shutdown: %v",
|
"barrier shutdown: %v",
|
||||||
@@ -1658,15 +1661,13 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
|||||||
log.Debugf("Adding node: %x got error: %v",
|
log.Debugf("Adding node: %x got error: %v",
|
||||||
msg.NodeID, err)
|
msg.NodeID, err)
|
||||||
|
|
||||||
switch {
|
if !routing.IsError(
|
||||||
case routing.IsError(err, routing.ErrOutdated,
|
err,
|
||||||
routing.ErrIgnored):
|
routing.ErrOutdated,
|
||||||
|
routing.ErrIgnored,
|
||||||
case err == routing.ErrVBarrierShuttingDown:
|
routing.ErrVBarrierShuttingDown,
|
||||||
|
) {
|
||||||
default:
|
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nMsg.err <- err
|
nMsg.err <- err
|
||||||
@@ -2188,11 +2189,14 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := d.cfg.Router.UpdateEdge(update, schedulerOp...); err != nil {
|
if err := d.cfg.Router.UpdateEdge(update, schedulerOp...); err != nil {
|
||||||
if routing.IsError(err, routing.ErrOutdated,
|
if routing.IsError(
|
||||||
routing.ErrIgnored) {
|
err, routing.ErrOutdated,
|
||||||
|
routing.ErrIgnored,
|
||||||
|
routing.ErrVBarrierShuttingDown,
|
||||||
|
) {
|
||||||
log.Debug(err)
|
log.Debug(err)
|
||||||
} else if err != routing.ErrVBarrierShuttingDown {
|
|
||||||
|
|
||||||
|
} else {
|
||||||
key := newRejectCacheKey(
|
key := newRejectCacheKey(
|
||||||
msg.ShortChannelID.ToUint64(),
|
msg.ShortChannelID.ToUint64(),
|
||||||
nMsg.peer.PubKey(),
|
nMsg.peer.PubKey(),
|
||||||
|
|||||||
@@ -28,6 +28,15 @@ const (
|
|||||||
// ErrInvalidFundingOutput is returned if the channle funding output
|
// ErrInvalidFundingOutput is returned if the channle funding output
|
||||||
// fails validation.
|
// fails validation.
|
||||||
ErrInvalidFundingOutput
|
ErrInvalidFundingOutput
|
||||||
|
|
||||||
|
// ErrVBarrierShuttingDown signals that the barrier has been requested
|
||||||
|
// to shutdown, and that the caller should not treat the wait condition
|
||||||
|
// as fulfilled.
|
||||||
|
ErrVBarrierShuttingDown
|
||||||
|
|
||||||
|
// ErrParentValidationFailed signals that the validation of a
|
||||||
|
// dependent's parent failed, so the dependent must not be processed.
|
||||||
|
ErrParentValidationFailed
|
||||||
)
|
)
|
||||||
|
|
||||||
// routerError is a structure that represent the error inside the routing package,
|
// routerError is a structure that represent the error inside the routing package,
|
||||||
|
|||||||
+9
-3
@@ -1062,13 +1062,19 @@ func (r *ChannelRouter) networkHandler() {
|
|||||||
update.msg,
|
update.msg,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch err {
|
switch {
|
||||||
case ErrVBarrierShuttingDown:
|
case IsError(
|
||||||
|
err, ErrVBarrierShuttingDown,
|
||||||
|
):
|
||||||
update.err <- err
|
update.err <- err
|
||||||
case ErrParentValidationFailed:
|
|
||||||
|
case IsError(
|
||||||
|
err, ErrParentValidationFailed,
|
||||||
|
):
|
||||||
update.err <- newErrf(
|
update.err <- newErrf(
|
||||||
ErrIgnored, err.Error(),
|
ErrIgnored, err.Error(),
|
||||||
)
|
)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log.Warnf("unexpected error "+
|
log.Warnf("unexpected error "+
|
||||||
"during validation "+
|
"during validation "+
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package routing
|
package routing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
@@ -9,17 +8,6 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/routing/route"
|
"github.com/lightningnetwork/lnd/routing/route"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// ErrVBarrierShuttingDown signals that the barrier has been requested
|
|
||||||
// to shutdown, and that the caller should not treat the wait condition
|
|
||||||
// as fulfilled.
|
|
||||||
ErrVBarrierShuttingDown = errors.New("validation barrier shutting down")
|
|
||||||
|
|
||||||
// ErrParentValidationFailed signals that the validation of a
|
|
||||||
// dependent's parent failed, so the dependent must not be processed.
|
|
||||||
ErrParentValidationFailed = errors.New("parent validation failed")
|
|
||||||
)
|
|
||||||
|
|
||||||
// validationSignals contains two signals which allows the ValidationBarrier to
|
// validationSignals contains two signals which allows the ValidationBarrier to
|
||||||
// communicate back to the caller whether a dependent should be processed or not
|
// communicate back to the caller whether a dependent should be processed or not
|
||||||
// based on whether its parent was successfully validated. Only one of these
|
// based on whether its parent was successfully validated. Only one of these
|
||||||
@@ -228,9 +216,11 @@ func (v *ValidationBarrier) WaitForDependants(job interface{}) error {
|
|||||||
if ok {
|
if ok {
|
||||||
select {
|
select {
|
||||||
case <-v.quit:
|
case <-v.quit:
|
||||||
return ErrVBarrierShuttingDown
|
return newErrf(ErrVBarrierShuttingDown,
|
||||||
|
"validation barrier shutting down")
|
||||||
case <-signals.deny:
|
case <-signals.deny:
|
||||||
return ErrParentValidationFailed
|
return newErrf(ErrParentValidationFailed,
|
||||||
|
"parent validation failed")
|
||||||
case <-signals.allow:
|
case <-signals.allow:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,14 +141,18 @@ func TestValidationBarrierQuit(t *testing.T) {
|
|||||||
|
|
||||||
switch {
|
switch {
|
||||||
// First half should return without failure.
|
// First half should return without failure.
|
||||||
case i < numTasks/4 && err != routing.ErrParentValidationFailed:
|
case i < numTasks/4 && !routing.IsError(
|
||||||
|
err, routing.ErrParentValidationFailed,
|
||||||
|
):
|
||||||
t.Fatalf("unexpected failure while waiting: %v", err)
|
t.Fatalf("unexpected failure while waiting: %v", err)
|
||||||
|
|
||||||
case i >= numTasks/4 && i < numTasks/2 && err != nil:
|
case i >= numTasks/4 && i < numTasks/2 && err != nil:
|
||||||
t.Fatalf("unexpected failure while waiting: %v", err)
|
t.Fatalf("unexpected failure while waiting: %v", err)
|
||||||
|
|
||||||
// Last half should return the shutdown error.
|
// Last half should return the shutdown error.
|
||||||
case i >= numTasks/2 && err != routing.ErrVBarrierShuttingDown:
|
case i >= numTasks/2 && !routing.IsError(
|
||||||
|
err, routing.ErrVBarrierShuttingDown,
|
||||||
|
):
|
||||||
t.Fatalf("expected failure after quitting: want %v, "+
|
t.Fatalf("expected failure after quitting: want %v, "+
|
||||||
"got %v", routing.ErrVBarrierShuttingDown, err)
|
"got %v", routing.ErrVBarrierShuttingDown, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user