[ROUTING] Improve 'routing.Table' interface.
Description:
Currently, we are very dependent on (routing.Table).RangeRules() to search the contents of routing.Table. We should have specific search functions for each search (add methods to routing.Table interface).
Motivation:
This allows for a clearer overview of how we interact with the routing table.
Tasks:
- [ ] Document a list of the aforementioned cases.
- [ ] Make a proposal of how we are to change the
routing.Tableinterface. - [ ] Make relevant changes.
- [ ] Test.
Which ability do you think we are lacking now when looking for a rule?. Do you have any specific case in which it will be convenient to have additional search functions?
@ivcosla I think it's not like lacking it's more of improvement and comfort to use if I get it correctly.
@evanlinjin I looked through all of the RangeRules calls. The most valuable use cases I see there are:
- Search for a specific type of rule
- Search for a rule not yet expired
Based on this, I would propose to add the following funcs to the interface:
- NotExpired() map[RouteID]Rule
- RuleOfType(t RuleType) map[RouteID]Rule
Also these could be done in the same manner as
RangeRulesnow (e.g. receive iterating func as an argument)
For further discussion I may also suggest:
- Expired() map[RouteID]Rule
All other funcs that need more complex search should still use the RangeRules
I like this. But I would rename RuleOfType to RulesOfType. Also, let's have both NotExpired() and Expired().