Skip to content
Snippets Groups Projects
Unverified Commit f85e0e4c authored by takt's avatar takt Committed by GitHub
Browse files

Add prefix dedup function that also dedups IPs (#231)

parent 59e01a4b
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,12 @@ func (p *Prefix) Dedup() *Prefix {
return pfxc.get(p)
}
// DedupWithIP gets a copy of Prefix from the cache and dedups the IP part
func (p *Prefix) DedupWithIP() *Prefix {
p.addr = p.addr.Dedup()
return pfxc.get(p)
}
// NewPrefixFromProtoPrefix creates a Prefix from a proto Prefix
func NewPrefixFromProtoPrefix(pfx api.Prefix) *Prefix {
return &Prefix{
......@@ -54,10 +60,10 @@ func PrefixFromString(s string) (*Prefix, error) {
}
// ToProto converts prefix to proto prefix
func (pfx *Prefix) ToProto() *api.Prefix {
func (p *Prefix) ToProto() *api.Prefix {
return &api.Prefix{
Address: pfx.addr.ToProto(),
Pfxlen: uint32(pfx.pfxlen),
Address: p.addr.ToProto(),
Pfxlen: uint32(p.pfxlen),
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment