cidranger
cidranger copied to clipboard
trie.go:insert - fix proposal for Ipv4\Ipv6 in same trie
func (p *prefixTrie) insert(network rnet.Network, entry RangerEntry) (bool, error) {
* * *
// No existing child, insert new leaf trie.
if existingChild == nil || existingChild.network.Number == nil {
* * *
}
* * *
// Check whether it is necessary to insert additional path prefix between current trie and existing child,
// in the case that inserted network diverges on its path to existing child.
if lcb, err := network.LeastCommonBitPosition(existingChild.network); err == nil {
* * *
} else {
return false, err
}
return existingChild.insert(network, entry)
}