Send + Recv compressed multiaddrs (bytes). this makes
for much smaller addresses, as string addresses are
inflated for human readability. compare:
```
consider: "/ip4/192.168.10.10/tcp/13456"
string: 0x2f6970342f3139322e3136382e31302e31302f7463702f3133343536
packed: 0x04c0a80a0a063490
```
Online record verification -- meaning record verification
that might cause messages to other peers -- presents a
way to perform an attack on a dht node: forge a record and
make the node attempt to fetch the public key to verify.
This becomes a very powerful amplification attack if
online verification is done for records _received passively_.
This means records that were received as the result of a
PUT_VALUE or ADD_PROVIDER. Thus we only accept records we
can verify offline (whose public keys we already have). In
practice this is not at all a problem for us, because
typical connections are encrypted: we've already exchanged
public keys.
Providers are records that need Addresses. The routing
system needs to provide -- not only the ID, but also --
the peer's Addresses. A peer.PeerInfo is a small struct
to pass around a peer.ID and []ma.Multiaddr.
routing interface doesn't wait for value to appear in network, but value
doesn't appear in network until time as passed
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
When performing this "promise" pattern, it is important to
provide a
channel with space for one value. Otherwise the sender may
block forever
in the case of a receiver that decides to abandon the
request. A subtle
detail, but one that is important for avoiding
leaked goroutines.
cc @whyrusleeping @jbenet
License: MIT
Signed-off-by: Brian Tiger Chow
<brian@perfmode.com>
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
This commit makes GetProviders (sync) respect the request context. It
also amends all of GetProviders' callsites to pass a context in. This
meant changing the signature of the dht's handlerfunc.
I think I'll start referring to the request context as Vito Corleone.
cc @whyrusleeping @jbenet
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
the important change here is that within FindProvidersAsync, the channel
is closed using a `defer`. This ensures the channel is always closed,
regardless of the path taken to exit.
+ misc cleanup
cc @whyrusleeping @jbenet
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>