diff --git a/go.mod b/go.mod index a6c85dd..9990635 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.13 require ( filippo.io/edwards25519 v1.0.0-beta.2 github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da - github.com/pkg/errors v0.9.1 gitlab.com/NebulousLabs/Sia v1.5.4 gitlab.com/NebulousLabs/encoding v0.0.0-20200604091946-456c3dc907fe gitlab.com/NebulousLabs/log v0.0.0-20200604091839-0ba4a941cdc2 diff --git a/go.sum b/go.sum index 3e9128d..09f5c46 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -filippo.io/edwards25519 v1.0.0-alpha.2 h1:EWbZLqGEPSIj2W69gx04KtNVkyPIfe3uj0DhDQJonbQ= -filippo.io/edwards25519 v1.0.0-alpha.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o= filippo.io/edwards25519 v1.0.0-beta.2 h1:/BZRNzm8N4K4eWfK28dL4yescorxtO7YG1yun8fy+pI= filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA= @@ -17,14 +14,11 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/coreos/bbolt v1.3.2 h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/threefish v0.0.0-20120919164726-3ecf4c494abf h1:K5VXW9LjmJv/xhjvQcNWTdk4WOSyreil6YaubuCPeRY= @@ -61,22 +55,15 @@ github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf h1:WfD7V github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA= github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= -github.com/karrick/godirwalk v1.10.12 h1:BqUm+LuJcXjGv1d2mj3gBiQyrQ57a0rYoAmhvJQ7RDU= -github.com/karrick/godirwalk v1.10.12/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w= -github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.2 h1:1xAgYebNnsb9LKCdLOvFWtAxGU/33mjJtyOVbmUa0Us= github.com/klauspost/cpuid v1.2.2/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/klauspost/reedsolomon v1.9.2 h1:E9CMS2Pqbv+C7tsrYad4YC9MfhnMVWhMRsTi7U0UB18= -github.com/klauspost/reedsolomon v1.9.2/go.mod h1:CwCi+NUr9pqSVktrkN+Ondf06rkhYZ/pcNv7fu+8Un4= github.com/klauspost/reedsolomon v1.9.3 h1:N/VzgeMfHmLc+KHMD1UL/tNkfXAt8FnUqlgXGIduwAY= github.com/klauspost/reedsolomon v1.9.3/go.mod h1:CwCi+NUr9pqSVktrkN+Ondf06rkhYZ/pcNv7fu+8Un4= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -94,8 +81,6 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -109,7 +94,6 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -117,33 +101,21 @@ github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4k github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.4/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/vbauerster/mpb/v5 v5.0.3/go.mod h1:h3YxU5CSr8rZP4Q3xZPVB3jJLhWPou63lHEdr9ytH4Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xtaci/smux v1.3.3 h1:+vnzZHTLGHrj+LzUZEkKmvu4KkG7fj4jwMPqhawvErg= github.com/xtaci/smux v1.3.3/go.mod h1:f+nYm6SpuHMy/SH0zpbvAFHT1QoMcgLOsWcFip5KfPw= -gitlab.com/NebulousLabs/Sia v1.4.1 h1:Vzx9NFtyG0qF+2oRZLj6uKGakkqlcBGaHstki7UcvBE= -gitlab.com/NebulousLabs/Sia v1.4.1/go.mod h1:pmBBguXJl2nxajST2OtRv0FOIMSggtn5evGpE9Pju3Y= -gitlab.com/NebulousLabs/Sia v1.4.8 h1:NBBawRM0JvyD1Z1jB5er+4byrQ9B8jpqE7kfNbOHw2c= -gitlab.com/NebulousLabs/Sia v1.4.8/go.mod h1:AlAQ634YMvZ040N8ffji8u0oZdFLzlzs0ogUzIZ7Thg= -gitlab.com/NebulousLabs/Sia v1.5.0 h1:rmxUeEu07ODFdmwdcZJFA83Fv4EQs/CYjmn6RVw7OWk= -gitlab.com/NebulousLabs/Sia v1.5.0/go.mod h1:dcWW1yClYDu/v10Q/ujNX290kg9WrnU2/sZere4IRP4= gitlab.com/NebulousLabs/Sia v1.5.4 h1:7+j8Z5BZLPn/LGF0dCODwr1Nq+AYD5cOjopK2PhYTew= gitlab.com/NebulousLabs/Sia v1.5.4/go.mod h1:NN77/QIB1opjhFQ9ZxPKg4HqRPUQLiu6YXBHRIyRR1g= -gitlab.com/NebulousLabs/bolt v1.4.0 h1:6sfFp1YQtGWbSLLYoH8+0h3EtFRGbsp07L3uZNChdE0= -gitlab.com/NebulousLabs/bolt v1.4.0/go.mod h1:72gB2R0hTcUU2Ih7mBpHF0jJlIldSyPzG1cuwz1uYJY= gitlab.com/NebulousLabs/bolt v1.4.4 h1:3UhpR2qtHs87dJBE3CIzhw48GYSoUUNByJmic0cbu1w= gitlab.com/NebulousLabs/bolt v1.4.4/go.mod h1:ZL02cwhpLNif6aruxvUMqu/Bdy0/lFY21jMFfNAA+O8= gitlab.com/NebulousLabs/demotemutex v0.0.0-20151003192217-235395f71c40 h1:IbucNi8u1a1ErgVFVgg8pERhSyzYe5l+o8krDMnNjWA= @@ -152,7 +124,6 @@ gitlab.com/NebulousLabs/encoding v0.0.0-20200604091946-456c3dc907fe h1:vylvMCgxV gitlab.com/NebulousLabs/encoding v0.0.0-20200604091946-456c3dc907fe/go.mod h1:Gi3CPCauIWmGp7YrnV/mKZ8qkD/N/LrunGNc8QmsVkU= gitlab.com/NebulousLabs/entropy-mnemonics v0.0.0-20181018051301-7532f67e3500 h1:BUDZfLl/9IRseYl7/GW1DF+11SYCMJ6P4whCBJhtEhQ= gitlab.com/NebulousLabs/entropy-mnemonics v0.0.0-20181018051301-7532f67e3500/go.mod h1:4koft3fRXTETovKPTeX/Aggj+ajCGWCcuuBBc598Pcs= -gitlab.com/NebulousLabs/errors v0.0.0-20171229012116-7ead97ef90b8 h1:gZfMjx7Jr6N8b7iJO4eUjDsn6xJqoyXg8D+ogdoAfKY= gitlab.com/NebulousLabs/errors v0.0.0-20171229012116-7ead97ef90b8/go.mod h1:ZkMZ0dpQyWwlENaeZVBiQRjhMEZvk6VTXquzl3FOFP8= gitlab.com/NebulousLabs/errors v0.0.0-20200929122200-06c536cf6975 h1:L/ENs/Ar1bFzUeKx6m3XjlmBgIUlykX9dzvp5k9NGxc= gitlab.com/NebulousLabs/errors v0.0.0-20200929122200-06c536cf6975/go.mod h1:ZkMZ0dpQyWwlENaeZVBiQRjhMEZvk6VTXquzl3FOFP8= @@ -163,37 +134,20 @@ gitlab.com/NebulousLabs/go-upnp v0.0.0-20181011194642-3a71999ed0d3/go.mod h1:sle gitlab.com/NebulousLabs/log v0.0.0-20200529173103-40b250c2d92c/go.mod h1:qOhJbQ7Vzw+F+RCVmpPZ7WAwBIM9PZv4tWKp6Kgd9CY= gitlab.com/NebulousLabs/log v0.0.0-20200604091839-0ba4a941cdc2 h1:b6KJfBiIrGGSxcHVmLLyjJbwAmlIiA9M1qsMTsr8d1s= gitlab.com/NebulousLabs/log v0.0.0-20200604091839-0ba4a941cdc2/go.mod h1:qOhJbQ7Vzw+F+RCVmpPZ7WAwBIM9PZv4tWKp6Kgd9CY= -gitlab.com/NebulousLabs/merkletree v0.0.0-20190207030457-bc4a11e31a0d h1:ObC0V0W72CGqAliMv63xNEzKI6V0FnKcNHfi4+X5jiY= -gitlab.com/NebulousLabs/merkletree v0.0.0-20190207030457-bc4a11e31a0d/go.mod h1:xItahGeKIkh9BQfxDEX6O3eWxOxbLBPX738sXm0uVaQ= gitlab.com/NebulousLabs/merkletree v0.0.0-20200118113624-07fbf710afc4 h1:iuNdBfBg0umjOvrEf9MxGzK+NwAyE2oCZjDqUx9zVFs= gitlab.com/NebulousLabs/merkletree v0.0.0-20200118113624-07fbf710afc4/go.mod h1:0cjDwhA+Pv9ZQXHED7HUSS3sCvo2zgsoaMgE7MeGBWo= gitlab.com/NebulousLabs/monitor v0.0.0-20191205095550-2b0fd3e1012a h1:fs891phmYZrVdaCVPXfHGDMpV5LWPKvnOMjx70EpJkw= gitlab.com/NebulousLabs/monitor v0.0.0-20191205095550-2b0fd3e1012a/go.mod h1:QxXtb5hIp2xQkfb+lzBDIqQIGEj22U7AkYCXO3hkhqc= gitlab.com/NebulousLabs/persist v0.0.0-20200605115618-007e5e23d877 h1:BGJ+na/hpeAV6WR8Pys9bJM2ynEwKmT6+qgF8pn01fM= gitlab.com/NebulousLabs/persist v0.0.0-20200605115618-007e5e23d877/go.mod h1:KT2SgNX75xjMIQdDi3Rf3tcDWsX/D289R65Ss/7lKBg= -gitlab.com/NebulousLabs/ratelimit v0.0.0-20180716154200-1308156c2eaf h1:B0oWvYNYeov4s6nzoVPN4qxdAanrlR9mx552axpnXmg= -gitlab.com/NebulousLabs/ratelimit v0.0.0-20180716154200-1308156c2eaf/go.mod h1:vowDA1cdvtWW678ugB7L/yKT2pCN37aH6zYp9NF5Isc= -gitlab.com/NebulousLabs/ratelimit v0.0.0-20191111145210-66b93e150b27 h1:G8v2awvHcrvulXibvNpzLx3RlTuX0hB+0AZdl18pl50= -gitlab.com/NebulousLabs/ratelimit v0.0.0-20191111145210-66b93e150b27/go.mod h1:hvNy5sMP9gGrNQ7kNgb+vWuiPptqTk4W45bQbbT/vmg= -gitlab.com/NebulousLabs/ratelimit v0.0.0-20200703092634-24a64284c0ec h1:+FlF7OO7h81SPLkx9wpDAnnTbLiTL5izb9gldkbW/MQ= -gitlab.com/NebulousLabs/ratelimit v0.0.0-20200703092634-24a64284c0ec/go.mod h1:hvNy5sMP9gGrNQ7kNgb+vWuiPptqTk4W45bQbbT/vmg= gitlab.com/NebulousLabs/ratelimit v0.0.0-20200811080431-99b8f0768b2e h1:sMZdmPFduUilFk8Ed1Ya/DP0gVfUbGhLlNtLG2tONYk= gitlab.com/NebulousLabs/ratelimit v0.0.0-20200811080431-99b8f0768b2e/go.mod h1:HVrehlTxX2hYjsrL1k0WK43OZ0NGZfGvqzPL+n0/zrM= -gitlab.com/NebulousLabs/siamux v0.0.0-20200511155832-64a7ac68c8ab h1:NUCtCUgbRosZfCOJ3v27O5GmEnK8+fXAyx3J1SEfHrE= -gitlab.com/NebulousLabs/siamux v0.0.0-20200511155832-64a7ac68c8ab/go.mod h1:oaTSN0KXMgdNRKLg0CVH1vuZB2NcsmkngWf2pYK0N1Y= -gitlab.com/NebulousLabs/siamux v0.0.0-20200723083235-f2c35a421446 h1:Vs6RMOAK6EKL/i4CZysNKkev36/ziM18E8GKyKrIeIY= gitlab.com/NebulousLabs/siamux v0.0.0-20200723083235-f2c35a421446/go.mod h1:B0RyynPElUG2Y2CAVIIRriIqR9qht2I+nDisi3gfKn0= gitlab.com/NebulousLabs/siamux v0.0.0-20201105164950-869a9dc7edcf h1:LdIti1+B0guIKJXdOVu0nkK4vRsRiwdt+xyjUI+9c50= gitlab.com/NebulousLabs/siamux v0.0.0-20201105164950-869a9dc7edcf/go.mod h1:B0RyynPElUG2Y2CAVIIRriIqR9qht2I+nDisi3gfKn0= -gitlab.com/NebulousLabs/threadgroup v0.0.0-20180716154133-88a11db9e46c h1:psW9YBmnyKKCddPncr7mwJCx6n7FzlIs1EWIiSo7fyQ= -gitlab.com/NebulousLabs/threadgroup v0.0.0-20180716154133-88a11db9e46c/go.mod h1:w05nvlkvHlk3Vfc7mcU29Toic1X0BcYUnKoTHS0ea2Y= gitlab.com/NebulousLabs/threadgroup v0.0.0-20200527092543-afa01960408c/go.mod h1:av52iTyGuPtGU+GMcqfGtZu2vxhIjPgrxvIwVYelEvs= gitlab.com/NebulousLabs/threadgroup v0.0.0-20200608151952-38921fbef213 h1:owERlKtUEFTPQ897iiqWPOuWBdq7BYqPxDOCgEZnbN4= gitlab.com/NebulousLabs/threadgroup v0.0.0-20200608151952-38921fbef213/go.mod h1:vIutAvl7lmJqLVYTCBY5WDdJomP+V74At8LCeEYoH8w= -gitlab.com/NebulousLabs/writeaheadlog v0.0.0-20190703190009-cb822c37bc94 h1:JJFFedB70d+aO54OFq/m8iOp2MhpA3u8dPMjwJx5J40= -gitlab.com/NebulousLabs/writeaheadlog v0.0.0-20190703190009-cb822c37bc94/go.mod h1:Lhpa9AcbWcYKcc4amZsOHqJdQglnkWrGuUI68XC7U2Q= -gitlab.com/NebulousLabs/writeaheadlog v0.0.0-20190814160017-69f300e9bcb8 h1:u74TgFUPYl9G1rYLUKmavwJoF8Li/qJLMSiU5ntafKA= -gitlab.com/NebulousLabs/writeaheadlog v0.0.0-20190814160017-69f300e9bcb8/go.mod h1:Lhpa9AcbWcYKcc4amZsOHqJdQglnkWrGuUI68XC7U2Q= gitlab.com/NebulousLabs/writeaheadlog v0.0.0-20200618142844-c59a90f49130 h1:0hiQX3a4rmdu/duDhrRxl80zYHZoJDkSbTEFwSlAc74= gitlab.com/NebulousLabs/writeaheadlog v0.0.0-20200618142844-c59a90f49130/go.mod h1:SxigdS5Q1ui+OMgGAXt1E/Fg3RB6PvKXMov2O3gvIzs= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= @@ -203,17 +157,12 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/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-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191105034135-c7e5f84aec59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20191107222254-f4817d981bb6/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200109152110-61a87790db17/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200117160349-530e935923ad/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5 h1:Q7tZBpemrlsc2I7IyODzhtallWRSm4Q0d09pL6XbQtU= -golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 h1:DZhuSZLsGlFL4CmhA8BcRA0mnthyA/nZ00AqCUo7vHg= @@ -226,10 +175,8 @@ golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -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/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= @@ -242,21 +189,15 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb h1:fgwFCsaw9buMuxNd6+DQfAuSFqbNiQZpcgJQAgJsK6k= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f h1:gWF768j/LaZugp8dyS4UwsslYCYz9XgFxvlgsn0n9H8= -golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a h1:i47hUS795cOydZI4AwJQCKXOr4BvxzvikwDoDtHhP2Y= golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/hostdb/hostdb.go b/hostdb/hostdb.go index aabb208..b7bce04 100644 --- a/hostdb/hostdb.go +++ b/hostdb/hostdb.go @@ -6,11 +6,11 @@ import ( "crypto/ed25519" "encoding/hex" "encoding/json" + "fmt" "net" "strings" "time" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/modules" "gitlab.com/NebulousLabs/Sia/types" "lukechampine.com/us/renterhost" @@ -134,7 +134,7 @@ func Scan(ctx context.Context, addr modules.NetAddress, pubkey HostPublicKey) (h err := func() error { s, err := renterhost.NewRenterSession(conn, pubkey.Ed25519()) if err != nil { - return errors.Wrap(err, "could not initiate RPC session") + return fmt.Errorf("could not initiate RPC session: %w", err) } defer s.Close() var resp renterhost.RPCSettingsResponse @@ -147,7 +147,10 @@ func Scan(ctx context.Context, addr modules.NetAddress, pubkey HostPublicKey) (h } return nil }() - ch <- res{host, errors.Wrap(err, "could not read signed host settings")} + if err != nil { + err = fmt.Errorf("could not read signed host settings: %w", err) + } + ch <- res{host, err} }() select { case <-ctx.Done(): diff --git a/renter/download.go b/renter/download.go index 3fa864e..23583b4 100644 --- a/renter/download.go +++ b/renter/download.go @@ -2,9 +2,10 @@ package renter import ( "bytes" + "errors" + "fmt" "io" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/modules" "lukechampine.com/us/hostdb" "lukechampine.com/us/merkle" @@ -128,7 +129,7 @@ func (d *ShardDownloader) CopySection(w io.Writer, offset, length int64) error { // slice is only valid until the next call to DownloadAndDecrypt. func (d *ShardDownloader) DownloadAndDecrypt(chunkIndex int64) ([]byte, error) { if chunkIndex >= int64(len(d.Slices)) { - return nil, errors.Errorf("unknown chunk index %v", chunkIndex) + return nil, fmt.Errorf("unknown chunk index %v", chunkIndex) } s := d.Slices[chunkIndex] offset := s.SegmentIndex * merkle.SegmentSize @@ -167,12 +168,12 @@ func NewShardDownloader(m *MetaFile, c Contract, hkr HostKeyResolver) (*ShardDow // get host IP hostIP, err := hkr.ResolveHostKey(c.HostKey) if err != nil { - return nil, errors.Wrapf(err, "%v: could not resolve host key", hostKey.ShortKey()) + return nil, fmt.Errorf("%v: could not resolve host key: %w", hostKey.ShortKey(), err) } // create downloader d, err := proto.NewSession(hostIP, c.HostKey, c.ID, c.RenterKey, 0) if err != nil { - return nil, errors.Wrapf(err, "%v: could not initiate download protocol with host", hostKey.ShortKey()) + return nil, fmt.Errorf("%v: could not initiate download protocol with host: %w", hostKey.ShortKey(), err) } return &ShardDownloader{ Downloader: d, diff --git a/renter/meta.go b/renter/meta.go index d34ed3c..8430d08 100644 --- a/renter/meta.go +++ b/renter/meta.go @@ -8,6 +8,8 @@ import ( "encoding/binary" "encoding/hex" "encoding/json" + "errors" + "fmt" "io" "os" "strings" @@ -15,7 +17,7 @@ import ( "unsafe" "github.com/aead/chacha20/chacha" - "github.com/pkg/errors" + "gitlab.com/NebulousLabs/Sia/crypto" "lukechampine.com/frand" "lukechampine.com/us/hostdb" @@ -115,11 +117,11 @@ func (s *KeySeed) XORKeyStream(msg []byte, nonce []byte, startIndex uint64) { func (m *MetaIndex) Validate() error { switch { case m.Version != MetaFileVersion: - return errors.Errorf("incompatible version (%v, want %v)", m.Version, MetaFileVersion) + return fmt.Errorf("incompatible version (%v, want %v)", m.Version, MetaFileVersion) case m.MinShards == 0: - return errors.Errorf("MinShards cannot be 0") + return fmt.Errorf("MinShards cannot be 0") case m.MinShards > len(m.Hosts): - return errors.Errorf("MinShards (%v) must not exceed number of hosts (%v)", m.Version, len(m.Hosts)) + return fmt.Errorf("MinShards (%v) must not exceed number of hosts (%v)", m.Version, len(m.Hosts)) } return nil } @@ -197,12 +199,12 @@ func NewMetaFile(mode os.FileMode, size int64, hosts []hostdb.HostPublicKey, min func WriteMetaFile(filename string, m *MetaFile) error { // validate before writing if err := validateShards(m.Shards); err != nil { - return errors.Wrap(err, "invalid shards") + return fmt.Errorf("invalid shards: %w", err) } f, err := os.Create(filename + "_tmp") if err != nil { - return errors.Wrap(err, "could not create archive") + return fmt.Errorf("could not create archive: %w", err) } defer f.Close() zip := gzip.NewWriter(f) @@ -216,9 +218,9 @@ func WriteMetaFile(filename string, m *MetaFile) error { Mode: 0666, }) if err != nil { - return errors.Wrap(err, "could not write index header") + return fmt.Errorf("could not write index header: %w", err) } else if _, err = tw.Write(index); err != nil { - return errors.Wrap(err, "could not write index") + return fmt.Errorf("could not write index: %w", err) } // write shards @@ -230,7 +232,7 @@ func WriteMetaFile(filename string, m *MetaFile) error { Mode: 0666, }) if err != nil { - return errors.Wrap(err, "could not write shard header") + return fmt.Errorf("could not write shard header: %w", err) } for _, ss := range m.Shards[i] { copy(encSlice, ss.MerkleRoot[:]) @@ -238,22 +240,22 @@ func WriteMetaFile(filename string, m *MetaFile) error { binary.LittleEndian.PutUint32(encSlice[36:], ss.NumSegments) copy(encSlice[40:], ss.Nonce[:]) if _, err = tw.Write(encSlice); err != nil { - return errors.Wrap(err, "could not add shard to archive") + return fmt.Errorf("could not add shard to archive: %w", err) } } } // flush, close, and atomically rename if err := tw.Close(); err != nil { - return errors.Wrap(err, "could not write tar data") + return fmt.Errorf("could not write tar data: %w", err) } else if err := zip.Close(); err != nil { - return errors.Wrap(err, "could not write gzip data") + return fmt.Errorf("could not write gzip data: %w", err) } else if err := f.Sync(); err != nil { - return errors.Wrap(err, "could not sync archive file") + return fmt.Errorf("could not sync archive file: %w", err) } else if err := f.Close(); err != nil { - return errors.Wrap(err, "could not close archive file") + return fmt.Errorf("could not close archive file: %w", err) } else if err := os.Rename(filename+"_tmp", filename); err != nil { - return errors.Wrap(err, "could not atomically replace archive file") + return fmt.Errorf("could not atomically replace archive file: %w", err) } return nil @@ -263,12 +265,12 @@ func WriteMetaFile(filename string, m *MetaFile) error { func ReadMetaFile(filename string) (*MetaFile, error) { f, err := os.Open(filename) if err != nil { - return nil, errors.Wrap(err, "could not open archive") + return nil, fmt.Errorf("could not open archive: %w", err) } defer f.Close() zip, err := gzip.NewReader(f) if err != nil { - return nil, errors.Wrap(err, "could not read gzip header") + return nil, fmt.Errorf("could not read gzip header: %w", err) } tr := tar.NewReader(zip) @@ -282,13 +284,13 @@ func ReadMetaFile(filename string) (*MetaFile, error) { } break } else if err != nil { - return nil, errors.Wrap(err, "could not read archive entry") + return nil, fmt.Errorf("could not read archive entry: %w", err) } if hdr.Name == indexFilename { // read index if err = json.NewDecoder(tr).Decode(&m.MetaIndex); err != nil { - return nil, errors.Wrap(err, "could not decode index") + return nil, fmt.Errorf("could not decode index: %w", err) } } else { // read shard @@ -296,7 +298,7 @@ func ReadMetaFile(filename string) (*MetaFile, error) { buf := make([]byte, SectorSliceSize) for i := range shard { if _, err := io.ReadFull(tr, buf); err != nil { - return nil, errors.Wrap(err, "could not read shard") + return nil, fmt.Errorf("could not read shard: %w", err) } copy(shard[i].MerkleRoot[:], buf[:32]) shard[i].SegmentIndex = binary.LittleEndian.Uint32(buf[32:36]) @@ -310,25 +312,25 @@ func ReadMetaFile(filename string) (*MetaFile, error) { } } if err := zip.Close(); err != nil { - return nil, errors.Wrap(err, "archive is corrupted") + return nil, fmt.Errorf("archive is corrupted: %w", err) } // now that we have the index and all shards in memory, order the shards // according the Hosts list in the index if len(shards) != len(m.Hosts) { - return nil, errors.Errorf("invalid metafile: number of shards (%v) does not match number of hosts (%v)", len(shards), len(m.Hosts)) + return nil, fmt.Errorf("invalid metafile: number of shards (%v) does not match number of hosts (%v)", len(shards), len(m.Hosts)) } m.Shards = make([][]SectorSlice, len(m.Hosts)) for hpk, shard := range shards { i := m.HostIndex(hpk) if i == -1 { - return nil, errors.Errorf("invalid shard filename: host %q not present in index", hpk) + return nil, fmt.Errorf("invalid shard filename: host %q not present in index", hpk) } m.Shards[i] = shard } if err := validateShards(m.Shards); err != nil { - return nil, errors.Wrap(err, "invalid shards") + return nil, fmt.Errorf("invalid shards: %w", err) } return m, nil @@ -338,13 +340,13 @@ func ReadMetaFile(filename string) (*MetaFile, error) { func ReadMetaIndex(filename string) (MetaIndex, error) { f, err := os.Open(filename) if err != nil { - return MetaIndex{}, errors.Wrap(err, "could not open archive") + return MetaIndex{}, fmt.Errorf("could not open archive: %w", err) } defer f.Close() zip, err := gzip.NewReader(f) if err != nil { - return MetaIndex{}, errors.Wrap(err, "could not read gzip header") + return MetaIndex{}, fmt.Errorf("could not read gzip header: %w", err) } defer zip.Close() @@ -355,13 +357,13 @@ func ReadMetaIndex(filename string) (MetaIndex, error) { if err == io.EOF { break } else if err != nil { - return MetaIndex{}, errors.Wrap(err, "could not read archive entry") + return MetaIndex{}, fmt.Errorf("could not read archive entry: %w", err) } else if hdr.Name != indexFilename { continue // skip entry } if err := json.NewDecoder(tr).Decode(&index); err != nil { - return MetaIndex{}, errors.Wrap(err, "could not decode index") + return MetaIndex{}, fmt.Errorf("could not decode index: %w", err) } // done return index, nil @@ -394,13 +396,13 @@ func MetaFileCanDownload(filename string) (bool, error) { func readMetaFileShards(filename string) (MetaIndex, int, error) { f, err := os.Open(filename) if err != nil { - return MetaIndex{}, 0, errors.Wrap(err, "could not open archive") + return MetaIndex{}, 0, fmt.Errorf("could not open archive: %w", err) } defer f.Close() zip, err := gzip.NewReader(f) if err != nil { - return MetaIndex{}, 0, errors.Wrap(err, "could not read gzip header") + return MetaIndex{}, 0, fmt.Errorf("could not read gzip header: %w", err) } defer zip.Close() @@ -413,11 +415,11 @@ func readMetaFileShards(filename string) (MetaIndex, int, error) { if err == io.EOF { break } else if err != nil { - return MetaIndex{}, 0, errors.Wrap(err, "could not read archive entry") + return MetaIndex{}, 0, fmt.Errorf("could not read archive entry: %w", err) } if hdr.Name == indexFilename { if err := json.NewDecoder(tr).Decode(&index); err != nil { - return MetaIndex{}, 0, errors.Wrap(err, "could not decode index") + return MetaIndex{}, 0, fmt.Errorf("could not decode index: %w", err) } haveIndex = true } else { @@ -427,7 +429,7 @@ func readMetaFileShards(filename string) (MetaIndex, int, error) { buf := make([]byte, SectorSliceSize) for i := 0; i < numSlices; i++ { if _, err := io.ReadFull(tr, buf); err != nil { - return MetaIndex{}, 0, errors.Wrap(err, "could not read shard") + return MetaIndex{}, 0, fmt.Errorf("could not read shard: %w", err) } numSegments += int64(binary.LittleEndian.Uint32(buf[36:40])) } @@ -438,7 +440,7 @@ func readMetaFileShards(filename string) (MetaIndex, int, error) { return MetaIndex{}, 0, errors.New("archive does not contain an index") } if err := index.Validate(); err != nil { - return MetaIndex{}, 0, errors.Wrap(err, "invalid index") + return MetaIndex{}, 0, fmt.Errorf("invalid index: %w", err) } // count full shards @@ -462,7 +464,7 @@ func validateShards(shards [][]SectorSlice) error { for j := 1; j < len(shards); j++ { s2 := shards[j][chunkIndex] if s.NumSegments != s2.NumSegments { - return errors.Errorf("shards %v and %v differ at chunk %v", 0, j, chunkIndex) + return fmt.Errorf("shards %v and %v differ at chunk %v", 0, j, chunkIndex) } } } diff --git a/renter/proto/formcontract.go b/renter/proto/formcontract.go index affe42b..78c7343 100644 --- a/renter/proto/formcontract.go +++ b/renter/proto/formcontract.go @@ -2,10 +2,11 @@ package proto import ( "crypto/ed25519" + "errors" + "fmt" "math/big" "time" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/crypto" "gitlab.com/NebulousLabs/Sia/types" "lukechampine.com/us/ed25519hash" @@ -41,7 +42,7 @@ func (s *Session) FormContract(w Wallet, tpool TransactionPool, key ed25519.Priv // get a renter address for the file contract's valid/missed outputs refundAddr, err := w.Address() if err != nil { - return ContractRevision{}, nil, errors.Wrap(err, "could not get an address to use") + return ContractRevision{}, nil, fmt.Errorf("could not get an address to use: %w", err) } // create unlock conditions @@ -104,7 +105,7 @@ func (s *Session) FormContract(w Wallet, tpool TransactionPool, key ed25519.Priv // tax, and a transaction fee. _, maxFee, err := tpool.FeeEstimate() if err != nil { - return ContractRevision{}, nil, errors.Wrap(err, "could not estimate transaction fee") + return ContractRevision{}, nil, fmt.Errorf("could not estimate transaction fee: %w", err) } fee := maxFee.Mul64(estTxnSize) totalCost := renterPayout.Add(s.host.ContractPrice).Add(types.Tax(startHeight, fc.Payout)).Add(fee) @@ -154,7 +155,7 @@ func (s *Session) FormContract(w Wallet, tpool TransactionPool, key ed25519.Priv txn.TransactionSignatures = addedSignatures err = w.SignTransaction(&txn, toSign) if err != nil { - err = errors.Wrap(err, "failed to sign transaction") + err = fmt.Errorf("failed to sign transaction: %w", err) s.sess.WriteResponse(nil, errors.New("internal error")) // don't want to reveal too much return ContractRevision{}, nil, err } diff --git a/renter/proto/proto.go b/renter/proto/proto.go index c90ab84..4d5fb35 100644 --- a/renter/proto/proto.go +++ b/renter/proto/proto.go @@ -2,9 +2,10 @@ package proto // import "lukechampine.com/us/renter/proto" import ( + "errors" + "fmt" "time" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/crypto" "gitlab.com/NebulousLabs/Sia/types" "lukechampine.com/us/hostdb" @@ -12,12 +13,14 @@ import ( ) func wrapErr(err *error, fnName string) { - *err = errors.WithMessage(*err, fnName) + if *err != nil { + *err = fmt.Errorf("%s: %w", fnName, *err) + } } func wrapErrWithReplace(err *error, fnName string) { if *err != nil { - *err = errors.Wrap(errors.Unwrap(*err), fnName) + *err = fmt.Errorf("%s: %w", fnName, errors.Unwrap(*err)) } } @@ -124,7 +127,7 @@ func SubmitContractRevision(c ContractRevision, w Wallet, tpool TransactionPool) // calculate transaction fee _, maxFee, err := tpool.FeeEstimate() if err != nil { - return errors.Wrap(err, "could not estimate transaction fee") + return fmt.Errorf("could not estimate transaction fee: %w", err) } fee := maxFee.Mul64(estTxnSize) @@ -142,7 +145,7 @@ func SubmitContractRevision(c ContractRevision, w Wallet, tpool TransactionPool) } defer discard() if err := w.SignTransaction(&txn, toSign); err != nil { - return errors.Wrap(err, "failed to sign transaction") + return fmt.Errorf("failed to sign transaction: %w", err) } // submit the funded and signed transaction diff --git a/renter/proto/renew.go b/renter/proto/renew.go index cba5363..25b3bd9 100644 --- a/renter/proto/renew.go +++ b/renter/proto/renew.go @@ -2,10 +2,11 @@ package proto import ( "crypto/ed25519" + "errors" + "fmt" "math" "time" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/crypto" "gitlab.com/NebulousLabs/Sia/types" @@ -40,7 +41,7 @@ func (s *Session) RenewContract(w Wallet, tpool TransactionPool, renterPayout ty // get a renter address for the file contract's valid/missed outputs refundAddr, err := w.Address() if err != nil { - return ContractRevision{}, nil, errors.Wrap(err, "could not get an address to use") + return ContractRevision{}, nil, fmt.Errorf("could not get an address to use: %w", err) } // calculate "base" price and collateral -- the storage cost and collateral @@ -114,7 +115,7 @@ func (s *Session) RenewContract(w Wallet, tpool TransactionPool, renterPayout ty // to pay for everything *except* the host's collateral contribution. _, maxFee, err := tpool.FeeEstimate() if err != nil { - return ContractRevision{}, nil, errors.Wrap(err, "could not estimate transaction fee") + return ContractRevision{}, nil, fmt.Errorf("could not estimate transaction fee: %w", err) } fee := maxFee.Mul64(estTxnSize) renterCost := fc.Payout.Sub(totalCollateral).Add(fee) @@ -177,7 +178,7 @@ func (s *Session) RenewContract(w Wallet, tpool TransactionPool, renterPayout ty txn.TransactionSignatures = addedSignatures err = w.SignTransaction(&txn, toSign) if err != nil { - err = errors.Wrap(err, "failed to sign transaction") + err = fmt.Errorf("failed to sign transaction: %w", err) s.sess.WriteResponse(nil, err) return ContractRevision{}, nil, err } diff --git a/renter/proto/session.go b/renter/proto/session.go index 6bd1f5b..7c60900 100644 --- a/renter/proto/session.go +++ b/renter/proto/session.go @@ -5,6 +5,7 @@ import ( "crypto/ed25519" "encoding/binary" "encoding/json" + "errors" "fmt" "io" "math" @@ -13,7 +14,6 @@ import ( "sort" "time" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/crypto" "gitlab.com/NebulousLabs/Sia/modules" "gitlab.com/NebulousLabs/Sia/types" @@ -51,11 +51,13 @@ var ( // readCtx or rejectCtx depending on whether we encountered an I/O error or the // host sent an explicit error message. func wrapResponseErr(err error, readCtx, rejectCtx string) error { - err = errors.Cause(err) - if _, ok := err.(*renterhost.RPCError); ok { - return errors.Wrap(err, rejectCtx) + if errors.As(err, new(*renterhost.RPCError)) { + return fmt.Errorf("%s: %w", rejectCtx, err) } - return errors.Wrap(err, readCtx) + if err != nil { + return fmt.Errorf("%s: %w", readCtx, err) + } + return nil } type statsConn struct { @@ -211,7 +213,7 @@ func (s *Session) Lock(id types.FileContractID, key ed25519.PrivateKey, timeout s.sess.SetChallenge(resp.NewChallenge) // verify claimed revision if len(resp.Signatures) != 2 { - return errors.Errorf("host returned wrong number of signatures (expected 2, got %v)", len(resp.Signatures)) + return fmt.Errorf("host returned wrong number of signatures (expected 2, got %v)", len(resp.Signatures)) } revHash := renterhost.HashRevision(resp.Revision) if !ed25519hash.Verify(ed25519hash.ExtractPublicKey(key), revHash, resp.Signatures[0].Signature) { @@ -262,7 +264,7 @@ func (s *Session) Settings() (_ hostdb.HostSettings, err error) { if err := s.call(renterhost.RPCSettingsID, nil, &resp); err != nil { return hostdb.HostSettings{}, err } else if err := json.Unmarshal(resp.Settings, &s.host.HostSettings); err != nil { - return hostdb.HostSettings{}, errors.Wrap(err, "couldn't unmarshal json") + return hostdb.HostSettings{}, fmt.Errorf("couldn't unmarshal json: %w", err) } return s.host.HostSettings, nil } @@ -441,17 +443,17 @@ func (s *Session) Read(w io.Writer, sections []renterhost.RPCReadRequestSection) // Read the signature, which may or may not be present. lenbuf := make([]byte, 8) if _, err := io.ReadFull(msgReader, lenbuf); err != nil { - return errors.Wrap(err, "couldn't read signature len") + return fmt.Errorf("couldn't read signature len: %w", err) } if n := binary.LittleEndian.Uint64(lenbuf); n > 0 { hostSig = make([]byte, n) if _, err := io.ReadFull(msgReader, hostSig); err != nil { - return errors.Wrap(err, "couldn't read signature") + return fmt.Errorf("couldn't read signature: %w", err) } } // stream the sector data into w and the proof verifier if _, err := io.ReadFull(msgReader, lenbuf); err != nil { - return errors.Wrap(err, "couldn't read data len") + return fmt.Errorf("couldn't read data len: %w", err) } else if binary.LittleEndian.Uint64(lenbuf) != uint64(sec.Length) { return errors.New("host sent wrong amount of sector data") } @@ -462,11 +464,11 @@ func (s *Session) Read(w io.Writer, sections []renterhost.RPCReadRequestSection) // the proof verifier Reads one segment at a time, so bufio is crucial // for performance here if _, err := rpv.ReadFrom(bufio.NewReaderSize(tee, 1<<16)); err != nil { - return errors.Wrap(err, "couldn't stream sector data") + return fmt.Errorf("couldn't stream sector data: %w", err) } // read the Merkle proof if _, err := io.ReadFull(msgReader, lenbuf); err != nil { - return errors.Wrap(err, "couldn't read proof len") + return fmt.Errorf("couldn't read proof len: %w", err) } if binary.LittleEndian.Uint64(lenbuf) != uint64(merkle.ProofSize(merkle.SegmentsPerSector, proofStart, proofEnd)) { return errors.New("invalid proof size") @@ -474,7 +476,7 @@ func (s *Session) Read(w io.Writer, sections []renterhost.RPCReadRequestSection) proof := make([]crypto.Hash, binary.LittleEndian.Uint64(lenbuf)) for i := range proof { if _, err := io.ReadFull(msgReader, proof[i][:]); err != nil { - return errors.Wrap(err, "couldn't read Merkle proof") + return fmt.Errorf("couldn't read Merkle proof: %w", err) } } // verify the message tag and the Merkle proof @@ -642,7 +644,7 @@ func (s *Session) Write(actions []renterhost.RPCWriteAction) (err error) { Signature: ed25519hash.Sign(s.key, revisionHash), } if err := s.sess.WriteResponse(renterSig, nil); err != nil { - return errors.Wrap(err, "couldn't write signature response") + return fmt.Errorf("couldn't write signature response: %w", err) } var hostSig renterhost.RPCWriteResponse if err := s.sess.ReadResponse(&hostSig, 4096); err != nil { diff --git a/renter/proto/session_test.go b/renter/proto/session_test.go index 67b48a9..519b555 100644 --- a/renter/proto/session_test.go +++ b/renter/proto/session_test.go @@ -3,10 +3,10 @@ package proto import ( "bytes" "crypto/ed25519" + "errors" "io/ioutil" "testing" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/crypto" "gitlab.com/NebulousLabs/Sia/types" "gitlab.com/NebulousLabs/encoding" @@ -24,6 +24,7 @@ func (stubWallet) Address() (_ types.UnlockHash, _ error) { return } func (stubWallet) FundTransaction(*types.Transaction, types.Currency) ([]crypto.Hash, func(), error) { return nil, func() {}, nil } + func (stubWallet) SignTransaction(txn *types.Transaction, toSign []crypto.Hash) error { txn.TransactionSignatures = append(txn.TransactionSignatures, make([]types.TransactionSignature, len(toSign))...) return nil @@ -173,7 +174,7 @@ func TestRenew(t *testing.T) { } // attempting to lock the old contract should return ErrContractFinalized - if err := renter.Lock(oldID, oldKey, 0); errors.Cause(err) != ErrContractFinalized { + if err := renter.Lock(oldID, oldKey, 0); !errors.Is(err, ErrContractFinalized) { t.Fatal("expected ErrContractFinalized, got", err) } renter.Close() diff --git a/renter/renterutil/fileops.go b/renter/renterutil/fileops.go index 595d9b8..b339a12 100644 --- a/renter/renterutil/fileops.go +++ b/renter/renterutil/fileops.go @@ -2,11 +2,12 @@ package renterutil import ( "bytes" + "errors" + "fmt" "io" "os" "time" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/crypto" "lukechampine.com/frand" "lukechampine.com/us/hostdb" @@ -296,7 +297,7 @@ func (fs *PseudoFS) flushSectors() error { } } if len(errs) != 0 { - return errors.Wrap(errs, "could not upload to some hosts") + return fmt.Errorf("could not upload to some hosts: %w", errs) } // update files @@ -471,15 +472,15 @@ func (fs *PseudoFS) fileReadAt(f *openMetaFile, p []byte, off int64) (int, error } close(reqChan) if goodShards < f.m.MinShards { - return 0, errors.Wrapf(errs, "too many hosts did not supply their shard (needed %v, got %v)", - f.m.MinShards, goodShards) + return 0, fmt.Errorf("too many hosts did not supply their shard (needed %v, got %v): %w", + f.m.MinShards, goodShards, errs) } // recover data shards directly into p skip := int(off % f.m.MinChunkSize()) err := f.m.ErasureCode().Recover(bytes.NewBuffer(p[:0]), shards, skip, len(p)) if err != nil { - return 0, errors.Wrap(err, "could not recover chunk") + return 0, fmt.Errorf("could not recover chunk: %w", err) } // apply any pending writes diff --git a/renter/renterutil/filesystem.go b/renter/renterutil/filesystem.go index 16af1c1..9330781 100644 --- a/renter/renterutil/filesystem.go +++ b/renter/renterutil/filesystem.go @@ -4,6 +4,8 @@ package renterutil // import "lukechampine.com/us/renter/renterutil" import ( "bytes" + "errors" + "fmt" "io" "os" "path/filepath" @@ -11,7 +13,6 @@ import ( "sync" "time" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/crypto" "lukechampine.com/us/hostdb" "lukechampine.com/us/renter" @@ -83,12 +84,12 @@ func (fs *PseudoFS) Chmod(name string, mode os.FileMode) error { m, err := renter.ReadMetaFile(path) if err != nil { - return errors.Wrapf(err, "chmod %v", path) + return fmt.Errorf("chmod %v: %w", path, err) } m.Mode = mode m.ModTime = time.Now() if err := renter.WriteMetaFile(path, m); err != nil { - return errors.Wrapf(err, "chmod %v", path) + return fmt.Errorf("chmod %v: %w", path, err) } return nil } @@ -97,7 +98,7 @@ func (fs *PseudoFS) Chmod(name string, mode os.FileMode) error { // (before umask), truncating it if it already exists. The returned file has // mode O_RDWR. func (fs *PseudoFS) Create(name string, minShards int) (*PseudoFile, error) { - return fs.OpenFile(name, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0666, minShards) + return fs.OpenFile(name, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0o666, minShards) } // Mkdir creates a new directory with the specified name and permission bits @@ -154,7 +155,7 @@ func (fs *PseudoFS) OpenFile(name string, flag int, perm os.FileMode, minShards } } if len(missing) > 0 { - return nil, errors.Errorf("insufficient contracts: need a contract from each of these hosts: %v", + return nil, fmt.Errorf("insufficient contracts: need a contract from each of these hosts: %v", strings.Join(missing, " ")) } } @@ -196,7 +197,7 @@ func (fs *PseudoFS) OpenFile(name string, flag int, perm os.FileMode, minShards var err error m, err = renter.ReadMetaFile(path) if err != nil { - return nil, errors.Wrapf(err, "open %v", name) + return nil, fmt.Errorf("open %v: %w", path, err) } // check whether we have a session for each of the file's hosts var missing []string @@ -208,13 +209,13 @@ func (fs *PseudoFS) OpenFile(name string, flag int, perm os.FileMode, minShards if flag&rwmask == os.O_RDONLY { // only need m.MinShards hosts in order to read if have := len(m.Hosts) - len(missing); have < m.MinShards { - return nil, errors.Errorf("insufficient contracts: need a contract from at least %v of these hosts: %v", + return nil, fmt.Errorf("insufficient contracts: need a contract from at least %v of these hosts: %v", m.MinShards-have, strings.Join(missing, " ")) } } else { // need all hosts in order to write if len(missing) > 0 { - return nil, errors.Errorf("insufficient contracts: need a contract from each of these hosts: %v", + return nil, fmt.Errorf("insufficient contracts: need a contract from each of these hosts: %v", strings.Join(missing, " ")) } } @@ -441,7 +442,7 @@ func (fs *PseudoFS) Stat(name string) (os.FileInfo, error) { path += metafileExt index, err := renter.ReadMetaIndex(path) if err != nil { - return nil, errors.Wrapf(err, "stat %v", name) + return nil, fmt.Errorf("stat %v: %w", name, err) } return pseudoFileInfo{name, index}, nil } @@ -513,9 +514,11 @@ const rwmask = os.O_RDONLY | os.O_WRONLY | os.O_RDWR func (pf PseudoFile) writeable() bool { return pf.flags&rwmask == os.O_WRONLY || pf.flags&rwmask == os.O_RDWR } + func (pf PseudoFile) readable() bool { return pf.flags&rwmask == os.O_RDONLY || pf.flags&rwmask == os.O_RDWR } + func (pf PseudoFile) appendOnly() bool { return pf.flags&os.O_APPEND == os.O_APPEND } diff --git a/renter/renterutil/filesystem_test.go b/renter/renterutil/filesystem_test.go index 4414790..3f66b0e 100644 --- a/renter/renterutil/filesystem_test.go +++ b/renter/renterutil/filesystem_test.go @@ -4,11 +4,11 @@ import ( "bytes" "crypto/ed25519" "encoding/hex" + "errors" "io" "os" "testing" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/crypto" "gitlab.com/NebulousLabs/Sia/modules" "gitlab.com/NebulousLabs/Sia/types" @@ -26,6 +26,7 @@ func (stubWallet) Address() (_ types.UnlockHash, _ error) { return } func (stubWallet) FundTransaction(*types.Transaction, types.Currency) ([]crypto.Hash, func(), error) { return nil, func() {}, nil } + func (stubWallet) SignTransaction(txn *types.Transaction, toSign []crypto.Hash) error { txn.TransactionSignatures = append(txn.TransactionSignatures, make([]types.TransactionSignature, len(toSign))...) return nil @@ -117,9 +118,9 @@ func TestHostErrorSet(t *testing.T) { } // should get a HostErrorSet when we sync err = pf.Sync() - hes, ok := errors.Cause(err).(HostErrorSet) - if !ok || hes == nil { - t.Fatal("expected HostSetError, got", errors.Cause(err)) + var hes HostErrorSet + if !errors.As(err, &hes) { + t.Fatal("expected HostSetError, got", err) } else if len(hes) != 3 { t.Fatal("expected HostSetError to have three hosts, got", len(hes)) } @@ -183,7 +184,7 @@ func TestFileSystemBasic(t *testing.T) { t.Error("incorrect name") } else if stat.Size() != int64(len(data)) { t.Error("incorrect size", stat.Size(), len(data)) - } else if stat.Mode() != 0666 { + } else if stat.Mode() != 0o666 { t.Error("incorrect mode") } @@ -194,7 +195,7 @@ func TestFileSystemBasic(t *testing.T) { } // chmod file - err = fs.Chmod("foo", 0676) + err = fs.Chmod("foo", 0o676) if err != nil { t.Fatal(err) } @@ -214,7 +215,7 @@ func TestFileSystemBasic(t *testing.T) { t.Error("incorrect name") } else if stat.Size() != int64(len(data)) { t.Error("incorrect size", stat.Size(), len(data)) - } else if stat.Mode() != 0676 { + } else if stat.Mode() != 0o676 { t.Error("incorrect mode") } diff --git a/renter/renterutil/hostset.go b/renter/renterutil/hostset.go index c2711bf..93bc816 100644 --- a/renter/renterutil/hostset.go +++ b/renter/renterutil/hostset.go @@ -1,19 +1,22 @@ package renterutil import ( + "errors" + "fmt" "strings" "sync" "time" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/types" "lukechampine.com/us/hostdb" "lukechampine.com/us/renter" "lukechampine.com/us/renter/proto" ) -var errNoHost = errors.New("no record of that host") -var errHostAcquired = errors.New("host is currently acquired") +var ( + errNoHost = errors.New("no record of that host") + errHostAcquired = errors.New("host is currently acquired") +) // A HostError associates an error with a given host. type HostError struct { @@ -182,7 +185,7 @@ func (set *HostSet) AddHost(c renter.Contract) { } hostIP, err := set.hkr.ResolveHostKey(c.HostKey) if err != nil { - return errors.Wrap(err, "could not resolve host key") + return fmt.Errorf("could not resolve host key: %w", err) } // create and lock the session manually so that we can use our custom // lock timeout diff --git a/renter/upload.go b/renter/upload.go index d656e88..2ba4772 100644 --- a/renter/upload.go +++ b/renter/upload.go @@ -1,7 +1,9 @@ package renter import ( - "github.com/pkg/errors" + "errors" + "fmt" + "gitlab.com/NebulousLabs/Sia/crypto" "gitlab.com/NebulousLabs/Sia/types" "lukechampine.com/frand" @@ -182,12 +184,12 @@ func NewShardUploader(m *MetaFile, c Contract, hkr HostKeyResolver, currentHeigh // get host IP hostIP, err := hkr.ResolveHostKey(c.HostKey) if err != nil { - return nil, errors.Wrapf(err, "%v: could not resolve host key", hostKey.ShortKey()) + return nil, fmt.Errorf("%v: could not resolve host key: %w", hostKey.ShortKey(), err) } // create uploader u, err := proto.NewSession(hostIP, c.HostKey, c.ID, c.RenterKey, currentHeight) if err != nil { - return nil, errors.Wrapf(err, "%v: could not initiate upload protocol with host", hostKey.ShortKey()) + return nil, fmt.Errorf("%v: could not initiate upload protocol with host: %w", hostKey.ShortKey(), err) } return &ShardUploader{ Uploader: u, diff --git a/renterhost/encoding.go b/renterhost/encoding.go index 1f557b0..49a3b69 100644 --- a/renterhost/encoding.go +++ b/renterhost/encoding.go @@ -3,11 +3,12 @@ package renterhost import ( "bytes" "encoding/binary" + "errors" + "fmt" "io" "math/big" "unsafe" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/crypto" "gitlab.com/NebulousLabs/Sia/types" "golang.org/x/crypto/blake2b" @@ -111,7 +112,7 @@ func (b *objBuffer) writePrefix(i int) { func (b *objBuffer) readPrefix(elemSize int) int { n := b.readUint64() if n > uint64(b.buf.Len()/elemSize) { - b.err = errors.Errorf("marshalled object contains invalid length prefix (%v elems x %v bytes/elem > %v bytes left in message)", n, elemSize, b.buf.Len()) + b.err = fmt.Errorf("marshalled object contains invalid length prefix (%v elems x %v bytes/elem > %v bytes left in message)", n, elemSize, b.buf.Len()) return 0 } return int(n) @@ -1244,12 +1245,12 @@ func (req *loopKeyExchangeRequest) readFrom(r io.Reader) error { var id Specifier copy(id[:], buf[:16]) if id != loopEnter { - return errors.Errorf("renter sent wrong specifier %q", id.String()) + return fmt.Errorf("renter sent wrong specifier %q", id.String()) } copy(req.PublicKey[:], buf[16:48]) numCiphers := binary.LittleEndian.Uint64(buf[48:]) if numCiphers > 16 { - return errors.Errorf("renter sent too many ciphers (%v)", numCiphers) + return fmt.Errorf("renter sent too many ciphers (%v)", numCiphers) } // second read, if necessary, to get ciphers ciphersSize := int(numCiphers) * sizeofSpecifier @@ -1285,7 +1286,7 @@ func (resp *loopKeyExchangeResponse) readFrom(r io.Reader) error { copy(resp.PublicKey[:], buf[:32]) sigLen := binary.LittleEndian.Uint64(buf[32:]) if sigLen != 64 { - return errors.Errorf("host sent non-ed25519 signature (%v bytes)", sigLen) + return fmt.Errorf("host sent non-ed25519 signature (%v bytes)", sigLen) } resp.Signature = buf[8+32:][:64] copy(resp.Cipher[:], buf[8+32+64:]) diff --git a/renterhost/session.go b/renterhost/session.go index efbb304..19a2a72 100644 --- a/renterhost/session.go +++ b/renterhost/session.go @@ -8,6 +8,8 @@ import ( "crypto/ed25519" "crypto/subtle" "encoding/binary" + "errors" + "fmt" "io" "io/ioutil" "net" @@ -15,7 +17,7 @@ import ( "sync" "github.com/aead/chacha20/chacha" - "github.com/pkg/errors" + "gitlab.com/NebulousLabs/Sia/crypto" "gitlab.com/NebulousLabs/Sia/types" "golang.org/x/crypto/blake2b" @@ -26,7 +28,9 @@ import ( ) func wrapErr(err *error, fnName string) { - *err = errors.Wrap(*err, fnName) + if *err != nil { + *err = fmt.Errorf("%s: %w", fnName, *err) + } } // MinMessageSize is the minimum size of an RPC message. If an encoded message @@ -168,9 +172,9 @@ func (s *Session) readMessage(obj ProtocolObject, maxLen uint64) error { } msgSize := s.inbuf.readUint64() if msgSize > maxLen { - return errors.Errorf("message size (%v bytes) exceeds maxLen of %v bytes", msgSize, maxLen) + return fmt.Errorf("message size (%v bytes) exceeds maxLen of %v bytes", msgSize, maxLen) } else if msgSize < uint64(s.aead.NonceSize()+s.aead.Overhead()) { - return errors.Errorf("message size (%v bytes) is too small (nonce + MAC is %v bytes)", msgSize, s.aead.NonceSize()+s.aead.Overhead()) + return fmt.Errorf("message size (%v bytes) is too small (nonce + MAC is %v bytes)", msgSize, s.aead.NonceSize()+s.aead.Overhead()) } s.inbuf.reset() @@ -192,12 +196,16 @@ func (s *Session) readMessage(obj ProtocolObject, maxLen uint64) error { // WriteRequest sends an encrypted RPC request, comprising an RPC ID and a // request object. -func (s *Session) WriteRequest(rpcID Specifier, req ProtocolObject) (err error) { - err = errors.Wrap(s.writeMessage(&rpcID), "WriteRequestID") - if err == nil && req != nil { - err = errors.Wrap(s.writeMessage(req), "WriteRequest") +func (s *Session) WriteRequest(rpcID Specifier, req ProtocolObject) error { + if err := s.writeMessage(&rpcID); err != nil { + return fmt.Errorf("WriteRequestID: %w", err) } - return + if req != nil { + if err := s.writeMessage(req); err != nil { + return fmt.Errorf("WriteRequest: %w", err) + } + } + return nil } // ReadID reads an RPC request ID. If the renter sends the session termination @@ -307,9 +315,9 @@ func (s *Session) RawResponse(maxLen uint64) (*ResponseReader, error) { } msgSize := s.inbuf.readUint64() if msgSize > maxLen { - return nil, errors.Errorf("message size (%v bytes) exceeds maxLen of %v bytes", msgSize, maxLen) + return nil, fmt.Errorf("message size (%v bytes) exceeds maxLen of %v bytes", msgSize, maxLen) } else if msgSize < uint64(s.aead.NonceSize()+s.aead.Overhead()) { - return nil, errors.Errorf("message size (%v bytes) is too small (nonce + MAC is %v bytes)", msgSize, s.aead.NonceSize()+s.aead.Overhead()) + return nil, fmt.Errorf("message size (%v bytes) is too small (nonce + MAC is %v bytes)", msgSize, s.aead.NonceSize()+s.aead.Overhead()) } msgSize -= uint64(s.aead.NonceSize() + s.aead.Overhead()) @@ -433,11 +441,11 @@ func NewRenterSession(conn io.ReadWriteCloser, pub ed25519.PublicKey) (_ *Sessio Ciphers: []Specifier{cipherChaCha20Poly1305}, } if err := req.writeTo(conn); err != nil { - return nil, errors.Wrap(err, "couldn't write handshake") + return nil, fmt.Errorf("couldn't write handshake: %w", err) } var resp loopKeyExchangeResponse if err := resp.readFrom(conn); err != nil { - return nil, errors.Wrap(err, "couldn't read host's handshake") + return nil, fmt.Errorf("couldn't read host's handshake: %w", err) } // validate the signature before doing anything else if !ed25519hash.Verify(pub, hashKeys(req.PublicKey, resp.PublicKey), resp.Signature) { diff --git a/renterhost/session_test.go b/renterhost/session_test.go index 6eaae6a..9e9f035 100644 --- a/renterhost/session_test.go +++ b/renterhost/session_test.go @@ -3,12 +3,12 @@ package renterhost import ( "bytes" "crypto/ed25519" + "errors" "io" "io/ioutil" "reflect" "testing" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/crypto" "gitlab.com/NebulousLabs/Sia/types" "gitlab.com/NebulousLabs/encoding" @@ -113,9 +113,11 @@ type pipeRWC struct { func (p pipeRWC) Read(b []byte) (int, error) { return p.r.Read(b) } + func (p pipeRWC) Write(b []byte) (int, error) { return p.w.Write(b) } + func (p pipeRWC) Close() error { p.r.Close() return p.w.Close() @@ -150,7 +152,7 @@ func TestSession(t *testing.T) { defer hs.Close() for { id, err := hs.ReadID() - if errors.Cause(err) == ErrRenterClosed { + if errors.Is(err, ErrRenterClosed) { return nil } else if err != nil { return err @@ -232,7 +234,7 @@ func TestFormContract(t *testing.T) { defer hs.Close() for { id, err := hs.ReadID() - if errors.Cause(err) == ErrRenterClosed { + if errors.Is(err, ErrRenterClosed) { return nil } else if err != nil { return err @@ -307,7 +309,7 @@ func TestRawMessage(t *testing.T) { defer hs.Close() for { id, err := hs.ReadID() - if errors.Cause(err) == ErrRenterClosed { + if errors.Is(err, ErrRenterClosed) { return nil } else if err != nil { return err diff --git a/wallet/bip39.go b/wallet/bip39.go index f24dddc..f3e43d5 100644 --- a/wallet/bip39.go +++ b/wallet/bip39.go @@ -3,9 +3,9 @@ package wallet import ( "crypto/sha256" "encoding/binary" + "errors" + "fmt" "strings" - - "github.com/pkg/errors" ) // NOTE: This is not a full implementation of BIP39; only 12-word phrases (128 @@ -46,7 +46,7 @@ func decodeBIP39Phrase(phrase string) ([16]byte, error) { } for _, word := range words { if _, ok := wordMap[word]; !ok { - return [16]byte{}, errors.Errorf("unrecognized word %q in seed phrase", word) + return [16]byte{}, fmt.Errorf("unrecognized word %q in seed phrase", word) } } diff --git a/wallet/builder.go b/wallet/builder.go index 3934b28..5e0d28e 100644 --- a/wallet/builder.go +++ b/wallet/builder.go @@ -2,11 +2,11 @@ package wallet import ( "crypto/ed25519" + "errors" "math/big" "sort" "unsafe" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/types" "lukechampine.com/us/ed25519hash" ) diff --git a/wallet/seedwallet.go b/wallet/seedwallet.go index d673f51..211f345 100644 --- a/wallet/seedwallet.go +++ b/wallet/seedwallet.go @@ -1,10 +1,10 @@ package wallet import ( + "errors" "reflect" "sync" - "github.com/pkg/errors" "gitlab.com/NebulousLabs/Sia/crypto" "gitlab.com/NebulousLabs/Sia/modules" "gitlab.com/NebulousLabs/Sia/types"