"errors" "time" proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto" ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" key "github.com/ipfs/go-ipfs/blocks/key" ci "github.com/ipfs/go-ipfs/p2p/crypto" "github.com/ipfs/go-ipfs/p2p/peer" routing "github.com/ipfs/go-ipfs/routing" pb "github.com/ipfs/go-ipfs/routing/dht/pb" record "github.com/ipfs/go-ipfs/routing/record" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" ) 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
import ( "bytes" "errors" "io" "time" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" host "github.com/ipfs/go-ipfs/p2p/host" inet "github.com/ipfs/go-ipfs/p2p/net" peer "github.com/ipfs/go-ipfs/p2p/peer" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" u "github.com/ipfs/go-ipfs/util" ) var log = eventlog.Logger("ping") const PingSize = 32 const ID = "/ipfs/ping" type PingService struct { Host host.Host } func NewPingService(h host.Host) *PingService { ps := &PingService{h} h.SetStreamHandler(ID, ps.PingHandler) return ps }
package network import ( ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" key "github.com/ipfs/go-ipfs/blocks/key" bsmsg "github.com/ipfs/go-ipfs/exchange/bitswap/message" host "github.com/ipfs/go-ipfs/p2p/host" inet "github.com/ipfs/go-ipfs/p2p/net" peer "github.com/ipfs/go-ipfs/p2p/peer" routing "github.com/ipfs/go-ipfs/routing" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" ) var log = eventlog.Logger("bitswap_network") // NewFromIpfsHost returns a BitSwapNetwork supported by underlying IPFS host func NewFromIpfsHost(host host.Host, r routing.IpfsRouting) BitSwapNetwork { bitswapNetwork := impl{ host: host, routing: r, } host.SetStreamHandler(ProtocolBitswap, bitswapNetwork.handleNewStream) host.Network().Notify((*netNotifiee)(&bitswapNetwork)) // TODO: StopNotify. return &bitswapNetwork } // impl transforms the ipfs network interface, which sends and receives // NetMessage objects, into the bitswap network interface.
package host import ( ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" metrics "github.com/ipfs/go-ipfs/metrics" inet "github.com/ipfs/go-ipfs/p2p/net" peer "github.com/ipfs/go-ipfs/p2p/peer" protocol "github.com/ipfs/go-ipfs/p2p/protocol" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" ) var log = eventlog.Logger("p2p/host") // Host is an object participating in a p2p network, which // implements protocols or provides services. It handles // requests like a Server, and issues requests like a Client. // It is called Host because it is both Server and Client (and Peer // may be confusing). type Host interface { // ID returns the (local) peer.ID associated with this Host ID() peer.ID // Peerstore returns the Host's repository of Peer Addresses and Keys. Peerstore() peer.Peerstore // Returns the listen addresses of the Host Addrs() []ma.Multiaddr // Networks returns the Network interface of the Host Network() inet.Network
package queue import ( context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" peer "github.com/ipfs/go-ipfs/p2p/peer" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" ) 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 blockstore import ( "errors" ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore" dsns "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/namespace" dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query" mh "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" blocks "github.com/ipfs/go-ipfs/blocks" key "github.com/ipfs/go-ipfs/blocks/key" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" ) 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
package record import ( "bytes" proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto" key "github.com/ipfs/go-ipfs/blocks/key" dag "github.com/ipfs/go-ipfs/merkledag" ci "github.com/ipfs/go-ipfs/p2p/crypto" pb "github.com/ipfs/go-ipfs/routing/dht/pb" eventlog "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 {
"errors" "fmt" "io" "sync" "time" msgio "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-msgio" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" ci "github.com/ipfs/go-ipfs/p2p/crypto" pb "github.com/ipfs/go-ipfs/p2p/crypto/secio/pb" peer "github.com/ipfs/go-ipfs/p2p/peer" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" u "github.com/ipfs/go-ipfs/util" ) 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
ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" manet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" cmds "github.com/ipfs/go-ipfs/commands" cmdsCli "github.com/ipfs/go-ipfs/commands/cli" cmdsHttp "github.com/ipfs/go-ipfs/commands/http" core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" u "github.com/ipfs/go-ipfs/util" ) // log is the command logger var log = eventlog.Logger("cmd/ipfs") // signal to output help var errHelpRequested = errors.New("Help Requested") const ( EnvEnableProfiling = "IPFS_PROF" cpuProfile = "ipfs.cpuprof" heapProfile = "ipfs.memprof" errorFormat = "ERROR: %v\n\n" ) type cmdInvocation struct { path []string cmd *cmds.Command req cmds.Request
package mocknet import ( eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" context "github.com/ipfs/go-ipfs/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/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/io" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" key "github.com/ipfs/go-ipfs/blocks/key" host "github.com/ipfs/go-ipfs/p2p/host" inet "github.com/ipfs/go-ipfs/p2p/net" peer "github.com/ipfs/go-ipfs/p2p/peer" dhtpb "github.com/ipfs/go-ipfs/routing/dht/pb" kbucket "github.com/ipfs/go-ipfs/routing/kbucket" eventlog "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. }
package dht_pb import ( ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" key "github.com/ipfs/go-ipfs/blocks/key" inet "github.com/ipfs/go-ipfs/p2p/net" peer "github.com/ipfs/go-ipfs/p2p/peer" eventlog "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)
ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" metrics "github.com/ipfs/go-ipfs/metrics" mstream "github.com/ipfs/go-ipfs/metrics/stream" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" inet "github.com/ipfs/go-ipfs/p2p/net" peer "github.com/ipfs/go-ipfs/p2p/peer" protocol "github.com/ipfs/go-ipfs/p2p/protocol" identify "github.com/ipfs/go-ipfs/p2p/protocol/identify" relay "github.com/ipfs/go-ipfs/p2p/protocol/relay" ) var log = eventlog.Logger("p2p/host/basic") // Option is a type used to pass in options to the host. type Option int const ( // NATPortMap makes the host attempt to open port-mapping in NAT devices // for all its listeners. Pass in this option in the constructor to // asynchronously a) find a gateway, b) open port mappings, c) republish // port mappings periodically. The NATed addresses are included in the // Host's Addrs() list. NATPortMap Option = iota ) // BasicHost is the basic implementation of the host.Host interface. This // particular host implementation:
"errors" "time" proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" key "github.com/ipfs/go-ipfs/blocks/key" "github.com/ipfs/go-ipfs/p2p/host" peer "github.com/ipfs/go-ipfs/p2p/peer" routing "github.com/ipfs/go-ipfs/routing" pb "github.com/ipfs/go-ipfs/routing/dht/pb" proxy "github.com/ipfs/go-ipfs/routing/supernode/proxy" eventlog "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 commands import ( "io" "strings" cmds "github.com/ipfs/go-ipfs/commands" unixfs "github.com/ipfs/go-ipfs/core/commands/unixfs" evlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" ) var log = evlog.Logger("core/commands") type TestOutput struct { Foo string Bar int } var Root = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "global p2p merkle-dag filesystem", Synopsis: ` ipfs [<flags>] <command> [<arg>] ... `, ShortDescription: ` BASIC COMMANDS init Initialize ipfs local configuration add <path> Add an object to ipfs cat <ref> Show ipfs object data get <ref> Download ipfs objects
gopath "path" "time" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" "github.com/ipfs/go-ipfs/commands/files" core "github.com/ipfs/go-ipfs/core" importer "github.com/ipfs/go-ipfs/importer" chunk "github.com/ipfs/go-ipfs/importer/chunk" merkledag "github.com/ipfs/go-ipfs/merkledag" "github.com/ipfs/go-ipfs/pin" "github.com/ipfs/go-ipfs/thirdparty/eventlog" unixfs "github.com/ipfs/go-ipfs/unixfs" ) var log = eventlog.Logger("coreunix") // Add builds a merkledag from the a reader, pinning all objects to the local // datastore. Returns a key representing the root node. func Add(n *core.IpfsNode, r io.Reader) (string, error) { // TODO more attractive function signature importer.BuildDagFromReader dagNode, err := importer.BuildDagFromReader( r, n.DAG, chunk.DefaultSplitter, importer.BasicPinnerCB(n.Pinning.GetManual()), ) if err != nil { return "", err } k, err := dagNode.Key()
"time" ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" lgbl "github.com/ipfs/go-ipfs/util/eventlog/loggables" metrics "github.com/ipfs/go-ipfs/metrics" host "github.com/ipfs/go-ipfs/p2p/host" inet "github.com/ipfs/go-ipfs/p2p/net" peer "github.com/ipfs/go-ipfs/p2p/peer" protocol "github.com/ipfs/go-ipfs/p2p/protocol" routing "github.com/ipfs/go-ipfs/routing" ) var log = eventlog.Logger("p2p/host/routed") // AddressTTL is the expiry time for our addresses. // We expire them quickly. const AddressTTL = time.Second * 10 // RoutedHost is a p2p Host that includes a routing system. // This allows the Host to find the addresses for peers when // it does not have them. type RoutedHost struct { host host.Host // embedded other host. route routing.IpfsRouting } func Wrap(h host.Host, r routing.IpfsRouting) *RoutedHost { return &RoutedHost{h, r}
ggio "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/io" ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" mstream "github.com/ipfs/go-ipfs/metrics/stream" host "github.com/ipfs/go-ipfs/p2p/host" inet "github.com/ipfs/go-ipfs/p2p/net" peer "github.com/ipfs/go-ipfs/p2p/peer" protocol "github.com/ipfs/go-ipfs/p2p/protocol" pb "github.com/ipfs/go-ipfs/p2p/protocol/identify/pb" config "github.com/ipfs/go-ipfs/repo/config" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" lgbl "github.com/ipfs/go-ipfs/util/eventlog/loggables" ) var log = eventlog.Logger("net/identify") // ID is the protocol.ID of the Identify Service. const ID protocol.ID = "/ipfs/identify" // IpfsVersion holds the current protocol version for a client running this code // TODO(jbenet): fix the versioning mess. const IpfsVersion = "ipfs/0.1.0" const ClientVersion = "go-ipfs/" + config.CurrentVersionNumber // IDService is a structure that implements ProtocolIdentify. // It is a trivial service that gives the other peer some // useful information about the local peer. A sort of hello. // // The IDService sends: // * Our IPFS Protocol Version
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" blocks "github.com/ipfs/go-ipfs/blocks" blockstore "github.com/ipfs/go-ipfs/blocks/blockstore" key "github.com/ipfs/go-ipfs/blocks/key" exchange "github.com/ipfs/go-ipfs/exchange" decision "github.com/ipfs/go-ipfs/exchange/bitswap/decision" bsmsg "github.com/ipfs/go-ipfs/exchange/bitswap/message" bsnet "github.com/ipfs/go-ipfs/exchange/bitswap/network" notifications "github.com/ipfs/go-ipfs/exchange/bitswap/notifications" wantlist "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist" peer "github.com/ipfs/go-ipfs/p2p/peer" "github.com/ipfs/go-ipfs/thirdparty/delay" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" ) 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
"math/rand" "testing" "time" host "github.com/ipfs/go-ipfs/p2p/host" inet "github.com/ipfs/go-ipfs/p2p/net" peer "github.com/ipfs/go-ipfs/p2p/peer" protocol "github.com/ipfs/go-ipfs/p2p/protocol" testutil "github.com/ipfs/go-ipfs/p2p/test/util" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" u "github.com/ipfs/go-ipfs/util" ) var log = eventlog.Logger("backpressure") // TestBackpressureStreamHandler tests whether mux handler // ratelimiting works. Meaning, since the handler is sequential // it should block senders. // // Important note: spdystream (which peerstream uses) has a set // of n workers (n=spdsystream.FRAME_WORKERS) which handle new // frames, including those starting new streams. So all of them // can be in the handler at one time. Also, the sending side // does not rate limit unless we call stream.Wait() // // // Note: right now, this happens muxer-wide. the muxer should // learn to flow control, so handlers cant block each other. func TestBackpressureStreamHandler(t *testing.T) {
addrutil "github.com/ipfs/go-ipfs/p2p/net/swarm/addr" peer "github.com/ipfs/go-ipfs/p2p/peer" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ps "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-peerstream" pst "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-stream-muxer" psy "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-stream-muxer/yamux" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess" goprocessctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context" prom "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus" mafilter "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/whyrusleeping/multiaddr-filter" context "github.com/ipfs/go-ipfs/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 }
"sync" "time" key "github.com/ipfs/go-ipfs/blocks/key" dag "github.com/ipfs/go-ipfs/merkledag" namesys "github.com/ipfs/go-ipfs/namesys" ci "github.com/ipfs/go-ipfs/p2p/crypto" path "github.com/ipfs/go-ipfs/path" pin "github.com/ipfs/go-ipfs/pin" ft "github.com/ipfs/go-ipfs/unixfs" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" ) var log = eventlog.Logger("ipnsfs") var ErrIsDirectory = errors.New("error: is a directory") // Filesystem is the writeable fuse filesystem structure type Filesystem struct { ctx context.Context dserv dag.DAGService nsys namesys.NameSystem resolver *path.Resolver pins pin.Pinner
"time" random "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" "github.com/ipfs/go-ipfs/core" coreunix "github.com/ipfs/go-ipfs/core/coreunix" mock "github.com/ipfs/go-ipfs/core/mock" mocknet "github.com/ipfs/go-ipfs/p2p/net/mock" "github.com/ipfs/go-ipfs/p2p/peer" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" "github.com/ipfs/go-ipfs/thirdparty/unit" testutil "github.com/ipfs/go-ipfs/util/testutil" ) var log = eventlog.Logger("epictest") const kSeed = 1 func Test1KBInstantaneous(t *testing.T) { conf := testutil.LatencyConfig{ NetworkLatency: 0, RoutingLatency: 0, BlockstoreLatency: 0, } if err := DirectAddCat(RandomBytes(1*unit.KB), conf); err != nil { t.Fatal(err) } }
syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync" commands "github.com/ipfs/go-ipfs/commands" core "github.com/ipfs/go-ipfs/core" corehttp "github.com/ipfs/go-ipfs/core/corehttp" corerouting "github.com/ipfs/go-ipfs/core/corerouting" "github.com/ipfs/go-ipfs/core/coreunix" peer "github.com/ipfs/go-ipfs/p2p/peer" "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" unit "github.com/ipfs/go-ipfs/thirdparty/unit" ds2 "github.com/ipfs/go-ipfs/util/datastore2" ) var elog = eventlog.Logger("gc-client") var ( cat = flag.Bool("cat", false, "else add") seed = flag.Int64("seed", 1, "") nBitsForKeypair = flag.Int("b", 1024, "number of bits for keypair (if repo is uninitialized)") ) func main() { flag.Parse() if err := run(); err != nil { fmt.Fprintf(os.Stderr, "error: %s\n", err) os.Exit(1) } }
mount "github.com/ipfs/go-ipfs/fuse/mount" ipnsfs "github.com/ipfs/go-ipfs/ipnsfs" merkledag "github.com/ipfs/go-ipfs/merkledag" namesys "github.com/ipfs/go-ipfs/namesys" path "github.com/ipfs/go-ipfs/path" pin "github.com/ipfs/go-ipfs/pin" repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" ) const IpnsValidatorTag = "ipns" const kSizeBlockstoreWriteCache = 100 const kReprovideFrequency = time.Hour * 12 var log = eventlog.Logger("core") type mode int const ( // zero value is not a valid mode, must be explicitly set invalidMode mode = iota offlineMode onlineMode ) // IpfsNode is IPFS Core module. It represents an IPFS instance. type IpfsNode struct { // Self Identity peer.ID // the local node's identity
swarm "github.com/ipfs/go-ipfs/p2p/net/swarm" protocol "github.com/ipfs/go-ipfs/p2p/protocol" testutil "github.com/ipfs/go-ipfs/p2p/test/util" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" u "github.com/ipfs/go-ipfs/util" ps "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-peerstream" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" ) func init() { // change the garbage collect timeout for testing. ps.GarbageCollectTimeout = 10 * time.Millisecond } var log = eventlog.Logger("reconnect") func EchoStreamHandler(stream inet.Stream) { c := stream.Conn() log.Debugf("%s echoing %s", c.LocalPeer(), c.RemotePeer()) go func() { defer stream.Close() io.Copy(stream, stream) }() } type sendChans struct { send chan struct{} sent chan struct{} read chan struct{} close_ chan struct{}
package corehttp import ( "fmt" "net" "net/http" "time" ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" manet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess" core "github.com/ipfs/go-ipfs/core" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" ) var log = eventlog.Logger("core/server") // ServeOption registers any HTTP handlers it provides on the given mux. // It returns the mux to expose to future options, which may be a new mux if it // is interested in mediating requests to future options, or the same mux // initially passed in if not. type ServeOption func(*core.IpfsNode, net.Listener, *http.ServeMux) (*http.ServeMux, error) // makeHandler turns a list of ServeOptions into a http.Handler that implements // all of the given options, in order. func makeHandler(n *core.IpfsNode, l net.Listener, options ...ServeOption) (http.Handler, error) { topMux := http.NewServeMux() mux := topMux for _, option := range options { var err error mux, err = option(n, l, mux)
"os" fuse "github.com/ipfs/go-ipfs/Godeps/_workspace/src/bazil.org/fuse" fs "github.com/ipfs/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs" proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" core "github.com/ipfs/go-ipfs/core" mdag "github.com/ipfs/go-ipfs/merkledag" path "github.com/ipfs/go-ipfs/path" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" uio "github.com/ipfs/go-ipfs/unixfs/io" ftpb "github.com/ipfs/go-ipfs/unixfs/pb" lgbl "github.com/ipfs/go-ipfs/util/eventlog/loggables" ) var log = eventlog.Logger("fuse/ipfs") // FileSystem is the readonly Ipfs Fuse Filesystem. type FileSystem struct { Ipfs *core.IpfsNode } // NewFileSystem constructs new fs using given core.IpfsNode instance. func NewFileSystem(ipfs *core.IpfsNode) *FileSystem { return &FileSystem{Ipfs: ipfs} } // Root constructs the Root of the filesystem, a Root object. func (f FileSystem) Root() (fs.Node, error) { return &Root{Ipfs: f.Ipfs}, nil }
package relay import ( "fmt" "io" mh "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" host "github.com/ipfs/go-ipfs/p2p/host" inet "github.com/ipfs/go-ipfs/p2p/net" peer "github.com/ipfs/go-ipfs/p2p/peer" protocol "github.com/ipfs/go-ipfs/p2p/protocol" eventlog "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 reprovide import ( "fmt" "time" backoff "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/cenkalti/backoff" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" blocks "github.com/ipfs/go-ipfs/blocks/blockstore" routing "github.com/ipfs/go-ipfs/routing" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" ) 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) {