routing+channeldb: add AddProof method

Originally we adding the edge without proof in order to able to use it
for payments path constrcution. This method will allow us to populate
the announcement proof after the exchange of the half proofs and
constrcutrion of full proof finished.
This commit is contained in:
Andrey Samokhvalov
2017-03-27 20:00:38 +03:00
committed by Olaoluwa Osuntokun
parent 4bca54e30c
commit 07076cce21
4 changed files with 100 additions and 0 deletions

View File

@@ -34,6 +34,10 @@ type ChannelGraphSource interface {
// edge/channel might be used in construction of payment path.
AddEdge(edge *channeldb.ChannelEdgeInfo) error
// AddProof updates the channel edge info with proof which is needed
// to properly announce the edge to the rest of the network.
AddProof(chanID lnwire.ShortChannelID, proof *channeldb.ChannelAuthProof) error
// UpdateEdge is used to update edge information, without this
// message edge considered as not fully constructed.
UpdateEdge(policy *channeldb.ChannelEdgePolicy) error
@@ -1063,3 +1067,18 @@ func (r *ChannelRouter) ForEachChannel(cb func(chanInfo *channeldb.ChannelEdgeIn
e1, e2 *channeldb.ChannelEdgePolicy) error) error {
return r.cfg.Graph.ForEachChannel(cb)
}
// AddProof updates the channel edge info with proof which is needed
// to properly announce the edge to the rest of the network.
// NOTE: Part of the Router interface.
func (r *ChannelRouter) AddProof(chanID lnwire.ShortChannelID,
proof *channeldb.ChannelAuthProof) error {
info, _, _, err := r.cfg.Graph.FetchChannelEdgesByID(chanID.ToUint64())
if err != nil {
return err
}
info.AuthProof = proof
return r.cfg.Graph.UpdateChannelEdge(info)
}