From ca6a502d119bbc55ef3b3fd615161b04905a93f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Tue, 28 May 2019 16:42:41 +0100 Subject: [PATCH] migrate to go-libp2p-core. --- go.mod | 15 ++++++-------- go.sum | 41 ++++++++++++++++++++++++++++++++++++++ mock/centralized_client.go | 32 ++++++++++++++--------------- mock/centralized_server.go | 22 ++++++++++---------- mock/centralized_test.go | 21 +++++++++---------- mock/interface.go | 17 ++++++++-------- none/none_client.go | 30 ++++++++++++++-------------- offline/offline.go | 34 +++++++++++++++---------------- offline/offline_test.go | 12 ++++++----- 9 files changed, 133 insertions(+), 91 deletions(-) diff --git a/go.mod b/go.mod index 7fc753d..a462f9d 100644 --- a/go.mod +++ b/go.mod @@ -2,18 +2,15 @@ module github.com/ipfs/go-ipfs-routing require ( github.com/gogo/protobuf v1.2.1 - github.com/ipfs/go-cid v0.0.1 + github.com/ipfs/go-cid v0.0.2 github.com/ipfs/go-datastore v0.0.1 github.com/ipfs/go-ipfs-delay v0.0.1 github.com/ipfs/go-ipfs-ds-help v0.0.1 github.com/ipfs/go-ipfs-util v0.0.1 github.com/ipfs/go-log v0.0.1 - github.com/libp2p/go-libp2p-host v0.0.1 - github.com/libp2p/go-libp2p-peer v0.0.1 - github.com/libp2p/go-libp2p-peerstore v0.0.1 - github.com/libp2p/go-libp2p-record v0.0.1 - github.com/libp2p/go-libp2p-routing v0.0.1 - github.com/libp2p/go-testutil v0.0.1 - github.com/multiformats/go-multiaddr v0.0.1 - github.com/multiformats/go-multihash v0.0.1 + github.com/libp2p/go-libp2p-core v0.0.2 + github.com/libp2p/go-libp2p-record v0.1.0 + github.com/libp2p/go-libp2p-testing v0.0.3 + github.com/multiformats/go-multiaddr v0.0.4 + github.com/multiformats/go-multihash v0.0.5 ) diff --git a/go.sum b/go.sum index 363d1e5..8612b09 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,11 @@ github.com/Kubuxu/go-os-helper v0.0.1/go.mod h1:N8B+I7vPCT80IcP58r50u4+gEEcsZETF github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/btcsuite/btcd v0.0.0-20190213025234-306aecffea32 h1:qkOC5Gd33k54tobS36cXdAzJbeHaduLtnLQQwNoIi78= github.com/btcsuite/btcd v0.0.0-20190213025234-306aecffea32/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= +github.com/btcsuite/btcd v0.0.0-20190523000118-16327141da8c h1:aEbSeNALREWXk0G7UdNhR3ayBV7tZ4M2PNmnrCAph6Q= +github.com/btcsuite/btcd v0.0.0-20190523000118-16327141da8c/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190207003914-4c204d697803/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= @@ -12,6 +15,7 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/coreos/go-semver v0.2.0 h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -36,6 +40,8 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ipfs/go-cid v0.0.1 h1:GBjWPktLnNyX0JiQCNFpUuUSoMw5KMyqrsejHYlILBE= github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= +github.com/ipfs/go-cid v0.0.2 h1:tuuKaZPU1M6HcejsO3AcYWW8sZ8MTvyxfc4uqB4eFE8= +github.com/ipfs/go-cid v0.0.2/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= github.com/ipfs/go-datastore v0.0.1 h1:AW/KZCScnBWlSb5JbnEnLKFWXL224LBEh/9KXXOrUms= github.com/ipfs/go-datastore v0.0.1/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE= github.com/ipfs/go-ds-badger v0.0.2/go.mod h1:Y3QpeSFWQf6MopLTiZD+VT6IC1yZqaGmjvRcKeSGij8= @@ -49,8 +55,11 @@ github.com/ipfs/go-ipfs-util v0.0.1 h1:Wz9bL2wB2YBJqggkA4dD7oSmqB4cAnpNbGrlHJulv github.com/ipfs/go-ipfs-util v0.0.1/go.mod h1:spsl5z8KUnrve+73pOhSVZND1SIxPW5RyBCNzQxlJBc= github.com/ipfs/go-log v0.0.1 h1:9XTUN/rW64BCG1YhPK9Hoy3q8nr4gOmHHBpgFdfw6Lc= github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM= +github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8 h1:bspPhN+oKYFk5fcGNuQzp6IGzYQSenLEgH3s6jkXrWw= github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8/go.mod h1:Ly/wlsjFq/qrU3Rar62tu1gASgGw6chQbSh/XgIIXCY= +github.com/jbenet/goprocess v0.1.3 h1:YKyIEECS/XvcfHtBzxtjBBbWK+MbvA6dG8ASiqwvr10= +github.com/jbenet/goprocess v0.1.3/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= @@ -62,6 +71,10 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/libp2p/go-buffer-pool v0.0.1/go.mod h1:xtyIz9PMobb13WaxR6Zo1Pd1zXJKYg0a8KiIvDp3TzQ= +github.com/libp2p/go-flow-metrics v0.0.1/go.mod h1:Iv1GH0sG8DtYN3SVJ2eG221wMiNpZxBdp967ls1g+k8= +github.com/libp2p/go-libp2p-core v0.0.1/go.mod h1:g/VxnTZ/1ygHxH3dKok7Vno1VfpvGcGip57wjTU4fco= +github.com/libp2p/go-libp2p-core v0.0.2 h1:86uOwW+O6Uc7NbaK4diuLZo2/Ikvqw2rgyV03VcSbLE= +github.com/libp2p/go-libp2p-core v0.0.2/go.mod h1:9dAcntw/n46XycV4RnlBq3BpgrmyUi9LuoTNdPrbUco= github.com/libp2p/go-libp2p-crypto v0.0.1 h1:JNQd8CmoGTohO/akqrH16ewsqZpci2CbgYH/LmYl8gw= github.com/libp2p/go-libp2p-crypto v0.0.1/go.mod h1:yJkNyDmO341d5wwXxDUGO0LykUVT72ImHNUqh5D/dBE= github.com/libp2p/go-libp2p-host v0.0.1 h1:dnqusU+DheGcdxrE718kG4XgHNuL2n9eEv8Rg5zy8hQ= @@ -78,8 +91,12 @@ github.com/libp2p/go-libp2p-protocol v0.0.1 h1:+zkEmZ2yFDi5adpVE3t9dqh/N9TbpFWyw github.com/libp2p/go-libp2p-protocol v0.0.1/go.mod h1:Af9n4PiruirSDjHycM1QuiMi/1VZNHYcK8cLgFJLZ4s= github.com/libp2p/go-libp2p-record v0.0.1 h1:zN7AS3X46qmwsw5JLxdDuI43cH5UYwovKxHPjKBYQxw= github.com/libp2p/go-libp2p-record v0.0.1/go.mod h1:grzqg263Rug/sRex85QrDOLntdFAymLDLm7lxMgU79Q= +github.com/libp2p/go-libp2p-record v0.1.0 h1:wHwBGbFzymoIl69BpgwIu0O6ta3TXGcMPvHUAcodzRc= +github.com/libp2p/go-libp2p-record v0.1.0/go.mod h1:ujNc8iuE5dlKWVy6wuL6dd58t0n7xI4hAIl8pE6wu5Q= github.com/libp2p/go-libp2p-routing v0.0.1 h1:hPMAWktf9rYi3ME4MG48qE7dq1ofJxiQbfdvpNntjhc= github.com/libp2p/go-libp2p-routing v0.0.1/go.mod h1:N51q3yTr4Zdr7V8Jt2JIktVU+3xBBylx1MZeVA6t1Ys= +github.com/libp2p/go-libp2p-testing v0.0.3 h1:bdij4bKaaND7tCsaXVjRfYkMpvoOeKj9AVQGJllA6jM= +github.com/libp2p/go-libp2p-testing v0.0.3/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= github.com/libp2p/go-stream-muxer v0.0.1 h1:Ce6e2Pyu+b5MC1k3eeFtAax0pW4gc6MosYSLV05UeLw= github.com/libp2p/go-stream-muxer v0.0.1/go.mod h1:bAo8x7YkSpadMTbtTaxGVHWUQsR/l5MEaHbKaliuT14= github.com/libp2p/go-testutil v0.0.1 h1:Xg+O0G2HIMfHqBOBDcMS1iSZJ3GEcId4qOxCQvsGZHk= @@ -92,18 +109,28 @@ github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0 github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16 h1:5W7KhL8HVF3XCFOweFD3BNESdnO8ewyYTFT2R+/b8FQ= github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= +github.com/minio/sha256-simd v0.0.0-20190328051042-05b4dd3047e5 h1:l16XLUUJ34wIz+RIvLhSwGvLvKyy+W598b135bJN6mg= +github.com/minio/sha256-simd v0.0.0-20190328051042-05b4dd3047e5/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= github.com/mr-tron/base58 v1.1.0 h1:Y51FGVJ91WBqCEabAi5OPUz38eAx8DakuAm5svLcsfQ= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= +github.com/mr-tron/base58 v1.1.1/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= +github.com/mr-tron/base58 v1.1.2 h1:ZEw4I2EgPKDJ2iEw0cNmLB3ROrEmkOtXIkaG7wZg+78= +github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI= github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA= github.com/multiformats/go-multiaddr v0.0.1 h1:/QUV3VBMDI6pi6xfiw7lr6xhDWWvQKn9udPn68kLSdY= github.com/multiformats/go-multiaddr v0.0.1/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= +github.com/multiformats/go-multiaddr v0.0.2/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= +github.com/multiformats/go-multiaddr v0.0.4 h1:WgMSI84/eRLdbptXMkMWDXPjPq7SPLIgGUVm2eroyU4= +github.com/multiformats/go-multiaddr v0.0.4/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= github.com/multiformats/go-multiaddr-dns v0.0.1/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= github.com/multiformats/go-multiaddr-net v0.0.1/go.mod h1:nw6HSxNmCIQH27XPGBuX+d1tnvM7ihcFwHMSstNAVUU= github.com/multiformats/go-multibase v0.0.1 h1:PN9/v21eLywrFWdFNsFKaU04kLJzuYzmrJR+ubhT9qA= github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/gviWFaSteVbWT51qgs= github.com/multiformats/go-multihash v0.0.1 h1:HHwN1K12I+XllBCrqKnhX949Orn4oawPkegHMu2vDqQ= github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U= +github.com/multiformats/go-multihash v0.0.5 h1:1wxmCvTXAifAepIMyF39vZinRw5sbqjPs/UIi93+uik= +github.com/multiformats/go-multihash v0.0.5/go.mod h1:lt/HCbqlQwlPBz7lv0sQCdtfcMtlJvakRUn/0Ual8po= github.com/multiformats/go-multistream v0.0.1 h1:JV4VfSdY9n7ECTtY59/TlSyFCzRILvYx4T4Ws8ZgihU= github.com/multiformats/go-multistream v0.0.1/go.mod h1:fJTiDfXJVmItycydCnNx4+wSzZ5NwG2FEVAI30fiovg= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -114,6 +141,10 @@ github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFSt github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/spacemonkeygo/openssl v0.0.0-20181017203307-c2dcc5cca94a/go.mod h1:7AyxJNCJ7SBZ1MfVQCWD6Uqo2oubI2Eq2y2eqf+A5r0= +github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc= +github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= +github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -123,17 +154,27 @@ github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc h1:9lDbC6 github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc/go.mod h1:bopw91TMyo8J3tvftk8xmU2kPmlrt4nScJQZU2hE5EM= github.com/whyrusleeping/mafmt v1.2.8/go.mod h1:faQJFPbLSxzD9xpA02ttW/tS9vZykNvXwGvqIpk20FA= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67 h1:ng3VDlRp5/DHpSWl02R4rM9I+8M2rhmsuLwAMmkLQWE= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190225124518-7f87c0fbb88b h1:+/WWzjwW6gidDJnMKWLKLX1gxn7irUTF1fLpQovfQ5M= golang.org/x/crypto v0.0.0-20190225124518-7f87c0fbb88b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f h1:R423Cnkcp5JABoeemiGEPlt9tHXFfw5kvc0yqlxRPWo= +golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190227160552-c95aed5357e7 h1:C2F/nMkR/9sfUTpvR3QrjBuTdvMUC/cFajkphs1YLQo= golang.org/x/net v0.0.0-20190227160552-c95aed5357e7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= diff --git a/mock/centralized_client.go b/mock/centralized_client.go index e09350d..e57d032 100644 --- a/mock/centralized_client.go +++ b/mock/centralized_client.go @@ -6,11 +6,11 @@ import ( cid "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log" - peer "github.com/libp2p/go-libp2p-peer" - pstore "github.com/libp2p/go-libp2p-peerstore" - routing "github.com/libp2p/go-libp2p-routing" - ropts "github.com/libp2p/go-libp2p-routing/options" - "github.com/libp2p/go-testutil" + + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/routing" + "github.com/libp2p/go-libp2p-testing/net" + ma "github.com/multiformats/go-multiaddr" ) @@ -19,37 +19,37 @@ var log = logging.Logger("mockrouter") type client struct { vs routing.ValueStore server server - peer testutil.Identity + peer tnet.Identity } // FIXME(brian): is this method meant to simulate putting a value into the network? -func (c *client) PutValue(ctx context.Context, key string, val []byte, opts ...ropts.Option) error { +func (c *client) PutValue(ctx context.Context, key string, val []byte, opts ...routing.Option) error { log.Debugf("PutValue: %s", key) return c.vs.PutValue(ctx, key, val, opts...) } // FIXME(brian): is this method meant to simulate getting a value from the network? -func (c *client) GetValue(ctx context.Context, key string, opts ...ropts.Option) ([]byte, error) { +func (c *client) GetValue(ctx context.Context, key string, opts ...routing.Option) ([]byte, error) { log.Debugf("GetValue: %s", key) return c.vs.GetValue(ctx, key, opts...) } -func (c *client) SearchValue(ctx context.Context, key string, opts ...ropts.Option) (<-chan []byte, error) { +func (c *client) SearchValue(ctx context.Context, key string, opts ...routing.Option) (<-chan []byte, error) { log.Debugf("SearchValue: %s", key) return c.vs.SearchValue(ctx, key, opts...) } -func (c *client) FindProviders(ctx context.Context, key cid.Cid) ([]pstore.PeerInfo, error) { +func (c *client) FindProviders(ctx context.Context, key cid.Cid) ([]peer.AddrInfo, error) { return c.server.Providers(key), nil } -func (c *client) FindPeer(ctx context.Context, pid peer.ID) (pstore.PeerInfo, error) { +func (c *client) FindPeer(ctx context.Context, pid peer.ID) (peer.AddrInfo, error) { log.Debugf("FindPeer: %s", pid) - return pstore.PeerInfo{}, nil + return peer.AddrInfo{}, nil } -func (c *client) FindProvidersAsync(ctx context.Context, k cid.Cid, max int) <-chan pstore.PeerInfo { - out := make(chan pstore.PeerInfo) +func (c *client) FindProvidersAsync(ctx context.Context, k cid.Cid, max int) <-chan peer.AddrInfo { + out := make(chan peer.AddrInfo) go func() { defer close(out) for i, p := range c.server.Providers(k) { @@ -72,7 +72,7 @@ func (c *client) Provide(_ context.Context, key cid.Cid, brd bool) error { if !brd { return nil } - info := pstore.PeerInfo{ + info := peer.AddrInfo{ ID: c.peer.ID(), Addrs: []ma.Multiaddr{c.peer.Address()}, } @@ -87,4 +87,4 @@ func (c *client) Bootstrap(context.Context) error { return nil } -var _ routing.IpfsRouting = &client{} +var _ routing.Routing = &client{} diff --git a/mock/centralized_server.go b/mock/centralized_server.go index a223f91..9c8bd85 100644 --- a/mock/centralized_server.go +++ b/mock/centralized_server.go @@ -9,17 +9,17 @@ import ( cid "github.com/ipfs/go-cid" ds "github.com/ipfs/go-datastore" dssync "github.com/ipfs/go-datastore/sync" - peer "github.com/libp2p/go-libp2p-peer" - pstore "github.com/libp2p/go-libp2p-peerstore" - "github.com/libp2p/go-testutil" + + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-testing/net" offline "github.com/ipfs/go-ipfs-routing/offline" ) // server is the mockrouting.Client's private interface to the routing server type server interface { - Announce(pstore.PeerInfo, cid.Cid) error - Providers(cid.Cid) []pstore.PeerInfo + Announce(peer.AddrInfo, cid.Cid) error + Providers(cid.Cid) []peer.AddrInfo Server } @@ -33,11 +33,11 @@ type s struct { } type providerRecord struct { - Peer pstore.PeerInfo + Peer peer.AddrInfo Created time.Time } -func (rs *s) Announce(p pstore.PeerInfo, c cid.Cid) error { +func (rs *s) Announce(p peer.AddrInfo, c cid.Cid) error { rs.lock.Lock() defer rs.lock.Unlock() @@ -54,14 +54,14 @@ func (rs *s) Announce(p pstore.PeerInfo, c cid.Cid) error { return nil } -func (rs *s) Providers(c cid.Cid) []pstore.PeerInfo { +func (rs *s) Providers(c cid.Cid) []peer.AddrInfo { rs.delayConf.Query.Wait() // before locking rs.lock.RLock() defer rs.lock.RUnlock() k := c.KeyString() - var ret []pstore.PeerInfo + var ret []peer.AddrInfo records, ok := rs.providers[k] if !ok { return ret @@ -80,11 +80,11 @@ func (rs *s) Providers(c cid.Cid) []pstore.PeerInfo { return ret } -func (rs *s) Client(p testutil.Identity) Client { +func (rs *s) Client(p tnet.Identity) Client { return rs.ClientWithDatastore(context.Background(), p, dssync.MutexWrap(ds.NewMapDatastore())) } -func (rs *s) ClientWithDatastore(_ context.Context, p testutil.Identity, datastore ds.Datastore) Client { +func (rs *s) ClientWithDatastore(_ context.Context, p tnet.Identity, datastore ds.Datastore) Client { return &client{ peer: p, vs: offline.NewOfflineRouter(datastore, MockValidator{}), diff --git a/mock/centralized_test.go b/mock/centralized_test.go index 704557a..2767ff1 100644 --- a/mock/centralized_test.go +++ b/mock/centralized_test.go @@ -8,13 +8,14 @@ import ( cid "github.com/ipfs/go-cid" delay "github.com/ipfs/go-ipfs-delay" u "github.com/ipfs/go-ipfs-util" - pstore "github.com/libp2p/go-libp2p-peerstore" - testutil "github.com/libp2p/go-testutil" + + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-testing/net" ) func TestKeyNotFound(t *testing.T) { - var pi = testutil.RandIdentityOrFatal(t) + var pi = tnet.RandIdentityOrFatal(t) var key = cid.NewCidV0(u.Hash([]byte("mock key"))) var ctx = context.Background() @@ -27,7 +28,7 @@ func TestKeyNotFound(t *testing.T) { } func TestClientFindProviders(t *testing.T) { - pi := testutil.RandIdentityOrFatal(t) + pi := tnet.RandIdentityOrFatal(t) rs := NewServer() client := rs.Client(pi) @@ -58,7 +59,7 @@ func TestClientOverMax(t *testing.T) { k := cid.NewCidV0(u.Hash([]byte("hello"))) numProvidersForHelloKey := 100 for i := 0; i < numProvidersForHelloKey; i++ { - pi := testutil.RandIdentityOrFatal(t) + pi := tnet.RandIdentityOrFatal(t) err := rs.Client(pi).Provide(context.Background(), k, true) if err != nil { t.Fatal(err) @@ -66,7 +67,7 @@ func TestClientOverMax(t *testing.T) { } max := 10 - pi := testutil.RandIdentityOrFatal(t) + pi := tnet.RandIdentityOrFatal(t) client := rs.Client(pi) providersFromClient := client.FindProvidersAsync(context.Background(), k, max) @@ -101,7 +102,7 @@ func TestCanceledContext(t *testing.T) { default: } - pi, err := testutil.RandIdentity() + pi, err := tnet.RandIdentity() if err != nil { t.Error(err) } @@ -113,7 +114,7 @@ func TestCanceledContext(t *testing.T) { } }() - local := testutil.RandIdentityOrFatal(t) + local := tnet.RandIdentityOrFatal(t) client := rs.Client(local) t.Log("warning: max is finite so this test is non-deterministic") @@ -141,7 +142,7 @@ func TestValidAfter(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - pi := testutil.RandIdentityOrFatal(t) + pi := tnet.RandIdentityOrFatal(t) key := cid.NewCidV0(u.Hash([]byte("mock key"))) conf := DelayConfig{ ValueVisibility: delay.Fixed(1 * time.Hour), @@ -152,7 +153,7 @@ func TestValidAfter(t *testing.T) { rs.Client(pi).Provide(ctx, key, true) - var providers []pstore.PeerInfo + var providers []peer.AddrInfo max := 100 providersChan := rs.Client(pi).FindProvidersAsync(ctx, key, max) for p := range providersChan { diff --git a/mock/interface.go b/mock/interface.go index 5d4e9f9..6b02065 100644 --- a/mock/interface.go +++ b/mock/interface.go @@ -1,6 +1,6 @@ // Package mockrouting provides a virtual routing server. To use it, // create a virtual routing server and use the Client() method to get a -// routing client (IpfsRouting). The server quacks like a DHT but is +// routing client (Routing). The server quacks like a DHT but is // really a local in-memory hash table. package mockrouting @@ -9,9 +9,10 @@ import ( ds "github.com/ipfs/go-datastore" delay "github.com/ipfs/go-ipfs-delay" - peer "github.com/libp2p/go-libp2p-peer" - routing "github.com/libp2p/go-libp2p-routing" - "github.com/libp2p/go-testutil" + + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/routing" + "github.com/libp2p/go-libp2p-testing/net" ) // MockValidator is a record validator that always returns success. @@ -22,13 +23,13 @@ func (MockValidator) Select(_ string, _ [][]byte) (int, error) { return 0, nil } // Server provides mockrouting Clients type Server interface { - Client(p testutil.Identity) Client - ClientWithDatastore(context.Context, testutil.Identity, ds.Datastore) Client + Client(p tnet.Identity) Client + ClientWithDatastore(context.Context, tnet.Identity, ds.Datastore) Client } -// Client implements IpfsRouting +// Client implements Routing type Client interface { - routing.IpfsRouting + routing.Routing } // NewServer returns a mockrouting Server diff --git a/none/none_client.go b/none/none_client.go index 45febc5..9604ab0 100644 --- a/none/none_client.go +++ b/none/none_client.go @@ -7,35 +7,35 @@ import ( cid "github.com/ipfs/go-cid" ds "github.com/ipfs/go-datastore" - p2phost "github.com/libp2p/go-libp2p-host" - peer "github.com/libp2p/go-libp2p-peer" - pstore "github.com/libp2p/go-libp2p-peerstore" + + "github.com/libp2p/go-libp2p-core/host" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/routing" + record "github.com/libp2p/go-libp2p-record" - routing "github.com/libp2p/go-libp2p-routing" - ropts "github.com/libp2p/go-libp2p-routing/options" ) type nilclient struct { } -func (c *nilclient) PutValue(_ context.Context, _ string, _ []byte, _ ...ropts.Option) error { +func (c *nilclient) PutValue(_ context.Context, _ string, _ []byte, _ ...routing.Option) error { return nil } -func (c *nilclient) GetValue(_ context.Context, _ string, _ ...ropts.Option) ([]byte, error) { +func (c *nilclient) GetValue(_ context.Context, _ string, _ ...routing.Option) ([]byte, error) { return nil, errors.New("tried GetValue from nil routing") } -func (c *nilclient) SearchValue(_ context.Context, _ string, _ ...ropts.Option) (<-chan []byte, error) { +func (c *nilclient) SearchValue(_ context.Context, _ string, _ ...routing.Option) (<-chan []byte, error) { return nil, errors.New("tried SearchValue from nil routing") } -func (c *nilclient) FindPeer(_ context.Context, _ peer.ID) (pstore.PeerInfo, error) { - return pstore.PeerInfo{}, nil +func (c *nilclient) FindPeer(_ context.Context, _ peer.ID) (peer.AddrInfo, error) { + return peer.AddrInfo{}, nil } -func (c *nilclient) FindProvidersAsync(_ context.Context, _ cid.Cid, _ int) <-chan pstore.PeerInfo { - out := make(chan pstore.PeerInfo) +func (c *nilclient) FindProvidersAsync(_ context.Context, _ cid.Cid, _ int) <-chan peer.AddrInfo { + out := make(chan peer.AddrInfo) defer close(out) return out } @@ -48,10 +48,10 @@ func (c *nilclient) Bootstrap(_ context.Context) error { return nil } -// ConstructNilRouting creates an IpfsRouting client which does nothing. -func ConstructNilRouting(_ context.Context, _ p2phost.Host, _ ds.Batching, _ record.Validator) (routing.IpfsRouting, error) { +// ConstructNilRouting creates an Routing client which does nothing. +func ConstructNilRouting(_ context.Context, _ host.Host, _ ds.Batching, _ record.Validator) (routing.Routing, error) { return &nilclient{}, nil } // ensure nilclient satisfies interface -var _ routing.IpfsRouting = &nilclient{} +var _ routing.Routing = &nilclient{} diff --git a/offline/offline.go b/offline/offline.go index 1627490..c76f920 100644 --- a/offline/offline.go +++ b/offline/offline.go @@ -1,4 +1,4 @@ -// Package offline implements IpfsRouting with a client which +// Package offline implements Routing with a client which // is only able to perform offline operations. package offline @@ -12,29 +12,29 @@ import ( cid "github.com/ipfs/go-cid" ds "github.com/ipfs/go-datastore" dshelp "github.com/ipfs/go-ipfs-ds-help" - "github.com/libp2p/go-libp2p-peer" - pstore "github.com/libp2p/go-libp2p-peerstore" + + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/routing" + record "github.com/libp2p/go-libp2p-record" pb "github.com/libp2p/go-libp2p-record/pb" - routing "github.com/libp2p/go-libp2p-routing" - ropts "github.com/libp2p/go-libp2p-routing/options" ) // ErrOffline is returned when trying to perform operations that // require connectivity. var ErrOffline = errors.New("routing system in offline mode") -// NewOfflineRouter returns an IpfsRouting implementation which only performs +// NewOfflineRouter returns an Routing implementation which only performs // offline operations. It allows to Put and Get signed dht // records to and from the local datastore. -func NewOfflineRouter(dstore ds.Datastore, validator record.Validator) routing.IpfsRouting { +func NewOfflineRouter(dstore ds.Datastore, validator record.Validator) routing.Routing { return &offlineRouting{ datastore: dstore, validator: validator, } } -// offlineRouting implements the IpfsRouting interface, +// offlineRouting implements the Routing interface, // but only provides the capability to Put and Get signed dht // records to and from the local datastore. type offlineRouting struct { @@ -42,7 +42,7 @@ type offlineRouting struct { validator record.Validator } -func (c *offlineRouting) PutValue(ctx context.Context, key string, val []byte, _ ...ropts.Option) error { +func (c *offlineRouting) PutValue(ctx context.Context, key string, val []byte, _ ...routing.Option) error { if err := c.validator.Validate(key, val); err != nil { return err } @@ -70,7 +70,7 @@ func (c *offlineRouting) PutValue(ctx context.Context, key string, val []byte, _ return c.datastore.Put(dshelp.NewKeyFromBinary([]byte(key)), data) } -func (c *offlineRouting) GetValue(ctx context.Context, key string, _ ...ropts.Option) ([]byte, error) { +func (c *offlineRouting) GetValue(ctx context.Context, key string, _ ...routing.Option) ([]byte, error) { buf, err := c.datastore.Get(dshelp.NewKeyFromBinary([]byte(key))) if err != nil { return nil, err @@ -90,7 +90,7 @@ func (c *offlineRouting) GetValue(ctx context.Context, key string, _ ...ropts.Op return val, nil } -func (c *offlineRouting) SearchValue(ctx context.Context, key string, _ ...ropts.Option) (<-chan []byte, error) { +func (c *offlineRouting) SearchValue(ctx context.Context, key string, _ ...routing.Option) (<-chan []byte, error) { out := make(chan []byte, 1) go func() { defer close(out) @@ -102,12 +102,12 @@ func (c *offlineRouting) SearchValue(ctx context.Context, key string, _ ...ropts return out, nil } -func (c *offlineRouting) FindPeer(ctx context.Context, pid peer.ID) (pstore.PeerInfo, error) { - return pstore.PeerInfo{}, ErrOffline +func (c *offlineRouting) FindPeer(ctx context.Context, pid peer.ID) (peer.AddrInfo, error) { + return peer.AddrInfo{}, ErrOffline } -func (c *offlineRouting) FindProvidersAsync(ctx context.Context, k cid.Cid, max int) <-chan pstore.PeerInfo { - out := make(chan pstore.PeerInfo) +func (c *offlineRouting) FindProvidersAsync(ctx context.Context, k cid.Cid, max int) <-chan peer.AddrInfo { + out := make(chan peer.AddrInfo) close(out) return out } @@ -124,5 +124,5 @@ func (c *offlineRouting) Bootstrap(context.Context) error { return nil } -// ensure offlineRouting matches the IpfsRouting interface -var _ routing.IpfsRouting = &offlineRouting{} +// ensure offlineRouting matches the Routing interface +var _ routing.Routing = &offlineRouting{} diff --git a/offline/offline_test.go b/offline/offline_test.go index 9703bac..00e0174 100644 --- a/offline/offline_test.go +++ b/offline/offline_test.go @@ -7,8 +7,10 @@ import ( cid "github.com/ipfs/go-cid" ds "github.com/ipfs/go-datastore" - ropt "github.com/libp2p/go-libp2p-routing/options" - testutil "github.com/libp2p/go-testutil" + + "github.com/libp2p/go-libp2p-core/routing" + "github.com/libp2p/go-libp2p-core/test" + mh "github.com/multiformats/go-multihash" ) @@ -40,12 +42,12 @@ func TestOfflineRouterStorage(t *testing.T) { t.Fatal("Router should throw errors for unfound records") } - local, err := offline.GetValue(ctx, "key", ropt.Offline) + local, err := offline.GetValue(ctx, "key", routing.Offline) if err != nil { t.Fatal(err) } - _, err = offline.GetValue(ctx, "notHere", ropt.Offline) + _, err = offline.GetValue(ctx, "notHere", routing.Offline) if err == nil { t.Fatal("Router should throw errors for unfound records") } @@ -61,7 +63,7 @@ func TestOfflineRouterLocal(t *testing.T) { nds := ds.NewMapDatastore() offline := NewOfflineRouter(nds, blankValidator{}) - id, _ := testutil.RandPeerID() + id, _ := test.RandPeerID() _, err := offline.FindPeer(ctx, id) if err != ErrOffline { t.Fatal("OfflineRouting should alert that its offline")