Skip to content

Instantly share code, notes, and snippets.

View anacrolix's full-sized avatar
🚀
Factorio

Matt Joiner anacrolix

🚀
Factorio
View GitHub Profile
macro_rules! handle {
($value:expr, $err:ident,$onerr:expr) => {
match $value {
Ok(ok) => ok,
Err($err) => $onerr,
}
};
}
dial queue completely ignores backoff errors. dial errors end query in first alpha value connect attempts:
> find_providers QmW1UQYrsBotoorzgBcQ3HVj5RzZUzB6g1vQwnNfUuCVdN 10
14:03:32.639 DEBUG dht: not connected. dialing. query.go:244
14:03:32.639 DEBUG dht: not connected. dialing. query.go:244
14:03:32.639 DEBUG dht: not connected. dialing. query.go:244
14:03:32.675 DEBUG dht: error connecting: dial backoff query.go:252
14:03:32.675 DEBUG dht: error connecting: dial backoff query.go:252
14:03:32.675 DEBUG dht: discarding dialled peer because of error: dial backoff dial_queue.go:325
14:03:32.675 DEBUG dht: discarding dialled peer because of error: dial backoff dial_queue.go:325
@anacrolix
anacrolix / go-mod.md
Last active March 5, 2019 01:07
Helpful resources for moving libp2p and IPFS repos toward go mod support

Prune local tags that don't exist on remote

All "naked" version tags from gx are now prefixed with gx/. The old ones should be removed from local checkouts to avoid repushing. This command removes local tags that don't exist on the remote.

git fetch --prune <remote> '+refs/tags/*:refs/tags/*'

Travis turd template

This template does CI for both gx and go-mod:

zenground0 [2:07 PM]
The first one is whether a libp2p host will advertise its (pid, multiaddr) mapping in a networks' DHT after constructing the node with a `libp2p.Routing(makeDHT)` option.
Right now this is all we do in the filecoin network and we don't seem to be advertising id,addr records in the dht.
Wondering if we're missing an obvious `provideRouteToMe` call or something like that
anacrolix [2:11 PM]
I’ll have to check, but a typical DHT will routinely reestablish its own presence to nearby peers, and announce itself during bootstraps.
In the context of libp2p, that should include the peer ID and routing information like multiaddrs
zenground0 [2:12 PM]
# this would be called before adding a connection to the connection manager
# (presumably we just completed dial or accept routines to completion)
def before_adding_conn():
if numconns < highwater:
return
# amortize the cost of evicting conns, drop connection count to the low water mark
for numconns > lowwater:
if not optimistic_evict():
force_eviction()

Keybase proof

I hereby claim:

  • I am anacrolix on github.
  • I am anacrolix (https://keybase.io/anacrolix) on keybase.
  • I have a public key ASAJKwn773yfndSRr376At4mjuwp4QspnAeQlMimAhVXogo

To claim this, I am signing this object:

@anacrolix
anacrolix / ipgo.sh
Last active February 28, 2019 18:49 — forked from Stebalien/ipgo.sh
#!/bin/bash
set -eu
export IPFS_GATEWAY="${IPFS_GATEWAY:-http://127.0.0.1:8080}"
CACHE_DIR="$(go env GOPATH)/pkg/mod/cache"
basepath() {
echo "${1##${CACHE_DIR}/download/}"
package s3storage
import (
"bytes"
"crypto/sha1"
"encoding/hex"
"errors"
"fmt"
"io"
"log"
func (cn *connection) iterUnbiasedPieceRequestOrder(f func(piece int) bool) bool {
now, readahead := cn.t.readerPiecePriorities()
var skip bitmap.Bitmap
if !cn.peerSentHaveAll {
// Pieces to skip include pieces the peer doesn't have.
skip = bitmap.Flip(cn.peerPieces, 0, cn.t.numPieces())
}
// And pieces that we already have.
skip.Union(cn.t.completedPieces)
skip.Union(cn.t.piecesQueuedForHash)