skywire-testnet icon indicating copy to clipboard operation
skywire-testnet copied to clipboard

[ROUTING] Improve 'routing.Table' interface.

Open evanlinjin opened this issue 6 years ago • 3 comments

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.Table interface.
  • [ ] Make relevant changes.
  • [ ] Test.

evanlinjin avatar Jun 26 '19 16:06 evanlinjin

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 avatar Jun 28 '19 07:06 ivcosla

@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 RangeRules now (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

Darkren avatar Jul 01 '19 17:07 Darkren

I like this. But I would rename RuleOfType to RulesOfType. Also, let's have both NotExpired() and Expired().

evanlinjin avatar Jul 20 '19 12:07 evanlinjin