53 lines
2.4 KiB
Markdown
53 lines
2.4 KiB
Markdown
|
# Location filter
|
||
|
|
||
|
|
||
|
Using DHT, geopositional ranges could be used as a prefix to scope indexes and route queries.
|
||
|
|
||
|
|
||
|
Earth circumference is around 40000 km.
|
||
|
|
||
|
Divided into 256 units, each unit would span around 150 km, which would constitute a feasible full-day roundtrip with motorized transport.
|
||
|
|
||
|
Further divided into 16 units, each unit would span about 10km, which would constitute a feasible full-day roundtrip on foot (which is the reality of mobility for most people in the world).
|
||
|
|
||
|
Further divided into 64 units, each unit would span around 150 metres, which is a couple of minutes' walk, or the equivalent of "what exists where I am right now," i.e. the smallest resolution needed in practical terms.
|
||
|
|
||
|
In practice, the units would be defined by degrees, conventionally starting at 0N 0E.
|
||
|
|
||
|
|
||
|
## Location filter base representation
|
||
|
|
||
|
The above allows us to express the location scope in a series of three bit fields,
|
||
|
|
||
|
- layer 1: bit 0-255: units of ~150 km
|
||
|
- layer 2: bit 256-269: units of ~10km
|
||
|
- layer 3: bit 270-333: units of ~0.15km
|
||
|
|
||
|
Thus, the filter can be represented within 42 bytes per axis, or 84 bytes total.
|
||
|
|
||
|
|
||
|
|
||
|
### Indexer scopes
|
||
|
|
||
|
Indexers will declare the geopositional scope of their relevance.
|
||
|
|
||
|
This would most likely be defined in layer 1 only. If an indexer only defines a single bit in layer 1, the protocol could advise that layer 2 is inspected for better granularity. And again the same with layer 2 and layer 3.
|
||
|
|
||
|
|
||
|
### Ask and bid scopes
|
||
|
|
||
|
A store would define its origin in coordinates, from which a location filter bit field would be compiled. The scope should always be defined in terms layer 3.
|
||
|
|
||
|
When the ask or bid is announced on the network, the forwarders and indexers can make a simple bitwise comparison to determine whether it matches its scope, and/or choose where to forward it to. This will localize the gossip and limit network congestion.
|
||
|
|
||
|
|
||
|
## Filter optimizations
|
||
|
|
||
|
The filter could optionally be shortened by omitting the layer(s) that dont carry information (e.g. scope is only defined in terms of layer 1).
|
||
|
|
||
|
|
||
|
The network could maintain consensus on e.g. the max scope limit any indexer may provide, and/or whether the scopes must be contiguous.
|
||
|
If the max limit was 1 unit in layer 1, then the layer one could be represented by a single byte only, whose numeric value defines the single relevant sector.
|
||
|
|
||
|
Similarily, if scopes must be contiguous, only two numeric values would be needed; one to define the offset and one to define the number of units.
|