protocol "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/protocol" routing "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing" pb "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/dht/pb" kb "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/kbucket" record "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/record" "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" u "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util" proto "github.com/heems/bssim/Godeps/_workspace/src/github.com/gogo/protobuf/proto" ds "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-datastore" goprocess "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/goprocess" goprocessctx "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/goprocess/context" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" ) var log = eventlog.Logger("dht") var ProtocolDHT protocol.ID = "/ipfs/dht" // NumBootstrapQueries defines the number of random dht queries to do to // collect members of the routing table. const NumBootstrapQueries = 5 // TODO. SEE https://github.com/jbenet/node-ipfs/blob/master/submodules/ipfs-dht/index.js // IpfsDHT is an implementation of Kademlia with Coral and S/Kademlia modifications. // It is used to implement the base IpfsRouting module. type IpfsDHT struct { host host.Host // the network services we need self peer.ID // Local peer (yourself) peerstore peer.Peerstore // Peer Registry
package relay import ( "fmt" "io" mh "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-multihash" host "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/host" inet "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/net" peer "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer" protocol "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/protocol" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" ) var log = eventlog.Logger("p2p/protocol/relay") // ID is the protocol.ID of the Relay Service. const ID protocol.ID = "/ipfs/relay" // Relay is a structure that implements ProtocolRelay. // It is a simple relay service which forwards traffic // between two directly connected peers. // // the protocol is very simple: // // /ipfs/relay\n // <multihash src id> // <multihash dst id> // <data stream> //
package record import ( "bytes" proto "github.com/heems/bssim/Godeps/_workspace/src/github.com/gogo/protobuf/proto" key "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key" dag "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/merkledag" ci "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/crypto" pb "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/dht/pb" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" ) var _ = dag.FetchGraph var log = eventlog.Logger("routing/record") // MakePutRecord creates and signs a dht record for the given key/value pair func MakePutRecord(sk ci.PrivKey, key key.Key, value []byte, sign bool) (*pb.Record, error) { record := new(pb.Record) record.Key = proto.String(string(key)) record.Value = value pkh, err := sk.GetPublic().Hash() if err != nil { return nil, err } record.Author = proto.String(string(pkh)) if sign {
package ipfsaddr import ( "errors" "strings" ma "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" peer "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" ) var log = eventlog.Logger("ipfsaddr") // ErrInvalidAddr signals an address is not a valid ipfs address. var ErrInvalidAddr = errors.New("invalid ipfs address") type IPFSAddr interface { ID() peer.ID Multiaddr() ma.Multiaddr Transport() ma.Multiaddr String() string Equal(b interface{}) bool } type ipfsAddr struct { ma ma.Multiaddr id peer.ID } func (a ipfsAddr) ID() peer.ID {
import ( "bytes" "io" "testing" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" u "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util" testutil "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util/testutil" ic "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/crypto" peer "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer" ma "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ) var log = eventlog.Logger("boguskey") // TestBogusPrivateKey is a key used for testing (to avoid expensive keygen) type TestBogusPrivateKey []byte // TestBogusPublicKey is a key used for testing (to avoid expensive keygen) type TestBogusPublicKey []byte func (pk TestBogusPublicKey) Verify(data, sig []byte) (bool, error) { log.Errorf("TestBogusPublicKey.Verify -- this better be a test!") return bytes.Equal(data, reverse(sig)), nil } func (pk TestBogusPublicKey) Bytes() ([]byte, error) { return []byte(pk), nil }
blockstore "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/blockstore" key "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key" exchange "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/exchange" decision "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/exchange/bitswap/decision" bsmsg "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/exchange/bitswap/message" bsnet "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/exchange/bitswap/network" notifications "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/exchange/bitswap/notifications" wantlist "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/exchange/bitswap/wantlist" peer "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer" "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/delay" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" process "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/goprocess" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" ) var log = eventlog.Logger("bitswap") const ( // maxProvidersPerRequest specifies the maximum number of providers desired // from the network. This value is specified because the network streams // results. // TODO: if a 'non-nice' strategy is implemented, consider increasing this value maxProvidersPerRequest = 3 providerRequestTimeout = time.Second * 10 hasBlockTimeout = time.Second * 15 provideTimeout = time.Second * 15 sizeBatchRequestChan = 32 // kMaxPriority is the max priority as defined by the bitswap protocol kMaxPriority = math.MaxInt32 HasBlockBufferSize = 256
"errors" "fmt" "io" "sync" "time" ci "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/crypto" pb "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/crypto/secio/pb" peer "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" u "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util" msgio "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-msgio" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" ) var log = eventlog.Logger("secio") // ErrUnsupportedKeyType is returned when a private key cast/type switch fails. var ErrUnsupportedKeyType = errors.New("unsupported key type") // ErrClosed signals the closing of a connection. var ErrClosed = errors.New("connection closed") // ErrEcho is returned when we're attempting to handshake with the same keys and nonces. var ErrEcho = errors.New("same keys and nonces. one side talking to self.") // HandshakeTimeout governs how long the handshake will be allowed to take place for. // Making this number large means there could be many bogus connections waiting to // timeout in flight. Typical handshakes take ~3RTTs, so it should be completed within // seconds across a typical planet in the solar system. var HandshakeTimeout = time.Second * 30
package protocol import ( "fmt" "io" "sync" inet "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/net" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" lgbl "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util/eventlog/loggables" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" ) var log = eventlog.Logger("net/mux") type streamHandlerMap map[ID]inet.StreamHandler // Mux provides simple stream multixplexing. // It helps you precisely when: // * You have many streams // * You have function handlers // // It contains the handlers for each protocol accepted. // It dispatches handlers for streams opened by remote peers. type Mux struct { lock sync.RWMutex handlers streamHandlerMap defaultHandler inet.StreamHandler } func NewMux() *Mux {
package relay_test import ( "io" "testing" inet "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/net" protocol "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/protocol" relay "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/protocol/relay" testutil "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/test/util" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" ) var log = eventlog.Logger("relay_test") func TestRelaySimple(t *testing.T) { ctx := context.Background() // these networks have the relay service wired in already. n1 := testutil.GenHostSwarm(t, ctx) n2 := testutil.GenHostSwarm(t, ctx) n3 := testutil.GenHostSwarm(t, ctx) n1p := n1.ID() n2p := n2.ID() n3p := n3.ID() n2pi := n2.Peerstore().PeerInfo(n2p)
"net" "time" ic "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/crypto" peer "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" u "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util" lgbl "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util/eventlog/loggables" msgio "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-msgio" mpool "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-msgio/mpool" ma "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" manet "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" ) var log = eventlog.Logger("conn") // ReleaseBuffer puts the given byte array back into the buffer pool, // first verifying that it is the correct size func ReleaseBuffer(b []byte) { log.Debugf("Releasing buffer! (cap,size = %d, %d)", cap(b), len(b)) mpool.ByteSlicePool.Put(uint32(cap(b)), b) } // singleConn represents a single connection to another Peer (IPFS Node). type singleConn struct { local peer.ID remote peer.ID maconn manet.Conn msgrw msgio.ReadWriteCloser event io.Closer
package dht_pb import ( ma "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" key "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key" inet "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/net" peer "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" ) var log = eventlog.Logger("dht.pb") type PeerRoutingInfo struct { peer.PeerInfo inet.Connectedness } // NewMessage constructs a new dht message with given type, key, and level func NewMessage(typ Message_MessageType, key string, level int) *Message { m := &Message{ Type: &typ, Key: &key, } m.SetClusterLevel(level) return m } func peerRoutingInfoToPBPeer(p PeerRoutingInfo) *Message_Peer { pbp := new(Message_Peer)
"errors" "time" proto "github.com/heems/bssim/Godeps/_workspace/src/github.com/gogo/protobuf/proto" key "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key" ci "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/crypto" "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer" routing "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing" pb "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/dht/pb" record "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/record" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" ds "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-datastore" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" ) var log = eventlog.Logger("offlinerouting") var ErrOffline = errors.New("routing system in offline mode") func NewOfflineRouter(dstore ds.Datastore, privkey ci.PrivKey) routing.IpfsRouting { return &offlineRouting{ datastore: dstore, sk: privkey, } } // offlineRouting implements the IpfsRouting interface, // but only provides the capability to Put and Get signed dht // records to and from the local datastore. type offlineRouting struct { datastore ds.Datastore
ma "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" manet "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" nat "github.com/heems/bssim/Godeps/_workspace/src/github.com/fd/go-nat" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" notifier "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/notifier" goprocess "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/goprocess" periodic "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/goprocess/periodic" ) var ( // ErrNoMapping signals no mapping exists for an address ErrNoMapping = errors.New("mapping not established") ) var log = eventlog.Logger("nat") // MappingDuration is a default port mapping duration. // Port mappings are renewed every (MappingDuration / 3) const MappingDuration = time.Second * 60 // DiscoverNAT looks for a NAT device in the network and // returns an object that can manage port mappings. func DiscoverNAT() *NAT { nat, err := nat.DiscoverGateway() if err != nil { log.Debug("DiscoverGateway error:", err) return nil } addr, err := nat.GetDeviceAddress() if err != nil {
package mocknet import ( eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" ) var log = eventlog.Logger("mocknet") // WithNPeers constructs a Mocknet with N peers. func WithNPeers(ctx context.Context, n int) (Mocknet, error) { m := New(ctx) for i := 0; i < n; i++ { if _, err := m.GenPeer(); err != nil { return nil, err } } return m, nil } // FullMeshLinked constructs a Mocknet with full mesh of Links. // This means that all the peers **can** connect to each other // (not that they already are connected. you can use m.ConnectAll()) func FullMeshLinked(ctx context.Context, n int) (Mocknet, error) { m, err := WithNPeers(ctx, n) if err != nil { return nil, err } nets := m.Nets()
ggio "github.com/heems/bssim/Godeps/_workspace/src/github.com/gogo/protobuf/io" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" key "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key" host "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/host" inet "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/net" peer "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer" dhtpb "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/dht/pb" kbucket "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/kbucket" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" ) const ProtocolSNR = "/ipfs/supernoderouting" var log = eventlog.Logger("supernode/proxy") type Proxy interface { Bootstrap(context.Context) error HandleStream(inet.Stream) SendMessage(ctx context.Context, m *dhtpb.Message) error SendRequest(ctx context.Context, m *dhtpb.Message) (*dhtpb.Message, error) } type standard struct { Host host.Host remoteInfos []peer.PeerInfo // addr required for bootstrapping remoteIDs []peer.ID // []ID is required for each req. here, cached for performance. }
// decision engine is given responsibility for all of the others, it can // intelligently decide how to combine requests efficiently. // // Some examples of what would be possible: // // * when sending out the wantlists, include `cancel` requests // * when handling `blockrequests`, include `sendwantlist` and `cancel` as appropriate // * when handling `cancel`, if we recently received a wanted block from a // peer, include a partial wantlist that contains a few other high priority // blocks // // In a sense, if we treat the decision engine as a black box, it could do // whatever it sees fit to produce desired outcomes (get wanted keys // quickly, maintain good relationships with peers, etc). var log = eventlog.Logger("engine") const ( // outboxChanBuffer must be 0 to prevent stale messages from being sent outboxChanBuffer = 0 ) // Envelope contains a message for a Peer type Envelope struct { // Peer is the intended recipient Peer peer.ID // Block is the payload Block *blocks.Block // A callback to notify the decision queue that the task is complete
package reprovide import ( "fmt" "time" backoff "github.com/cenkalti/backoff" blocks "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/blockstore" routing "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" ) var log = eventlog.Logger("reprovider") type Reprovider struct { // The routing system to provide values through rsys routing.IpfsRouting // The backing store for blocks to be provided bstore blocks.Blockstore } func NewReprovider(rsys routing.IpfsRouting, bstore blocks.Blockstore) *Reprovider { return &Reprovider{ rsys: rsys, bstore: bstore, } } func (rp *Reprovider) ProvideEvery(ctx context.Context, tick time.Duration) {
package queue import ( peer "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" ) var log = eventlog.Logger("peerqueue") // ChanQueue makes any PeerQueue synchronizable through channels. type ChanQueue struct { Queue PeerQueue EnqChan chan<- peer.ID DeqChan <-chan peer.ID } // NewChanQueue creates a ChanQueue by wrapping pq. func NewChanQueue(ctx context.Context, pq PeerQueue) *ChanQueue { cq := &ChanQueue{Queue: pq} cq.process(ctx) return cq } func (cq *ChanQueue) process(ctx context.Context) { // construct the channels here to be able to use them bidirectionally enqChan := make(chan peer.ID) deqChan := make(chan peer.ID) cq.EnqChan = enqChan cq.DeqChan = deqChan
package addrutil import ( "fmt" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" ma "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" manet "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" ) var log = eventlog.Logger("p2p/net/swarm/addr") // SupportedTransportStrings is the list of supported transports for the swarm. // These are strings of encapsulated multiaddr protocols. E.g.: // /ip4/tcp var SupportedTransportStrings = []string{ "/ip4/tcp", "/ip6/tcp", // "/ip4/udp/utp", disabled because the lib is broken // "/ip6/udp/utp", disabled because the lib is broken // "/ip4/udp/udt", disabled because the lib doesnt work on arm // "/ip6/udp/udt", disabled because the lib doesnt work on arm } // SupportedTransportProtocols is the list of supported transports for the swarm. // These are []ma.Protocol lists. Populated at runtime from SupportedTransportStrings var SupportedTransportProtocols = [][]ma.Protocol{} func init() {
addrutil "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/net/swarm/addr" peer "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" ma "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ps "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-peerstream" pst "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-peerstream/transport" psy "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-peerstream/transport/yamux" "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/goprocess" goprocessctx "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/goprocess/context" prom "github.com/heems/bssim/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus" mafilter "github.com/heems/bssim/Godeps/_workspace/src/github.com/whyrusleeping/multiaddr-filter" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" ) var log = eventlog.Logger("swarm2") var PSTransport pst.Transport var peersTotal = prom.NewGaugeVec(prom.GaugeOpts{ Namespace: "ipfs", Subsystem: "p2p", Name: "peers_total", Help: "Number of connected peers", }, []string{"peer_id"}) func init() { tpt := *psy.DefaultTransport tpt.MaxStreamWindowSize = 512 * 1024 PSTransport = &tpt }
"errors" "time" proto "github.com/heems/bssim/Godeps/_workspace/src/github.com/gogo/protobuf/proto" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" key "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key" "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/host" peer "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer" routing "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing" pb "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/dht/pb" proxy "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/supernode/proxy" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" ) var log = eventlog.Logger("supernode") type Client struct { peerhost host.Host peerstore peer.Peerstore proxy proxy.Proxy local peer.ID } // TODO take in datastore/cache func NewClient(px proxy.Proxy, h host.Host, ps peer.Peerstore, local peer.ID) (*Client, error) { return &Client{ proxy: px, local: local, peerstore: ps, peerhost: h,
package blockstore import ( "errors" blocks "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks" key "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key" eventlog "github.com/heems/bssim/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/eventlog" ds "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-datastore" dsns "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-datastore/namespace" dsq "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-datastore/query" mh "github.com/heems/bssim/Godeps/_workspace/src/github.com/jbenet/go-multihash" context "github.com/heems/bssim/Godeps/_workspace/src/golang.org/x/net/context" ) var log = eventlog.Logger("blockstore") // BlockPrefix namespaces blockstore datastores var BlockPrefix = ds.NewKey("blocks") var ValueTypeMismatch = errors.New("The retrieved value is not a Block") var ErrNotFound = errors.New("blockstore: block not found") // Blockstore wraps a ThreadSafeDatastore type Blockstore interface { DeleteBlock(key.Key) error Has(key.Key) (bool, error) Get(key.Key) (*blocks.Block, error) Put(*blocks.Block) error PutMany([]*blocks.Block) error