cidranger icon indicating copy to clipboard operation
cidranger copied to clipboard

trie.go:insert - fix proposal for Ipv4\Ipv6 in same trie

Open dmineev opened this issue 3 years ago • 0 comments

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)
}

dmineev avatar Aug 12 '21 22:08 dmineev