channeldb: add ErrEdgeAlreadyExist error

This commit is contained in:
Andrey Samokhvalov 2017-03-28 20:27:00 +03:00 committed by Olaoluwa Osuntokun
parent c3b2854428
commit 7a9a52c7b9
2 changed files with 6 additions and 2 deletions

@ -69,7 +69,11 @@ var (
// ErrEdgeNotFound is returned when an edge for the target chanID
// can't be found.
ErrEdgeNotFound = fmt.Errorf("edge for chanID not found")
ErrEdgeNotFound = fmt.Errorf("edge not found")
// ErrEdgeAlreadyExist is returned when edge with specific
// channel id can't be added because it already exist.
ErrEdgeAlreadyExist = fmt.Errorf("edge already exist")
// ErrNodeAliasNotFound is returned when alias for node can't be found.
ErrNodeAliasNotFound = fmt.Errorf("alias for node not found")

@ -424,7 +424,7 @@ func (c *ChannelGraph) AddChannelEdge(edge *ChannelEdgeInfo) error {
// created. If so, then we can exit early as this method is
// meant to be idempotent.
if edgeInfo := edgeIndex.Get(chanKey[:]); edgeInfo != nil {
return nil
return ErrEdgeAlreadyExist
}
// If the edge hasn't been created yet, then we'll first add it