lnwire: rename ErrorCode -> FundingError
To make it clear that these errors are not part of the spec, rename them to FundingError.
This commit is contained in:
parent
33fe09482b
commit
e4301d3a8f
@ -857,7 +857,7 @@ func (f *fundingManager) failFundingFlow(peer lnpeer.Peer, tempChanID [32]byte,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We only send the exact error if it is part of out whitelisted set of
|
// We only send the exact error if it is part of out whitelisted set of
|
||||||
// errors (lnwire.ErrorCode or lnwallet.ReservationError).
|
// errors (lnwire.FundingError or lnwallet.ReservationError).
|
||||||
var msg lnwire.ErrorData
|
var msg lnwire.ErrorData
|
||||||
switch e := fundingErr.(type) {
|
switch e := fundingErr.(type) {
|
||||||
|
|
||||||
@ -865,7 +865,7 @@ func (f *fundingManager) failFundingFlow(peer lnpeer.Peer, tempChanID [32]byte,
|
|||||||
// whitelisted types.
|
// whitelisted types.
|
||||||
case lnwallet.ReservationError:
|
case lnwallet.ReservationError:
|
||||||
msg = lnwire.ErrorData(e.Error())
|
msg = lnwire.ErrorData(e.Error())
|
||||||
case lnwire.ErrorCode:
|
case lnwire.FundingError:
|
||||||
msg = lnwire.ErrorData(e.Error())
|
msg = lnwire.ErrorData(e.Error())
|
||||||
|
|
||||||
// For all other error types we just send a generic error.
|
// For all other error types we just send a generic error.
|
||||||
|
@ -3,40 +3,30 @@ package lnwire
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrorCode represents the short error code for each of the defined errors
|
// FundingError represents a set of errors that can be encountered and sent
|
||||||
// within the Lightning Network protocol spec.
|
// during the funding workflow.
|
||||||
type ErrorCode uint8
|
type FundingError uint8
|
||||||
|
|
||||||
// ToGrpcCode is used to generate gRPC specific code which will be propagated
|
|
||||||
// to the ln rpc client. This code is used to have more detailed view of what
|
|
||||||
// goes wrong and also in order to have the ability pragmatically determine the
|
|
||||||
// error and take specific actions on the client side.
|
|
||||||
func (e ErrorCode) ToGrpcCode() codes.Code {
|
|
||||||
return (codes.Code)(e) + 100
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// ErrMaxPendingChannels is returned by remote peer when the number of
|
// ErrMaxPendingChannels is returned by remote peer when the number of
|
||||||
// active pending channels exceeds their maximum policy limit.
|
// active pending channels exceeds their maximum policy limit.
|
||||||
ErrMaxPendingChannels ErrorCode = 1
|
ErrMaxPendingChannels FundingError = 1
|
||||||
|
|
||||||
// ErrSynchronizingChain is returned by a remote peer that receives a
|
// ErrSynchronizingChain is returned by a remote peer that receives a
|
||||||
// channel update or a funding request while their still syncing to the
|
// channel update or a funding request while their still syncing to the
|
||||||
// latest state of the blockchain.
|
// latest state of the blockchain.
|
||||||
ErrSynchronizingChain ErrorCode = 2
|
ErrSynchronizingChain FundingError = 2
|
||||||
|
|
||||||
// ErrChanTooLarge is returned by a remote peer that receives a
|
// ErrChanTooLarge is returned by a remote peer that receives a
|
||||||
// FundingOpen request for a channel that is above their current
|
// FundingOpen request for a channel that is above their current
|
||||||
// soft-limit.
|
// soft-limit.
|
||||||
ErrChanTooLarge ErrorCode = 3
|
ErrChanTooLarge FundingError = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
// String returns a human readable version of the target ErrorCode.
|
// String returns a human readable version of the target FundingError.
|
||||||
func (e ErrorCode) String() string {
|
func (e FundingError) String() string {
|
||||||
switch e {
|
switch e {
|
||||||
case ErrMaxPendingChannels:
|
case ErrMaxPendingChannels:
|
||||||
return "Number of pending channels exceed maximum"
|
return "Number of pending channels exceed maximum"
|
||||||
@ -49,10 +39,10 @@ func (e ErrorCode) String() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error returns the human redable version of the target ErrorCode.
|
// Error returns the human redable version of the target FundingError.
|
||||||
//
|
//
|
||||||
// Satisfies the Error interface.
|
// NOTE: Satisfies the Error interface.
|
||||||
func (e ErrorCode) Error() string {
|
func (e FundingError) Error() string {
|
||||||
return e.String()
|
return e.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,8 +56,6 @@ type ErrorData []byte
|
|||||||
// format is purposefully general in order to allow expression of a wide array
|
// format is purposefully general in order to allow expression of a wide array
|
||||||
// of possible errors. Each Error message is directed at a particular open
|
// of possible errors. Each Error message is directed at a particular open
|
||||||
// channel referenced by ChannelPoint.
|
// channel referenced by ChannelPoint.
|
||||||
//
|
|
||||||
// TODO(roasbeef): remove the error code
|
|
||||||
type Error struct {
|
type Error struct {
|
||||||
// ChanID references the active channel in which the error occurred
|
// ChanID references the active channel in which the error occurred
|
||||||
// within. If the ChanID is all zeros, then this error applies to the
|
// within. If the ChanID is all zeros, then this error applies to the
|
||||||
|
Loading…
Reference in New Issue
Block a user