diff --git a/blockservice/blockservice.go b/blockservice/blockservice.go index 0b4f15b9878556c918ab81ad207708ed996e82c0..011ad0283f2b62d57abe50f6468aa9f3e3fa8093 100644 --- a/blockservice/blockservice.go +++ b/blockservice/blockservice.go @@ -5,8 +5,8 @@ import ( "time" ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go" - bitswap "github.com/jbenet/go-ipfs/bitswap" blocks "github.com/jbenet/go-ipfs/blocks" + exchange "github.com/jbenet/go-ipfs/exchange" u "github.com/jbenet/go-ipfs/util" mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" @@ -16,11 +16,11 @@ import ( // It uses an internal `datastore.Datastore` instance to store values. type BlockService struct { Datastore ds.Datastore - Remote bitswap.Exchange + Remote exchange.Exchange } // NewBlockService creates a BlockService with given datastore instance. -func NewBlockService(d ds.Datastore, rem bitswap.Exchange) (*BlockService, error) { +func NewBlockService(d ds.Datastore, rem exchange.Exchange) (*BlockService, error) { if d == nil { return nil, fmt.Errorf("BlockService requires valid datastore") } diff --git a/core/core.go b/core/core.go index 3ada24f156309b157a7f584a43e2d97f096b1d47..69a8bab09fb3d45bce79f0c0791b08d5a30e5274 100644 --- a/core/core.go +++ b/core/core.go @@ -10,10 +10,11 @@ import ( b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58" ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" - bitswap "github.com/jbenet/go-ipfs/bitswap" bserv "github.com/jbenet/go-ipfs/blockservice" config "github.com/jbenet/go-ipfs/config" ci "github.com/jbenet/go-ipfs/crypto" + exchange "github.com/jbenet/go-ipfs/exchange" + bitswap "github.com/jbenet/go-ipfs/exchange/bitswap" merkledag "github.com/jbenet/go-ipfs/merkledag" inet "github.com/jbenet/go-ipfs/net" mux "github.com/jbenet/go-ipfs/net/mux" @@ -47,7 +48,7 @@ type IpfsNode struct { Routing routing.IpfsRouting // the block exchange + strategy (bitswap) - BitSwap bitswap.Exchange + BitSwap exchange.Exchange // the block service, get/add blocks. Blocks *bserv.BlockService @@ -88,7 +89,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) { net inet.Network // TODO: refactor so we can use IpfsRouting interface instead of being DHT-specific route *dht.IpfsDHT - exchangeSession bitswap.Exchange + exchangeSession exchange.Exchange ) if online { diff --git a/bitswap/bitswap.go b/exchange/bitswap/bitswap.go similarity index 92% rename from bitswap/bitswap.go rename to exchange/bitswap/bitswap.go index ebbdd7b1101ea365d4a483e5db255d111cb5e29c..71b879f98bd0327c3e3d1a351c38a5f7d6136330 100644 --- a/bitswap/bitswap.go +++ b/exchange/bitswap/bitswap.go @@ -7,12 +7,13 @@ import ( context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go" - bsmsg "github.com/jbenet/go-ipfs/bitswap/message" - bsnet "github.com/jbenet/go-ipfs/bitswap/network" - notifications "github.com/jbenet/go-ipfs/bitswap/notifications" - strategy "github.com/jbenet/go-ipfs/bitswap/strategy" blocks "github.com/jbenet/go-ipfs/blocks" blockstore "github.com/jbenet/go-ipfs/blockstore" + exchange "github.com/jbenet/go-ipfs/exchange" + bsmsg "github.com/jbenet/go-ipfs/exchange/bitswap/message" + bsnet "github.com/jbenet/go-ipfs/exchange/bitswap/network" + notifications "github.com/jbenet/go-ipfs/exchange/bitswap/notifications" + strategy "github.com/jbenet/go-ipfs/exchange/bitswap/strategy" peer "github.com/jbenet/go-ipfs/peer" u "github.com/jbenet/go-ipfs/util" ) @@ -37,7 +38,7 @@ type bitswap struct { blockstore blockstore.Blockstore // routing interface for communication - routing Directory + routing exchange.Directory notifications notifications.PubSub @@ -48,7 +49,7 @@ type bitswap struct { } // NewSession initializes a bitswap session. -func NewSession(parent context.Context, s bsnet.NetworkService, p *peer.Peer, d ds.Datastore, directory Directory) Exchange { +func NewSession(parent context.Context, s bsnet.NetworkService, p *peer.Peer, d ds.Datastore, directory exchange.Directory) exchange.Exchange { // FIXME(brian): instantiate a concrete Strategist receiver := bsnet.Forwarder{} diff --git a/bitswap/message/Makefile b/exchange/bitswap/message/Makefile similarity index 100% rename from bitswap/message/Makefile rename to exchange/bitswap/message/Makefile diff --git a/bitswap/message/message.go b/exchange/bitswap/message/message.go similarity index 100% rename from bitswap/message/message.go rename to exchange/bitswap/message/message.go diff --git a/bitswap/message/message.pb.go b/exchange/bitswap/message/message.pb.go similarity index 100% rename from bitswap/message/message.pb.go rename to exchange/bitswap/message/message.pb.go diff --git a/bitswap/message/message.proto b/exchange/bitswap/message/message.proto similarity index 100% rename from bitswap/message/message.proto rename to exchange/bitswap/message/message.proto diff --git a/bitswap/message/message_test.go b/exchange/bitswap/message/message_test.go similarity index 100% rename from bitswap/message/message_test.go rename to exchange/bitswap/message/message_test.go diff --git a/bitswap/network/forwarder.go b/exchange/bitswap/network/forwarder.go similarity index 92% rename from bitswap/network/forwarder.go rename to exchange/bitswap/network/forwarder.go index f4eba0c14591f7e54903be068a1ad85102d6cfbd..603cd0123bc361c1b4dbf1b2a45f0fa739e633d8 100644 --- a/bitswap/network/forwarder.go +++ b/exchange/bitswap/network/forwarder.go @@ -2,7 +2,7 @@ package network import ( context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" - bsmsg "github.com/jbenet/go-ipfs/bitswap/message" + bsmsg "github.com/jbenet/go-ipfs/exchange/bitswap/message" peer "github.com/jbenet/go-ipfs/peer" ) diff --git a/bitswap/network/forwarder_test.go b/exchange/bitswap/network/forwarder_test.go similarity index 100% rename from bitswap/network/forwarder_test.go rename to exchange/bitswap/network/forwarder_test.go diff --git a/bitswap/network/interface.go b/exchange/bitswap/network/interface.go similarity index 95% rename from bitswap/network/interface.go rename to exchange/bitswap/network/interface.go index 89157b7a87197ec7fbbd01bc4e380dd32ed35687..7033983540b8a198949c90b15bbd023d225adc10 100644 --- a/bitswap/network/interface.go +++ b/exchange/bitswap/network/interface.go @@ -4,7 +4,7 @@ import ( context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" netservice "github.com/jbenet/go-ipfs/net/service" - bsmsg "github.com/jbenet/go-ipfs/bitswap/message" + bsmsg "github.com/jbenet/go-ipfs/exchange/bitswap/message" netmsg "github.com/jbenet/go-ipfs/net/message" peer "github.com/jbenet/go-ipfs/peer" ) diff --git a/bitswap/network/network_adapter.go b/exchange/bitswap/network/network_adapter.go similarity index 97% rename from bitswap/network/network_adapter.go rename to exchange/bitswap/network/network_adapter.go index f4b0a19371e8b670c57083766c818d3a469398d6..8914101bc5e4c6287b9689564545d3d7c7c6205b 100644 --- a/bitswap/network/network_adapter.go +++ b/exchange/bitswap/network/network_adapter.go @@ -5,7 +5,7 @@ import ( context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" - bsmsg "github.com/jbenet/go-ipfs/bitswap/message" + bsmsg "github.com/jbenet/go-ipfs/exchange/bitswap/message" netmsg "github.com/jbenet/go-ipfs/net/message" peer "github.com/jbenet/go-ipfs/peer" ) diff --git a/bitswap/notifications/notifications.go b/exchange/bitswap/notifications/notifications.go similarity index 100% rename from bitswap/notifications/notifications.go rename to exchange/bitswap/notifications/notifications.go diff --git a/bitswap/notifications/notifications_test.go b/exchange/bitswap/notifications/notifications_test.go similarity index 100% rename from bitswap/notifications/notifications_test.go rename to exchange/bitswap/notifications/notifications_test.go diff --git a/bitswap/offline.go b/exchange/bitswap/offline.go similarity index 88% rename from bitswap/offline.go rename to exchange/bitswap/offline.go index d1c0fea148c52029f985ae191d101e776d269e4b..46b71d27b515240db72ab6ffb91e4d3037f31d02 100644 --- a/bitswap/offline.go +++ b/exchange/bitswap/offline.go @@ -5,10 +5,11 @@ import ( "time" blocks "github.com/jbenet/go-ipfs/blocks" + exchange "github.com/jbenet/go-ipfs/exchange" u "github.com/jbenet/go-ipfs/util" ) -func NewOfflineExchange() Exchange { +func NewOfflineExchange() exchange.Exchange { return &offlineExchange{} } diff --git a/bitswap/offline_test.go b/exchange/bitswap/offline_test.go similarity index 100% rename from bitswap/offline_test.go rename to exchange/bitswap/offline_test.go diff --git a/bitswap/strategy/interface.go b/exchange/bitswap/strategy/interface.go similarity index 94% rename from bitswap/strategy/interface.go rename to exchange/bitswap/strategy/interface.go index bfbfe599c4b13cd689ed628b3dc5eb0c4240b2a3..8608c52cecc9b5ab047957845c5ce48882865d86 100644 --- a/bitswap/strategy/interface.go +++ b/exchange/bitswap/strategy/interface.go @@ -1,7 +1,7 @@ package strategy import ( - bsmsg "github.com/jbenet/go-ipfs/bitswap/message" + bsmsg "github.com/jbenet/go-ipfs/exchange/bitswap/message" peer "github.com/jbenet/go-ipfs/peer" u "github.com/jbenet/go-ipfs/util" ) diff --git a/bitswap/strategy/ledger.go b/exchange/bitswap/strategy/ledger.go similarity index 100% rename from bitswap/strategy/ledger.go rename to exchange/bitswap/strategy/ledger.go diff --git a/bitswap/strategy/ledger_test.go b/exchange/bitswap/strategy/ledger_test.go similarity index 100% rename from bitswap/strategy/ledger_test.go rename to exchange/bitswap/strategy/ledger_test.go diff --git a/bitswap/strategy/math.go b/exchange/bitswap/strategy/math.go similarity index 100% rename from bitswap/strategy/math.go rename to exchange/bitswap/strategy/math.go diff --git a/bitswap/strategy/math_test.go b/exchange/bitswap/strategy/math_test.go similarity index 100% rename from bitswap/strategy/math_test.go rename to exchange/bitswap/strategy/math_test.go diff --git a/bitswap/strategy/strategy.go b/exchange/bitswap/strategy/strategy.go similarity index 97% rename from bitswap/strategy/strategy.go rename to exchange/bitswap/strategy/strategy.go index 4e9a6df31704454bba4a7f63f54751e90a20f724..20881156162c444d7fa5f46b15f3af52588c0969 100644 --- a/bitswap/strategy/strategy.go +++ b/exchange/bitswap/strategy/strategy.go @@ -3,7 +3,7 @@ package strategy import ( "errors" - bsmsg "github.com/jbenet/go-ipfs/bitswap/message" + bsmsg "github.com/jbenet/go-ipfs/exchange/bitswap/message" "github.com/jbenet/go-ipfs/peer" u "github.com/jbenet/go-ipfs/util" ) diff --git a/bitswap/strategy/strategy_test.go b/exchange/bitswap/strategy/strategy_test.go similarity index 100% rename from bitswap/strategy/strategy_test.go rename to exchange/bitswap/strategy/strategy_test.go diff --git a/bitswap/interface.go b/exchange/interface.go similarity index 100% rename from bitswap/interface.go rename to exchange/interface.go