From 0edf1ae081ea715221b168456f31f0d1325cbc14 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 29 Nov 2018 20:01:37 -0800 Subject: [PATCH 01/13] build: update to latest btcwallet, neutrino, bbolt versions --- go.mod | 25 +++++++------------------ go.sum | 46 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/go.mod b/go.mod index 60e4da8a..8a14720a 100644 --- a/go.mod +++ b/go.mod @@ -6,23 +6,16 @@ require ( github.com/NebulousLabs/go-upnp v0.0.0-20180202185039-29b680b06c82 github.com/Yawning/aez v0.0.0-20180114000226-4dad034d9db2 github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect - github.com/aead/siphash v1.0.1 // indirect - github.com/btcsuite/btcd v0.0.0-20180824064422-79e00513b101 + github.com/btcsuite/btcd v0.0.0-20180824064422-b6c71b40a82170695049917527b460e796d33ed7 github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f - github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a - github.com/btcsuite/btcwallet v0.0.0-20181116030035-55c7c6399321 + github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60ae4834a1f57511e20c17b5f78be4b + github.com/btcsuite/btcwallet v0.0.0-20181116030035-284e2e0e696e33d5be388f7f3d9a26db703e0c06 github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941 - github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect - github.com/btcsuite/golangcrypto v0.0.0-20150304025918-53f62d9b43e8 // indirect - github.com/btcsuite/goleveldb v1.0.0 // indirect - github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect - github.com/coreos/bbolt v0.0.0-20180223184059-4f5275f4ebbf + github.com/coreos/bbolt v0.0.0-20180223184059-7ee3ded59d4835e10f3e7d0f7603c42aa5e83820 github.com/davecgh/go-spew v1.1.1 - github.com/fsnotify/fsnotify v1.4.7 // indirect github.com/go-errors/errors v1.0.1 github.com/golang/protobuf v1.2.0 github.com/grpc-ecosystem/grpc-gateway v0.0.0-20170724004829-f2862b476edc - github.com/hpcloud/tail v1.0.0 // indirect github.com/jackpal/gateway v1.0.4 github.com/jackpal/go-nat-pmp v0.0.0-20170405195558-28a68d0c24ad github.com/jessevdk/go-flags v0.0.0-20170926144705-f88afde2fa19 @@ -34,25 +27,21 @@ require ( github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073 // indirect github.com/juju/utils v0.0.0-20180820210520-bf9cc5bdd62d // indirect github.com/juju/version v0.0.0-20180108022336-b64dbd566305 // indirect - github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 - github.com/lightninglabs/gozmq v0.0.0-20180324010646-462a8a753885 // indirect - github.com/lightninglabs/neutrino v0.0.0-20181026005035-9a42f7df21be + github.com/kkdai/bstream v0.0.0-20181106074824-b3251f7901ec + github.com/lightninglabs/neutrino v0.0.0-20181026005035-c86e4463aec4e292dd46c7b506d8dfc9cd3fe031 github.com/lightningnetwork/lightning-onion v0.0.0-20180605012408-ac4d9da8f1d6 github.com/ltcsuite/ltcd v0.0.0-20180701083835-cdab10132e8c github.com/miekg/dns v0.0.0-20171125082028-79bfde677fa8 github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af // indirect github.com/tv42/zbase32 v0.0.0-20160707012821-501572607d02 github.com/urfave/cli v1.18.0 - golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac + golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85 golang.org/x/net v0.0.0-20180826012351-8a410e7b638d - golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 // indirect golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 google.golang.org/grpc v1.15.0 gopkg.in/errgo.v1 v1.0.0 // indirect - gopkg.in/fsnotify.v1 v1.4.7 // indirect gopkg.in/macaroon-bakery.v2 v2.0.1 gopkg.in/macaroon.v2 v2.0.0 gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce // indirect - gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect ) diff --git a/go.sum b/go.sum index eb629b13..b8b040ea 100644 --- a/go.sum +++ b/go.sum @@ -11,14 +11,19 @@ github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmH github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -github.com/btcsuite/btcd v0.0.0-20180824064422-79e00513b101 h1:/xe0TaCPKYG1hw3IffeXdmiJfw8x6SFBDKnr83vtVbw= -github.com/btcsuite/btcd v0.0.0-20180824064422-79e00513b101/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= +github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4= +github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= +github.com/btcsuite/btcd v0.0.0-20180823030728-d81d8877b8f3/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= +github.com/btcsuite/btcd v0.0.0-20180824064422-b6c71b40a82170695049917527b460e796d33ed7 h1:hvyEQzI9fgZ0WNl6WEQraBoHiXeGYQ3Urbk7jzBNBBc= +github.com/btcsuite/btcd v0.0.0-20180824064422-b6c71b40a82170695049917527b460e796d33ed7/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= -github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a h1:RQMUrEILyYJEoAT34XS/kLu40vC0+po/UfxrBBA4qZE= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcwallet v0.0.0-20181116030035-55c7c6399321 h1:RYidO91vylcYH/Iva/vGrScjrdp8x5RB1XjhOq/TZss= -github.com/btcsuite/btcwallet v0.0.0-20181116030035-55c7c6399321/go.mod h1:+q7/nPeXqu8jJ0ah0fcMOlWGZ2GeL2QoL6c7nCFUEVA= +github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60ae4834a1f57511e20c17b5f78be4b h1:sa+k743hEDlacUmuzqYlpxx4gp61C9Cf531bPaOneWo= +github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60ae4834a1f57511e20c17b5f78be4b/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/btcwallet v0.0.0-20180904010540-284e2e0e696e33d5be388f7f3d9a26db703e0c06/go.mod h1:/d7QHZsfUAruXuBhyPITqoYOmJ+nq35qPsJjz/aSpCg= +github.com/btcsuite/btcwallet v0.0.0-20181116030035-284e2e0e696e33d5be388f7f3d9a26db703e0c06 h1:4v35CTTwAliWecZvAMxpIuk2fZvuuBzWaZslnp0YAvs= +github.com/btcsuite/btcwallet v0.0.0-20181116030035-284e2e0e696e33d5be388f7f3d9a26db703e0c06/go.mod h1:/d7QHZsfUAruXuBhyPITqoYOmJ+nq35qPsJjz/aSpCg= github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941 h1:kij1x2aL7VE6gtx8KMIt8PGPgI5GV9LgtHFG5KaEMPY= github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941/go.mod h1:QcFA8DZHtuIAdYKCq/BzELOaznRsCvwf4zTPmaYwaig= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw= @@ -32,8 +37,9 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/coreos/bbolt v0.0.0-20180223184059-4f5275f4ebbf h1:tJpA9/rXV/dIbGH2eWW6Cptwwz5ax6ft2DAuHR/qfNQ= -github.com/coreos/bbolt v0.0.0-20180223184059-4f5275f4ebbf/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/bbolt v0.0.0-20180223184059-7ee3ded59d4835e10f3e7d0f7603c42aa5e83820 h1:W1bWzjKRrqKEpWlFsJ6Yef9Q4LUhdfJmS6sQrQj5L6c= +github.com/coreos/bbolt v0.0.0-20180223184059-7ee3ded59d4835e10f3e7d0f7603c42aa5e83820/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= @@ -44,6 +50,7 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekf github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v0.0.0-20180821051752-b27b920f9e71/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/grpc-ecosystem/grpc-gateway v0.0.0-20170724004829-f2862b476edc h1:3NXdOHZ1YlN6SGP3FPbn4k73O2MeEp065abehRwGFxI= @@ -54,6 +61,7 @@ github.com/jackpal/gateway v1.0.4 h1:LS5EHkLuQ6jzaHwULi0vL+JO0mU/n4yUtK8oUjHHOlM github.com/jackpal/gateway v1.0.4/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA= github.com/jackpal/go-nat-pmp v0.0.0-20170405195558-28a68d0c24ad h1:heFfj7z0pGsNCekUlsFhO2jstxO4b5iQ665LjwM5mDc= github.com/jackpal/go-nat-pmp v0.0.0-20170405195558-28a68d0c24ad/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v0.0.0-20170926144705-f88afde2fa19 h1:k9/LaykApavRKKlaWkunBd48Um+vMxnUNNsIjS7OJn8= github.com/jessevdk/go-flags v0.0.0-20170926144705-f88afde2fa19/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jrick/logrotate v1.0.0 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI= @@ -73,8 +81,9 @@ github.com/juju/utils v0.0.0-20180820210520-bf9cc5bdd62d/go.mod h1:6/KLg8Wz/y2KV github.com/juju/version v0.0.0-20180108022336-b64dbd566305 h1:lQxPJ1URr2fjsKnJRt/BxiIxjLt9IKGvS+0injMHbag= github.com/juju/version v0.0.0-20180108022336-b64dbd566305/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= +github.com/kkdai/bstream v0.0.0-20181106074824-b3251f7901ec h1:n1NeQ3SgUHyISrjFFoO5dR748Is8dBL9qpaTNfphQrs= +github.com/kkdai/bstream v0.0.0-20181106074824-b3251f7901ec/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -82,8 +91,9 @@ 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/lightninglabs/gozmq v0.0.0-20180324010646-462a8a753885 h1:fTLuPUkaKIIV0+gA1IxiBDvDxtF8tzpSF6N6NfFGmsU= github.com/lightninglabs/gozmq v0.0.0-20180324010646-462a8a753885/go.mod h1:KUh15naRlx/TmUMFS/p4JJrCrE6F7RGF7rsnvuu45E4= -github.com/lightninglabs/neutrino v0.0.0-20181026005035-9a42f7df21be h1:wZMh0rYDoZ7r2S0ylgBVHEMWL0+t7LcP+ZGEig7UDHk= -github.com/lightninglabs/neutrino v0.0.0-20181026005035-9a42f7df21be/go.mod h1:KJq43Fu9ceitbJsSXMILcT4mGDNI/crKmPIkDOZXFyM= +github.com/lightninglabs/neutrino v0.0.0-20181017011010-4d6069299130/go.mod h1:KJq43Fu9ceitbJsSXMILcT4mGDNI/crKmPIkDOZXFyM= +github.com/lightninglabs/neutrino v0.0.0-20181026005035-c86e4463aec4e292dd46c7b506d8dfc9cd3fe031 h1:gXqBl67K2v6SUDJpCxJiRzmdkZzxp/tt4z1ezXWjQqE= +github.com/lightninglabs/neutrino v0.0.0-20181026005035-c86e4463aec4e292dd46c7b506d8dfc9cd3fe031/go.mod h1:Y8IaaFZEKKGiyuRmUmKLR/n9+8m61mMDTkQBIMTc/Fw= github.com/lightningnetwork/lightning-onion v0.0.0-20180605012408-ac4d9da8f1d6 h1:ONLGrYJVQdbtP6CE/ff1KNWZtygRGEh12RzonTiCzPs= github.com/lightningnetwork/lightning-onion v0.0.0-20180605012408-ac4d9da8f1d6/go.mod h1:8EgEt4a/NUOVQd+3kk6n9aZCJ1Ssj96Pb6lCrci+6oc= github.com/ltcsuite/ltcd v0.0.0-20180701083835-cdab10132e8c h1:rdKAF0qixVZQy+Hkrojg2vHTZOxJEHns2ymbevTDPms= @@ -100,18 +110,25 @@ github.com/tv42/zbase32 v0.0.0-20160707012821-501572607d02 h1:tcJ6OjwOMvExLlzrAV github.com/tv42/zbase32 v0.0.0-20160707012821-501572607d02/go.mod h1:tHlrkM198S068ZqfrO6S8HsoJq2bF3ETfTL+kt4tInY= github.com/urfave/cli v1.18.0 h1:m9MfmZWX7bwr9kUcs/Asr95j0IVXzGNNc+/5ku2m26Q= github.com/urfave/cli v1.18.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac h1:7d7lG9fHOLdL6jZPtnV4LpI41SbohIJ1Atq7U991dMg= -golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +go.etcd.io/bbolt v1.3.0 h1:oY10fI923Q5pVCVt1GBTZMn8LHo5M+RCInFpeMnV4QI= +go.etcd.io/bbolt v1.3.0/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85 h1:et7+NAX3lLIk5qUCTA9QelBjGE/NkhzYw/mhnr0s7nI= +golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180821023952-922f4815f713/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d h1:g9qWBGx4puODJTMVyoPrpoxPFgVGd+z1DZwjfRu4d0I= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180821140842-3b58ed4ad339/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 h1:YAFjXN64LMvktoUZH9zgY4lGc/msGN7HQfoSuKCgaDU= +golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 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/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM= @@ -120,6 +137,7 @@ golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGm google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.15.0 h1:Az/KuahOM4NAidTEuJCv/RonAA7rYsTPkqXVjr+8OOw= google.golang.org/grpc v1.15.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 1fd3aac9257a14dd35e45087b8d316c3f9b5bc7b Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 29 Nov 2018 20:04:21 -0800 Subject: [PATCH 02/13] multi: switch from bolt packge to bbolt package for all imports --- autopilot/graph.go | 6 +- breacharbiter.go | 12 +-- breacharbiter_test.go | 52 ++++++------ channeldb/channel.go | 82 +++++++++---------- channeldb/db.go | 50 ++++++------ channeldb/forwarding_log.go | 4 +- channeldb/forwarding_package.go | 44 +++++----- channeldb/forwarding_package_test.go | 50 ++++++------ channeldb/graph.go | 116 +++++++++++++-------------- channeldb/graph_test.go | 10 +-- channeldb/invoices.go | 24 +++--- channeldb/meta.go | 16 ++-- channeldb/meta_test.go | 24 +++--- channeldb/migrations.go | 14 ++-- channeldb/migrations_test.go | 6 +- channeldb/nodes.go | 14 ++-- channeldb/payments.go | 16 ++-- channeldb/waitingproof.go | 8 +- channeldb/witness_cache.go | 8 +- contractcourt/briefcase.go | 34 ++++---- contractcourt/briefcase_test.go | 4 +- discovery/gossiper.go | 6 +- fundingmanager.go | 6 +- htlcswitch/circuit_map.go | 12 +-- htlcswitch/control_tower.go | 6 +- htlcswitch/decayedlog.go | 16 ++-- htlcswitch/link_test.go | 12 +-- htlcswitch/sequencer.go | 4 +- htlcswitch/switch.go | 4 +- htlcswitch/test_utils.go | 4 +- lnwallet/interface_test.go | 2 +- macaroons/service.go | 7 +- macaroons/service_test.go | 4 +- macaroons/store.go | 12 +-- macaroons/store_test.go | 8 +- nursery_store.go | 86 ++++++++++---------- routing/missioncontrol.go | 2 +- routing/pathfind.go | 8 +- routing/router.go | 4 +- rpcserver.go | 10 +-- server.go | 2 +- 41 files changed, 404 insertions(+), 405 deletions(-) diff --git a/autopilot/graph.go b/autopilot/graph.go index 6940747d..4fbd0296 100644 --- a/autopilot/graph.go +++ b/autopilot/graph.go @@ -49,7 +49,7 @@ func ChannelGraphFromDatabase(db *channeldb.ChannelGraph) ChannelGraph { // channeldb.LightningNode. The wrapper method implement the autopilot.Node // interface. type dbNode struct { - tx *bolt.Tx + tx *bbolt.Tx node *channeldb.LightningNode } @@ -82,7 +82,7 @@ func (d dbNode) Addrs() []net.Addr { // // NOTE: Part of the autopilot.Node interface. func (d dbNode) ForEachChannel(cb func(ChannelEdge) error) error { - return d.node.ForEachChannel(d.tx, func(tx *bolt.Tx, + return d.node.ForEachChannel(d.tx, func(tx *bbolt.Tx, ei *channeldb.ChannelEdgeInfo, ep, _ *channeldb.ChannelEdgePolicy) error { // Skip channels for which no outgoing edge policy is available. @@ -119,7 +119,7 @@ func (d dbNode) ForEachChannel(cb func(ChannelEdge) error) error { // // NOTE: Part of the autopilot.ChannelGraph interface. func (d *databaseChannelGraph) ForEachNode(cb func(Node) error) error { - return d.db.ForEachNode(nil, func(tx *bolt.Tx, n *channeldb.LightningNode) error { + return d.db.ForEachNode(nil, func(tx *bbolt.Tx, n *channeldb.LightningNode) error { // We'll skip over any node that doesn't have any advertised // addresses. As we won't be able to reach them to actually diff --git a/breacharbiter.go b/breacharbiter.go index 3a68220b..c7786791 100644 --- a/breacharbiter.go +++ b/breacharbiter.go @@ -1152,7 +1152,7 @@ func newRetributionStore(db *channeldb.DB) *retributionStore { // Add adds a retribution state to the retributionStore, which is then persisted // to disk. func (rs *retributionStore) Add(ret *retributionInfo) error { - return rs.db.Update(func(tx *bolt.Tx) error { + return rs.db.Update(func(tx *bbolt.Tx) error { // If this is our first contract breach, the retributionBucket // won't exist, in which case, we just create a new bucket. retBucket, err := tx.CreateBucketIfNotExists(retributionBucket) @@ -1179,7 +1179,7 @@ func (rs *retributionStore) Add(ret *retributionInfo) error { // startup and re-register for confirmation notifications. func (rs *retributionStore) Finalize(chanPoint *wire.OutPoint, finalTx *wire.MsgTx) error { - return rs.db.Update(func(tx *bolt.Tx) error { + return rs.db.Update(func(tx *bbolt.Tx) error { justiceBkt, err := tx.CreateBucketIfNotExists(justiceTxnBucket) if err != nil { return err @@ -1206,7 +1206,7 @@ func (rs *retributionStore) GetFinalizedTxn( chanPoint *wire.OutPoint) (*wire.MsgTx, error) { var finalTxBytes []byte - if err := rs.db.View(func(tx *bolt.Tx) error { + if err := rs.db.View(func(tx *bbolt.Tx) error { justiceBkt := tx.Bucket(justiceTxnBucket) if justiceBkt == nil { return nil @@ -1240,7 +1240,7 @@ func (rs *retributionStore) GetFinalizedTxn( // that has already been breached. func (rs *retributionStore) IsBreached(chanPoint *wire.OutPoint) (bool, error) { var found bool - err := rs.db.View(func(tx *bolt.Tx) error { + err := rs.db.View(func(tx *bbolt.Tx) error { retBucket := tx.Bucket(retributionBucket) if retBucket == nil { return nil @@ -1265,7 +1265,7 @@ func (rs *retributionStore) IsBreached(chanPoint *wire.OutPoint) (bool, error) { // Remove removes a retribution state and finalized justice transaction by // channel point from the retribution store. func (rs *retributionStore) Remove(chanPoint *wire.OutPoint) error { - return rs.db.Update(func(tx *bolt.Tx) error { + return rs.db.Update(func(tx *bbolt.Tx) error { retBucket := tx.Bucket(retributionBucket) // We return an error if the bucket is not already created, @@ -1304,7 +1304,7 @@ func (rs *retributionStore) Remove(chanPoint *wire.OutPoint) error { // ForAll iterates through all stored retributions and executes the passed // callback function on each retribution. func (rs *retributionStore) ForAll(cb func(*retributionInfo) error) error { - return rs.db.View(func(tx *bolt.Tx) error { + return rs.db.View(func(tx *bbolt.Tx) error { // If the bucket does not exist, then there are no pending // retributions. retBucket := tx.Bucket(retributionBucket) diff --git a/breacharbiter_test.go b/breacharbiter_test.go index 31fc5a04..21d62658 100644 --- a/breacharbiter_test.go +++ b/breacharbiter_test.go @@ -628,36 +628,34 @@ func makeTestChannelDB() (*channeldb.DB, func(), error) { // channeldb.DB, and tests its behavior using the general RetributionStore test // suite. func TestChannelDBRetributionStore(t *testing.T) { - db, cleanUp, err := makeTestChannelDB() - if err != nil { - t.Fatalf("unable to open channeldb: %v", err) - } - defer db.Close() - defer cleanUp() - - restartDb := func() RetributionStore { - // Close and reopen channeldb - if err = db.Close(); err != nil { - t.Fatalf("unable to close channeldb during restart: %v", - err) - } - db, err = channeldb.Open(db.Path()) - if err != nil { - t.Fatalf("unable to open channeldb: %v", err) - } - - return newRetributionStore(db) - } - // Finally, instantiate retribution store and execute RetributionStore // test suite. for _, test := range retributionStoreTestSuite { t.Run( "channeldbDBRetributionStore."+test.name, func(tt *testing.T) { - if err = db.Wipe(); err != nil { - t.Fatalf("unable to wipe channeldb: %v", - err) + db, cleanUp, err := makeTestChannelDB() + if err != nil { + t.Fatalf("unable to open channeldb: %v", err) + } + defer db.Close() + defer cleanUp() + + restartDb := func() RetributionStore { + // Close and reopen channeldb + if err = db.Close(); err != nil { + t.Fatalf("unable to close "+ + "channeldb during "+ + "restart: %v", + err) + } + db, err = channeldb.Open(db.Path()) + if err != nil { + t.Fatalf("unable to open "+ + "channeldb: %v", err) + } + + return newRetributionStore(db) } frs := newFailingRetributionStore(restartDb) @@ -818,7 +816,11 @@ func testRetributionStoreRemoves( for i, retInfo := range retributions { // Snapshot number of entries before and after the removal. nbefore := countRetributions(t, frs) - if err := frs.Remove(&retInfo.chanPoint); err != nil { + err := frs.Remove(&retInfo.chanPoint) + switch { + case nbefore == 0 && err == nil: + + case nbefore > 0 && err != nil: t.Fatalf("unable to remove to retribution %v "+ "from store: %v", i, err) } diff --git a/channeldb/channel.go b/channeldb/channel.go index 5a6245b8..6a86bda2 100644 --- a/channeldb/channel.go +++ b/channeldb/channel.go @@ -495,7 +495,7 @@ func (c *OpenChannel) RefreshShortChanID() error { defer c.Unlock() var sid lnwire.ShortChannelID - err := c.Db.View(func(tx *bolt.Tx) error { + err := c.Db.View(func(tx *bbolt.Tx) error { chanBucket, err := fetchChanBucket( tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash, ) @@ -525,8 +525,8 @@ func (c *OpenChannel) RefreshShortChanID() error { // fetchChanBucket is a helper function that returns the bucket where a // channel's data resides in given: the public key for the node, the outpoint, // and the chainhash that the channel resides on. -func fetchChanBucket(tx *bolt.Tx, nodeKey *btcec.PublicKey, - outPoint *wire.OutPoint, chainHash chainhash.Hash) (*bolt.Bucket, error) { +func fetchChanBucket(tx *bbolt.Tx, nodeKey *btcec.PublicKey, + outPoint *wire.OutPoint, chainHash chainhash.Hash) (*bbolt.Bucket, error) { // First fetch the top level bucket which stores all data related to // current, active channels. @@ -567,7 +567,7 @@ func fetchChanBucket(tx *bolt.Tx, nodeKey *btcec.PublicKey, // fullSync is an internal version of the FullSync method which allows callers // to sync the contents of an OpenChannel while re-using an existing database // transaction. -func (c *OpenChannel) fullSync(tx *bolt.Tx) error { +func (c *OpenChannel) fullSync(tx *bbolt.Tx) error { // First fetch the top level bucket which stores all data related to // current, active channels. openChanBucket, err := tx.CreateBucketIfNotExists(openChannelBucket) @@ -613,7 +613,7 @@ func (c *OpenChannel) MarkAsOpen(openLoc lnwire.ShortChannelID) error { c.Lock() defer c.Unlock() - if err := c.Db.Update(func(tx *bolt.Tx) error { + if err := c.Db.Update(func(tx *bbolt.Tx) error { chanBucket, err := fetchChanBucket( tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash, ) @@ -649,7 +649,7 @@ func (c *OpenChannel) MarkDataLoss(commitPoint *btcec.PublicKey) error { defer c.Unlock() var status ChannelStatus - if err := c.Db.Update(func(tx *bolt.Tx) error { + if err := c.Db.Update(func(tx *bbolt.Tx) error { chanBucket, err := fetchChanBucket( tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash, ) @@ -693,7 +693,7 @@ func (c *OpenChannel) MarkDataLoss(commitPoint *btcec.PublicKey) error { func (c *OpenChannel) DataLossCommitPoint() (*btcec.PublicKey, error) { var commitPoint *btcec.PublicKey - err := c.Db.View(func(tx *bolt.Tx) error { + err := c.Db.View(func(tx *bbolt.Tx) error { chanBucket, err := fetchChanBucket( tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash, ) @@ -744,7 +744,7 @@ func (c *OpenChannel) MarkCommitmentBroadcasted() error { } func (c *OpenChannel) putChanStatus(status ChannelStatus) error { - if err := c.Db.Update(func(tx *bolt.Tx) error { + if err := c.Db.Update(func(tx *bbolt.Tx) error { chanBucket, err := fetchChanBucket( tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash, ) @@ -774,7 +774,7 @@ func (c *OpenChannel) putChanStatus(status ChannelStatus) error { // putChannel serializes, and stores the current state of the channel in its // entirety. -func putOpenChannel(chanBucket *bolt.Bucket, channel *OpenChannel) error { +func putOpenChannel(chanBucket *bbolt.Bucket, channel *OpenChannel) error { // First, we'll write out all the relatively static fields, that are // decided upon initial channel creation. if err := putChanInfo(chanBucket, channel); err != nil { @@ -798,7 +798,7 @@ func putOpenChannel(chanBucket *bolt.Bucket, channel *OpenChannel) error { // fetchOpenChannel retrieves, and deserializes (including decrypting // sensitive) the complete channel currently active with the passed nodeID. -func fetchOpenChannel(chanBucket *bolt.Bucket, +func fetchOpenChannel(chanBucket *bbolt.Bucket, chanPoint *wire.OutPoint) (*OpenChannel, error) { channel := &OpenChannel{ @@ -845,7 +845,7 @@ func (c *OpenChannel) SyncPending(addr net.Addr, pendingHeight uint32) error { c.FundingBroadcastHeight = pendingHeight - return c.Db.Update(func(tx *bolt.Tx) error { + return c.Db.Update(func(tx *bbolt.Tx) error { // First, sync all the persistent channel state to disk. if err := c.fullSync(tx); err != nil { return err @@ -884,7 +884,7 @@ func (c *OpenChannel) UpdateCommitment(newCommitment *ChannelCommitment) error { c.Lock() defer c.Unlock() - err := c.Db.Update(func(tx *bolt.Tx) error { + err := c.Db.Update(func(tx *bbolt.Tx) error { chanBucket, err := fetchChanBucket( tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash, ) @@ -1303,7 +1303,7 @@ func (c *OpenChannel) AppendRemoteCommitChain(diff *CommitDiff) error { c.Lock() defer c.Unlock() - return c.Db.Update(func(tx *bolt.Tx) error { + return c.Db.Update(func(tx *bbolt.Tx) error { // First, we'll grab the writable bucket where this channel's // data resides. chanBucket, err := fetchChanBucket( @@ -1353,7 +1353,7 @@ func (c *OpenChannel) AppendRemoteCommitChain(diff *CommitDiff) error { // these pointers, causing the tip and the tail to point to the same entry. func (c *OpenChannel) RemoteCommitChainTip() (*CommitDiff, error) { var cd *CommitDiff - err := c.Db.View(func(tx *bolt.Tx) error { + err := c.Db.View(func(tx *bbolt.Tx) error { chanBucket, err := fetchChanBucket( tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash, ) @@ -1399,7 +1399,7 @@ func (c *OpenChannel) InsertNextRevocation(revKey *btcec.PublicKey) error { c.RemoteNextRevocation = revKey - err := c.Db.Update(func(tx *bolt.Tx) error { + err := c.Db.Update(func(tx *bbolt.Tx) error { chanBucket, err := fetchChanBucket( tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash, ) @@ -1429,7 +1429,7 @@ func (c *OpenChannel) AdvanceCommitChainTail(fwdPkg *FwdPkg) error { var newRemoteCommit *ChannelCommitment - err := c.Db.Update(func(tx *bolt.Tx) error { + err := c.Db.Update(func(tx *bbolt.Tx) error { chanBucket, err := fetchChanBucket( tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash, ) @@ -1537,7 +1537,7 @@ func (c *OpenChannel) LoadFwdPkgs() ([]*FwdPkg, error) { defer c.RUnlock() var fwdPkgs []*FwdPkg - if err := c.Db.View(func(tx *bolt.Tx) error { + if err := c.Db.View(func(tx *bbolt.Tx) error { var err error fwdPkgs, err = c.Packager.LoadFwdPkgs(tx) return err @@ -1555,7 +1555,7 @@ func (c *OpenChannel) AckAddHtlcs(addRefs ...AddRef) error { c.Lock() defer c.Unlock() - return c.Db.Update(func(tx *bolt.Tx) error { + return c.Db.Update(func(tx *bbolt.Tx) error { return c.Packager.AckAddHtlcs(tx, addRefs...) }) } @@ -1568,7 +1568,7 @@ func (c *OpenChannel) AckSettleFails(settleFailRefs ...SettleFailRef) error { c.Lock() defer c.Unlock() - return c.Db.Update(func(tx *bolt.Tx) error { + return c.Db.Update(func(tx *bbolt.Tx) error { return c.Packager.AckSettleFails(tx, settleFailRefs...) }) } @@ -1579,7 +1579,7 @@ func (c *OpenChannel) SetFwdFilter(height uint64, fwdFilter *PkgFilter) error { c.Lock() defer c.Unlock() - return c.Db.Update(func(tx *bolt.Tx) error { + return c.Db.Update(func(tx *bbolt.Tx) error { return c.Packager.SetFwdFilter(tx, height, fwdFilter) }) } @@ -1592,7 +1592,7 @@ func (c *OpenChannel) RemoveFwdPkg(height uint64) error { c.Lock() defer c.Unlock() - return c.Db.Update(func(tx *bolt.Tx) error { + return c.Db.Update(func(tx *bbolt.Tx) error { return c.Packager.RemovePkg(tx, height) }) } @@ -1612,7 +1612,7 @@ func (c *OpenChannel) RevocationLogTail() (*ChannelCommitment, error) { } var commit ChannelCommitment - if err := c.Db.View(func(tx *bolt.Tx) error { + if err := c.Db.View(func(tx *bbolt.Tx) error { chanBucket, err := fetchChanBucket( tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash, ) @@ -1659,7 +1659,7 @@ func (c *OpenChannel) CommitmentHeight() (uint64, error) { defer c.RUnlock() var height uint64 - err := c.Db.View(func(tx *bolt.Tx) error { + err := c.Db.View(func(tx *bbolt.Tx) error { // Get the bucket dedicated to storing the metadata for open // channels. chanBucket, err := fetchChanBucket( @@ -1694,7 +1694,7 @@ func (c *OpenChannel) FindPreviousState(updateNum uint64) (*ChannelCommitment, e defer c.RUnlock() var commit ChannelCommitment - err := c.Db.View(func(tx *bolt.Tx) error { + err := c.Db.View(func(tx *bbolt.Tx) error { chanBucket, err := fetchChanBucket( tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash, ) @@ -1848,7 +1848,7 @@ func (c *OpenChannel) CloseChannel(summary *ChannelCloseSummary) error { c.Lock() defer c.Unlock() - return c.Db.Update(func(tx *bolt.Tx) error { + return c.Db.Update(func(tx *bbolt.Tx) error { openChanBucket := tx.Bucket(openChannelBucket) if openChanBucket == nil { return ErrNoChanDBExists @@ -1992,7 +1992,7 @@ func (c *OpenChannel) Snapshot() *ChannelSnapshot { // latest fully committed state is returned. The first commitment returned is // the local commitment, and the second returned is the remote commitment. func (c *OpenChannel) LatestCommitments() (*ChannelCommitment, *ChannelCommitment, error) { - err := c.Db.View(func(tx *bolt.Tx) error { + err := c.Db.View(func(tx *bbolt.Tx) error { chanBucket, err := fetchChanBucket( tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash, ) @@ -2014,7 +2014,7 @@ func (c *OpenChannel) LatestCommitments() (*ChannelCommitment, *ChannelCommitmen // acting on a possible contract breach to ensure, that the caller has the most // up to date information required to deliver justice. func (c *OpenChannel) RemoteRevocationStore() (shachain.Store, error) { - err := c.Db.View(func(tx *bolt.Tx) error { + err := c.Db.View(func(tx *bbolt.Tx) error { chanBucket, err := fetchChanBucket( tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash, ) @@ -2031,7 +2031,7 @@ func (c *OpenChannel) RemoteRevocationStore() (shachain.Store, error) { return c.RevocationStore, nil } -func putChannelCloseSummary(tx *bolt.Tx, chanID []byte, +func putChannelCloseSummary(tx *bbolt.Tx, chanID []byte, summary *ChannelCloseSummary, lastChanState *OpenChannel) error { closedChanBucket, err := tx.CreateBucketIfNotExists(closedChannelBucket) @@ -2110,7 +2110,7 @@ func serializeChannelCloseSummary(w io.Writer, cs *ChannelCloseSummary) error { return nil } -func fetchChannelCloseSummary(tx *bolt.Tx, +func fetchChannelCloseSummary(tx *bbolt.Tx, chanID []byte) (*ChannelCloseSummary, error) { closedChanBucket, err := tx.CreateBucketIfNotExists(closedChannelBucket) @@ -2217,7 +2217,7 @@ func writeChanConfig(b io.Writer, c *ChannelConfig) error { ) } -func putChanInfo(chanBucket *bolt.Bucket, channel *OpenChannel) error { +func putChanInfo(chanBucket *bbolt.Bucket, channel *OpenChannel) error { var w bytes.Buffer if err := WriteElements(&w, channel.ChanType, channel.ChainHash, channel.FundingOutpoint, @@ -2260,7 +2260,7 @@ func serializeChanCommit(w io.Writer, c *ChannelCommitment) error { return SerializeHtlcs(w, c.Htlcs...) } -func putChanCommitment(chanBucket *bolt.Bucket, c *ChannelCommitment, +func putChanCommitment(chanBucket *bbolt.Bucket, c *ChannelCommitment, local bool) error { var commitKey []byte @@ -2278,7 +2278,7 @@ func putChanCommitment(chanBucket *bolt.Bucket, c *ChannelCommitment, return chanBucket.Put(commitKey, b.Bytes()) } -func putChanCommitments(chanBucket *bolt.Bucket, channel *OpenChannel) error { +func putChanCommitments(chanBucket *bbolt.Bucket, channel *OpenChannel) error { err := putChanCommitment(chanBucket, &channel.LocalCommitment, true) if err != nil { return err @@ -2287,7 +2287,7 @@ func putChanCommitments(chanBucket *bolt.Bucket, channel *OpenChannel) error { return putChanCommitment(chanBucket, &channel.RemoteCommitment, false) } -func putChanRevocationState(chanBucket *bolt.Bucket, channel *OpenChannel) error { +func putChanRevocationState(chanBucket *bbolt.Bucket, channel *OpenChannel) error { var b bytes.Buffer err := WriteElements( @@ -2322,7 +2322,7 @@ func readChanConfig(b io.Reader, c *ChannelConfig) error { ) } -func fetchChanInfo(chanBucket *bolt.Bucket, channel *OpenChannel) error { +func fetchChanInfo(chanBucket *bbolt.Bucket, channel *OpenChannel) error { infoBytes := chanBucket.Get(chanInfoKey) if infoBytes == nil { return ErrNoChanInfoFound @@ -2379,7 +2379,7 @@ func deserializeChanCommit(r io.Reader) (ChannelCommitment, error) { return c, nil } -func fetchChanCommitment(chanBucket *bolt.Bucket, local bool) (ChannelCommitment, error) { +func fetchChanCommitment(chanBucket *bbolt.Bucket, local bool) (ChannelCommitment, error) { var commitKey []byte if local { commitKey = append(chanCommitmentKey, byte(0x00)) @@ -2396,7 +2396,7 @@ func fetchChanCommitment(chanBucket *bolt.Bucket, local bool) (ChannelCommitment return deserializeChanCommit(r) } -func fetchChanCommitments(chanBucket *bolt.Bucket, channel *OpenChannel) error { +func fetchChanCommitments(chanBucket *bbolt.Bucket, channel *OpenChannel) error { var err error channel.LocalCommitment, err = fetchChanCommitment(chanBucket, true) @@ -2411,7 +2411,7 @@ func fetchChanCommitments(chanBucket *bolt.Bucket, channel *OpenChannel) error { return nil } -func fetchChanRevocationState(chanBucket *bolt.Bucket, channel *OpenChannel) error { +func fetchChanRevocationState(chanBucket *bbolt.Bucket, channel *OpenChannel) error { revBytes := chanBucket.Get(revocationStateKey) if revBytes == nil { return ErrNoRevocationsFound @@ -2437,7 +2437,7 @@ func fetchChanRevocationState(chanBucket *bolt.Bucket, channel *OpenChannel) err return ReadElements(r, &channel.RemoteNextRevocation) } -func deleteOpenChannel(chanBucket *bolt.Bucket, chanPointBytes []byte) error { +func deleteOpenChannel(chanBucket *bbolt.Bucket, chanPointBytes []byte) error { if err := chanBucket.Delete(chanInfoKey); err != nil { return err @@ -2478,7 +2478,7 @@ func readLogKey(b []byte) uint64 { return byteOrder.Uint64(b) } -func appendChannelLogEntry(log *bolt.Bucket, +func appendChannelLogEntry(log *bbolt.Bucket, commit *ChannelCommitment) error { var b bytes.Buffer @@ -2490,7 +2490,7 @@ func appendChannelLogEntry(log *bolt.Bucket, return log.Put(logEntrykey[:], b.Bytes()) } -func fetchChannelLogEntry(log *bolt.Bucket, +func fetchChannelLogEntry(log *bbolt.Bucket, updateNum uint64) (ChannelCommitment, error) { logEntrykey := makeLogKey(updateNum) @@ -2503,7 +2503,7 @@ func fetchChannelLogEntry(log *bolt.Bucket, return deserializeChanCommit(commitReader) } -func wipeChannelLogEntries(log *bolt.Bucket) error { +func wipeChannelLogEntries(log *bbolt.Bucket) error { // TODO(roasbeef): comment logCursor := log.Cursor() diff --git a/channeldb/db.go b/channeldb/db.go index e36dcf84..0f918318 100644 --- a/channeldb/db.go +++ b/channeldb/db.go @@ -23,7 +23,7 @@ const ( // migration is a function which takes a prior outdated version of the database // instances and mutates the key/bucket structure to arrive at a more // up-to-date version of the database. -type migration func(tx *bolt.Tx) error +type migration func(tx *bbolt.Tx) error type version struct { number uint32 @@ -103,7 +103,7 @@ var bufPool = &sync.Pool{ // information related to nodes, routing data, open/closed channels, fee // schedules, and reputation data. type DB struct { - *bolt.DB + *bbolt.DB dbPath string } @@ -118,7 +118,7 @@ func Open(dbPath string) (*DB, error) { } } - bdb, err := bolt.Open(path, dbFilePermission, nil) + bdb, err := bbolt.Open(path, dbFilePermission, nil) if err != nil { return nil, err } @@ -146,41 +146,41 @@ func (d *DB) Path() string { // database. The deletion is done in a single transaction, therefore this // operation is fully atomic. func (d *DB) Wipe() error { - return d.Update(func(tx *bolt.Tx) error { + return d.Update(func(tx *bbolt.Tx) error { err := tx.DeleteBucket(openChannelBucket) - if err != nil && err != bolt.ErrBucketNotFound { + if err != nil && err != bbolt.ErrBucketNotFound { return err } err = tx.DeleteBucket(closedChannelBucket) - if err != nil && err != bolt.ErrBucketNotFound { + if err != nil && err != bbolt.ErrBucketNotFound { return err } err = tx.DeleteBucket(invoiceBucket) - if err != nil && err != bolt.ErrBucketNotFound { + if err != nil && err != bbolt.ErrBucketNotFound { return err } err = tx.DeleteBucket(nodeInfoBucket) - if err != nil && err != bolt.ErrBucketNotFound { + if err != nil && err != bbolt.ErrBucketNotFound { return err } err = tx.DeleteBucket(nodeBucket) - if err != nil && err != bolt.ErrBucketNotFound { + if err != nil && err != bbolt.ErrBucketNotFound { return err } err = tx.DeleteBucket(edgeBucket) - if err != nil && err != bolt.ErrBucketNotFound { + if err != nil && err != bbolt.ErrBucketNotFound { return err } err = tx.DeleteBucket(edgeIndexBucket) - if err != nil && err != bolt.ErrBucketNotFound { + if err != nil && err != bbolt.ErrBucketNotFound { return err } err = tx.DeleteBucket(graphMetaBucket) - if err != nil && err != bolt.ErrBucketNotFound { + if err != nil && err != bbolt.ErrBucketNotFound { return err } @@ -200,12 +200,12 @@ func createChannelDB(dbPath string) error { } path := filepath.Join(dbPath, dbName) - bdb, err := bolt.Open(path, dbFilePermission, nil) + bdb, err := bbolt.Open(path, dbFilePermission, nil) if err != nil { return err } - err = bdb.Update(func(tx *bolt.Tx) error { + err = bdb.Update(func(tx *bbolt.Tx) error { if _, err := tx.CreateBucket(openChannelBucket); err != nil { return err } @@ -302,7 +302,7 @@ func fileExists(path string) bool { // zero-length slice is returned. func (d *DB) FetchOpenChannels(nodeID *btcec.PublicKey) ([]*OpenChannel, error) { var channels []*OpenChannel - err := d.View(func(tx *bolt.Tx) error { + err := d.View(func(tx *bbolt.Tx) error { var err error channels, err = d.fetchOpenChannels(tx, nodeID) return err @@ -315,7 +315,7 @@ func (d *DB) FetchOpenChannels(nodeID *btcec.PublicKey) ([]*OpenChannel, error) // stored currently active/open channels associated with the target nodeID. In // the case that no active channels are known to have been created with this // node, then a zero-length slice is returned. -func (d *DB) fetchOpenChannels(tx *bolt.Tx, +func (d *DB) fetchOpenChannels(tx *bbolt.Tx, nodeID *btcec.PublicKey) ([]*OpenChannel, error) { // Get the bucket dedicated to storing the metadata for open channels. @@ -368,7 +368,7 @@ func (d *DB) fetchOpenChannels(tx *bolt.Tx, // fetchNodeChannels retrieves all active channels from the target chainBucket // which is under a node's dedicated channel bucket. This function is typically // used to fetch all the active channels related to a particular node. -func (d *DB) fetchNodeChannels(chainBucket *bolt.Bucket) ([]*OpenChannel, error) { +func (d *DB) fetchNodeChannels(chainBucket *bbolt.Bucket) ([]*OpenChannel, error) { var channels []*OpenChannel @@ -464,7 +464,7 @@ func (d *DB) FetchWaitingCloseChannels() ([]*OpenChannel, error) { func fetchChannels(d *DB, pending, waitingClose bool) ([]*OpenChannel, error) { var channels []*OpenChannel - err := d.View(func(tx *bolt.Tx) error { + err := d.View(func(tx *bbolt.Tx) error { // Get the bucket dedicated to storing the metadata for open // channels. openChanBucket := tx.Bucket(openChannelBucket) @@ -551,7 +551,7 @@ func fetchChannels(d *DB, pending, waitingClose bool) ([]*OpenChannel, error) { func (d *DB) FetchClosedChannels(pendingOnly bool) ([]*ChannelCloseSummary, error) { var chanSummaries []*ChannelCloseSummary - if err := d.View(func(tx *bolt.Tx) error { + if err := d.View(func(tx *bbolt.Tx) error { closeBucket := tx.Bucket(closedChannelBucket) if closeBucket == nil { return ErrNoClosedChannels @@ -589,7 +589,7 @@ var ErrClosedChannelNotFound = errors.New("unable to find closed channel summary // point of the channel in question. func (d *DB) FetchClosedChannel(chanID *wire.OutPoint) (*ChannelCloseSummary, error) { var chanSummary *ChannelCloseSummary - if err := d.View(func(tx *bolt.Tx) error { + if err := d.View(func(tx *bbolt.Tx) error { closeBucket := tx.Bucket(closedChannelBucket) if closeBucket == nil { return ErrClosedChannelNotFound @@ -623,7 +623,7 @@ func (d *DB) FetchClosedChannelForID(cid lnwire.ChannelID) ( *ChannelCloseSummary, error) { var chanSummary *ChannelCloseSummary - if err := d.View(func(tx *bolt.Tx) error { + if err := d.View(func(tx *bbolt.Tx) error { closeBucket := tx.Bucket(closedChannelBucket) if closeBucket == nil { return ErrClosedChannelNotFound @@ -671,7 +671,7 @@ func (d *DB) FetchClosedChannelForID(cid lnwire.ChannelID) ( // the pending funds in a channel that has been forcibly closed have been // swept. func (d *DB) MarkChanFullyClosed(chanPoint *wire.OutPoint) error { - return d.Update(func(tx *bolt.Tx) error { + return d.Update(func(tx *bbolt.Tx) error { var b bytes.Buffer if err := writeOutpoint(&b, chanPoint); err != nil { return err @@ -724,7 +724,7 @@ func (d *DB) MarkChanFullyClosed(chanPoint *wire.OutPoint) error { // pruneLinkNode determines whether we should garbage collect a link node from // the database due to no longer having any open channels with it. If there are // any left, then this acts as a no-op. -func (d *DB) pruneLinkNode(tx *bolt.Tx, remotePub *btcec.PublicKey) error { +func (d *DB) pruneLinkNode(tx *bbolt.Tx, remotePub *btcec.PublicKey) error { openChannels, err := d.fetchOpenChannels(tx, remotePub) if err != nil { return fmt.Errorf("unable to fetch open channels for peer %x: "+ @@ -744,7 +744,7 @@ func (d *DB) pruneLinkNode(tx *bolt.Tx, remotePub *btcec.PublicKey) error { // PruneLinkNodes attempts to prune all link nodes found within the databse with // whom we no longer have any open channels with. func (d *DB) PruneLinkNodes() error { - return d.Update(func(tx *bolt.Tx) error { + return d.Update(func(tx *bbolt.Tx) error { linkNodes, err := d.fetchAllLinkNodes(tx) if err != nil { return err @@ -803,7 +803,7 @@ func (d *DB) syncVersions(versions []version) error { migrations, migrationVersions := getMigrationsToApply( versions, meta.DbVersionNumber, ) - return d.Update(func(tx *bolt.Tx) error { + return d.Update(func(tx *bbolt.Tx) error { for i, migration := range migrations { if migration == nil { continue diff --git a/channeldb/forwarding_log.go b/channeldb/forwarding_log.go index b444e32c..04e8719a 100644 --- a/channeldb/forwarding_log.go +++ b/channeldb/forwarding_log.go @@ -111,7 +111,7 @@ func (f *ForwardingLog) AddForwardingEvents(events []ForwardingEvent) error { var timestamp [8]byte - return f.db.Batch(func(tx *bolt.Tx) error { + return f.db.Batch(func(tx *bbolt.Tx) error { // First, we'll fetch the bucket that stores our time series // log. logBucket, err := tx.CreateBucketIfNotExists( @@ -204,7 +204,7 @@ func (f *ForwardingLog) Query(q ForwardingEventQuery) (ForwardingLogTimeSlice, e recordsToSkip := q.IndexOffset recordOffset := q.IndexOffset - err := f.db.View(func(tx *bolt.Tx) error { + err := f.db.View(func(tx *bbolt.Tx) error { // If the bucket wasn't found, then there aren't any events to // be returned. logBucket := tx.Bucket(forwardingLogBucket) diff --git a/channeldb/forwarding_package.go b/channeldb/forwarding_package.go index 5817fc21..a4de4e26 100644 --- a/channeldb/forwarding_package.go +++ b/channeldb/forwarding_package.go @@ -318,7 +318,7 @@ type SettleFailRef struct { type SettleFailAcker interface { // AckSettleFails atomically updates the settle-fail filters in *other* // channels' forwarding packages. - AckSettleFails(tx *bolt.Tx, settleFailRefs ...SettleFailRef) error + AckSettleFails(tx *bbolt.Tx, settleFailRefs ...SettleFailRef) error } // GlobalFwdPkgReader is an interface used to retrieve the forwarding packages @@ -326,7 +326,7 @@ type SettleFailAcker interface { type GlobalFwdPkgReader interface { // LoadChannelFwdPkgs loads all known forwarding packages for the given // channel. - LoadChannelFwdPkgs(tx *bolt.Tx, + LoadChannelFwdPkgs(tx *bbolt.Tx, source lnwire.ShortChannelID) ([]*FwdPkg, error) } @@ -357,14 +357,14 @@ func NewSwitchPackager() *SwitchPackager { // AckSettleFails atomically updates the settle-fail filters in *other* // channels' forwarding packages, to mark that the switch has received a settle // or fail residing in the forwarding package of a link. -func (*SwitchPackager) AckSettleFails(tx *bolt.Tx, +func (*SwitchPackager) AckSettleFails(tx *bbolt.Tx, settleFailRefs ...SettleFailRef) error { return ackSettleFails(tx, settleFailRefs) } // LoadChannelFwdPkgs loads all forwarding packages for a particular channel. -func (*SwitchPackager) LoadChannelFwdPkgs(tx *bolt.Tx, +func (*SwitchPackager) LoadChannelFwdPkgs(tx *bbolt.Tx, source lnwire.ShortChannelID) ([]*FwdPkg, error) { return loadChannelFwdPkgs(tx, source) @@ -376,19 +376,19 @@ func (*SwitchPackager) LoadChannelFwdPkgs(tx *bolt.Tx, type FwdPackager interface { // AddFwdPkg serializes and writes a FwdPkg for this channel at the // remote commitment height included in the forwarding package. - AddFwdPkg(tx *bolt.Tx, fwdPkg *FwdPkg) error + AddFwdPkg(tx *bbolt.Tx, fwdPkg *FwdPkg) error // SetFwdFilter looks up the forwarding package at the remote `height` // and sets the `fwdFilter`, marking the Adds for which: // 1) We are not the exit node // 2) Passed all validation // 3) Should be forwarded to the switch immediately after a failure - SetFwdFilter(tx *bolt.Tx, height uint64, fwdFilter *PkgFilter) error + SetFwdFilter(tx *bbolt.Tx, height uint64, fwdFilter *PkgFilter) error // AckAddHtlcs atomically updates the add filters in this channel's // forwarding packages to mark the resolution of an Add that was // received from the remote party. - AckAddHtlcs(tx *bolt.Tx, addRefs ...AddRef) error + AckAddHtlcs(tx *bbolt.Tx, addRefs ...AddRef) error // SettleFailAcker allows a link to acknowledge settle/fail HTLCs // belonging to other channels. @@ -396,11 +396,11 @@ type FwdPackager interface { // LoadFwdPkgs loads all known forwarding packages owned by this // channel. - LoadFwdPkgs(tx *bolt.Tx) ([]*FwdPkg, error) + LoadFwdPkgs(tx *bbolt.Tx) ([]*FwdPkg, error) // RemovePkg deletes a forwarding package owned by this channel at // the provided remote `height`. - RemovePkg(tx *bolt.Tx, height uint64) error + RemovePkg(tx *bbolt.Tx, height uint64) error } // ChannelPackager is used by a channel to manage the lifecycle of its forwarding @@ -420,7 +420,7 @@ func NewChannelPackager(source lnwire.ShortChannelID) *ChannelPackager { } // AddFwdPkg writes a newly locked in forwarding package to disk. -func (*ChannelPackager) AddFwdPkg(tx *bolt.Tx, fwdPkg *FwdPkg) error { +func (*ChannelPackager) AddFwdPkg(tx *bbolt.Tx, fwdPkg *FwdPkg) error { fwdPkgBkt, err := tx.CreateBucketIfNotExists(fwdPackagesKey) if err != nil { return err @@ -485,7 +485,7 @@ func (*ChannelPackager) AddFwdPkg(tx *bolt.Tx, fwdPkg *FwdPkg) error { } // putLogUpdate writes an htlc to the provided `bkt`, using `index` as the key. -func putLogUpdate(bkt *bolt.Bucket, idx uint16, htlc *LogUpdate) error { +func putLogUpdate(bkt *bbolt.Bucket, idx uint16, htlc *LogUpdate) error { var b bytes.Buffer if err := htlc.Encode(&b); err != nil { return err @@ -497,12 +497,12 @@ func putLogUpdate(bkt *bolt.Bucket, idx uint16, htlc *LogUpdate) error { // LoadFwdPkgs scans the forwarding log for any packages that haven't been // processed, and returns their deserialized log updates in a map indexed by the // remote commitment height at which the updates were locked in. -func (p *ChannelPackager) LoadFwdPkgs(tx *bolt.Tx) ([]*FwdPkg, error) { +func (p *ChannelPackager) LoadFwdPkgs(tx *bbolt.Tx) ([]*FwdPkg, error) { return loadChannelFwdPkgs(tx, p.source) } // loadChannelFwdPkgs loads all forwarding packages owned by `source`. -func loadChannelFwdPkgs(tx *bolt.Tx, source lnwire.ShortChannelID) ([]*FwdPkg, error) { +func loadChannelFwdPkgs(tx *bbolt.Tx, source lnwire.ShortChannelID) ([]*FwdPkg, error) { fwdPkgBkt := tx.Bucket(fwdPackagesKey) if fwdPkgBkt == nil { return nil, nil @@ -543,7 +543,7 @@ func loadChannelFwdPkgs(tx *bolt.Tx, source lnwire.ShortChannelID) ([]*FwdPkg, e // loadFwPkg reads the packager's fwd pkg at a given height, and determines the // appropriate FwdState. -func loadFwdPkg(fwdPkgBkt *bolt.Bucket, source lnwire.ShortChannelID, +func loadFwdPkg(fwdPkgBkt *bbolt.Bucket, source lnwire.ShortChannelID, height uint64) (*FwdPkg, error) { sourceKey := makeLogKey(source.ToUint64()) @@ -649,7 +649,7 @@ func loadFwdPkg(fwdPkgBkt *bolt.Bucket, source lnwire.ShortChannelID, // loadHtlcs retrieves all serialized htlcs in a bucket, returning // them in order of the indexes they were written under. -func loadHtlcs(bkt *bolt.Bucket) ([]LogUpdate, error) { +func loadHtlcs(bkt *bbolt.Bucket) ([]LogUpdate, error) { var htlcs []LogUpdate if err := bkt.ForEach(func(_, v []byte) error { var htlc LogUpdate @@ -674,7 +674,7 @@ func loadHtlcs(bkt *bolt.Bucket) ([]LogUpdate, error) { // leaving this channel. After a restart, we skip validation of these Adds, // since they are assumed to have already been validated, and make the switch or // outgoing link responsible for handling replays. -func (p *ChannelPackager) SetFwdFilter(tx *bolt.Tx, height uint64, +func (p *ChannelPackager) SetFwdFilter(tx *bbolt.Tx, height uint64, fwdFilter *PkgFilter) error { fwdPkgBkt := tx.Bucket(fwdPackagesKey) @@ -713,7 +713,7 @@ func (p *ChannelPackager) SetFwdFilter(tx *bolt.Tx, height uint64, // AckAddHtlcs accepts a list of references to add htlcs, and updates the // AckAddFilter of those forwarding packages to indicate that a settle or fail // has been received in response to the add. -func (p *ChannelPackager) AckAddHtlcs(tx *bolt.Tx, addRefs ...AddRef) error { +func (p *ChannelPackager) AckAddHtlcs(tx *bbolt.Tx, addRefs ...AddRef) error { if len(addRefs) == 0 { return nil } @@ -753,7 +753,7 @@ func (p *ChannelPackager) AckAddHtlcs(tx *bolt.Tx, addRefs ...AddRef) error { // ackAddHtlcsAtHeight updates the AddAckFilter of a single forwarding package // with a list of indexes, writing the resulting filter back in its place. -func ackAddHtlcsAtHeight(sourceBkt *bolt.Bucket, height uint64, +func ackAddHtlcsAtHeight(sourceBkt *bbolt.Bucket, height uint64, indexes []uint16) error { heightKey := makeLogKey(height) @@ -796,12 +796,12 @@ func ackAddHtlcsAtHeight(sourceBkt *bolt.Bucket, height uint64, // package. This should only be called after the source of the Add has locked in // the settle/fail, or it becomes otherwise safe to forgo retransmitting the // settle/fail after a restart. -func (p *ChannelPackager) AckSettleFails(tx *bolt.Tx, settleFailRefs ...SettleFailRef) error { +func (p *ChannelPackager) AckSettleFails(tx *bbolt.Tx, settleFailRefs ...SettleFailRef) error { return ackSettleFails(tx, settleFailRefs) } // ackSettleFails persistently acknowledges a batch of settle fail references. -func ackSettleFails(tx *bolt.Tx, settleFailRefs []SettleFailRef) error { +func ackSettleFails(tx *bbolt.Tx, settleFailRefs []SettleFailRef) error { if len(settleFailRefs) == 0 { return nil } @@ -855,7 +855,7 @@ func ackSettleFails(tx *bolt.Tx, settleFailRefs []SettleFailRef) error { // ackSettleFailsAtHeight given a destination bucket, acks the provided indexes // at particular a height by updating the settle fail filter. -func ackSettleFailsAtHeight(destBkt *bolt.Bucket, height uint64, +func ackSettleFailsAtHeight(destBkt *bbolt.Bucket, height uint64, indexes []uint16) error { heightKey := makeLogKey(height) @@ -895,7 +895,7 @@ func ackSettleFailsAtHeight(destBkt *bolt.Bucket, height uint64, // RemovePkg deletes the forwarding package at the given height from the // packager's source bucket. -func (p *ChannelPackager) RemovePkg(tx *bolt.Tx, height uint64) error { +func (p *ChannelPackager) RemovePkg(tx *bbolt.Tx, height uint64) error { fwdPkgBkt := tx.Bucket(fwdPackagesKey) if fwdPkgBkt == nil { return nil diff --git a/channeldb/forwarding_package_test.go b/channeldb/forwarding_package_test.go index 83120745..85fda950 100644 --- a/channeldb/forwarding_package_test.go +++ b/channeldb/forwarding_package_test.go @@ -207,7 +207,7 @@ func TestPackagerEmptyFwdPkg(t *testing.T) { // Next, create and write a new forwarding package with no htlcs. fwdPkg := channeldb.NewFwdPkg(shortChanID, 0, nil, nil) - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.AddFwdPkg(tx, fwdPkg) }); err != nil { t.Fatalf("unable to add fwd pkg: %v", err) @@ -226,7 +226,7 @@ func TestPackagerEmptyFwdPkg(t *testing.T) { // Now, write the forwarding decision. In this case, its just an empty // fwd filter. - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.SetFwdFilter(tx, fwdPkg.Height, fwdPkg.FwdFilter) }); err != nil { t.Fatalf("unable to set fwdfiter: %v", err) @@ -244,7 +244,7 @@ func TestPackagerEmptyFwdPkg(t *testing.T) { assertAckFilterIsFull(t, fwdPkgs[0], true) // Lastly, remove the completed forwarding package from disk. - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.RemovePkg(tx, fwdPkg.Height) }); err != nil { t.Fatalf("unable to remove fwdpkg: %v", err) @@ -279,7 +279,7 @@ func TestPackagerOnlyAdds(t *testing.T) { nAdds := len(adds) - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.AddFwdPkg(tx, fwdPkg) }); err != nil { t.Fatalf("unable to add fwd pkg: %v", err) @@ -300,7 +300,7 @@ func TestPackagerOnlyAdds(t *testing.T) { // added any adds to the fwdfilter, this would indicate that all of the // adds were 1) settled locally by this link (exit hop), or 2) the htlc // was failed locally. - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.SetFwdFilter(tx, fwdPkg.Height, fwdPkg.FwdFilter) }); err != nil { t.Fatalf("unable to set fwdfiter: %v", err) @@ -324,7 +324,7 @@ func TestPackagerOnlyAdds(t *testing.T) { Index: uint16(i), } - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.AckAddHtlcs(tx, addRef) }); err != nil { t.Fatalf("unable to ack add htlc: %v", err) @@ -343,7 +343,7 @@ func TestPackagerOnlyAdds(t *testing.T) { assertAckFilterIsFull(t, fwdPkgs[0], true) // Lastly, remove the completed forwarding package from disk. - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.RemovePkg(tx, fwdPkg.Height) }); err != nil { t.Fatalf("unable to remove fwdpkg: %v", err) @@ -381,7 +381,7 @@ func TestPackagerOnlySettleFails(t *testing.T) { nSettleFails := len(settleFails) - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.AddFwdPkg(tx, fwdPkg) }); err != nil { t.Fatalf("unable to add fwd pkg: %v", err) @@ -402,7 +402,7 @@ func TestPackagerOnlySettleFails(t *testing.T) { // added any adds to the fwdfilter, this would indicate that all of the // adds were 1) settled locally by this link (exit hop), or 2) the htlc // was failed locally. - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.SetFwdFilter(tx, fwdPkg.Height, fwdPkg.FwdFilter) }); err != nil { t.Fatalf("unable to set fwdfiter: %v", err) @@ -428,7 +428,7 @@ func TestPackagerOnlySettleFails(t *testing.T) { Index: uint16(i), } - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.AckSettleFails(tx, failSettleRef) }); err != nil { t.Fatalf("unable to ack add htlc: %v", err) @@ -448,7 +448,7 @@ func TestPackagerOnlySettleFails(t *testing.T) { assertAckFilterIsFull(t, fwdPkgs[0], true) // Lastly, remove the completed forwarding package from disk. - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.RemovePkg(tx, fwdPkg.Height) }); err != nil { t.Fatalf("unable to remove fwdpkg: %v", err) @@ -486,7 +486,7 @@ func TestPackagerAddsThenSettleFails(t *testing.T) { nAdds := len(adds) nSettleFails := len(settleFails) - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.AddFwdPkg(tx, fwdPkg) }); err != nil { t.Fatalf("unable to add fwd pkg: %v", err) @@ -507,7 +507,7 @@ func TestPackagerAddsThenSettleFails(t *testing.T) { // added any adds to the fwdfilter, this would indicate that all of the // adds were 1) settled locally by this link (exit hop), or 2) the htlc // was failed locally. - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.SetFwdFilter(tx, fwdPkg.Height, fwdPkg.FwdFilter) }); err != nil { t.Fatalf("unable to set fwdfiter: %v", err) @@ -532,7 +532,7 @@ func TestPackagerAddsThenSettleFails(t *testing.T) { Index: uint16(i), } - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.AckAddHtlcs(tx, addRef) }); err != nil { t.Fatalf("unable to ack add htlc: %v", err) @@ -559,7 +559,7 @@ func TestPackagerAddsThenSettleFails(t *testing.T) { Index: uint16(i), } - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.AckSettleFails(tx, failSettleRef) }); err != nil { t.Fatalf("unable to remove settle/fail htlc: %v", err) @@ -579,7 +579,7 @@ func TestPackagerAddsThenSettleFails(t *testing.T) { assertAckFilterIsFull(t, fwdPkgs[0], true) // Lastly, remove the completed forwarding package from disk. - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.RemovePkg(tx, fwdPkg.Height) }); err != nil { t.Fatalf("unable to remove fwdpkg: %v", err) @@ -619,7 +619,7 @@ func TestPackagerSettleFailsThenAdds(t *testing.T) { nAdds := len(adds) nSettleFails := len(settleFails) - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.AddFwdPkg(tx, fwdPkg) }); err != nil { t.Fatalf("unable to add fwd pkg: %v", err) @@ -640,7 +640,7 @@ func TestPackagerSettleFailsThenAdds(t *testing.T) { // added any adds to the fwdfilter, this would indicate that all of the // adds were 1) settled locally by this link (exit hop), or 2) the htlc // was failed locally. - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.SetFwdFilter(tx, fwdPkg.Height, fwdPkg.FwdFilter) }); err != nil { t.Fatalf("unable to set fwdfiter: %v", err) @@ -669,7 +669,7 @@ func TestPackagerSettleFailsThenAdds(t *testing.T) { Index: uint16(i), } - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.AckSettleFails(tx, failSettleRef) }); err != nil { t.Fatalf("unable to remove settle/fail htlc: %v", err) @@ -696,7 +696,7 @@ func TestPackagerSettleFailsThenAdds(t *testing.T) { Index: uint16(i), } - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.AckAddHtlcs(tx, addRef) }); err != nil { t.Fatalf("unable to ack add htlc: %v", err) @@ -716,7 +716,7 @@ func TestPackagerSettleFailsThenAdds(t *testing.T) { assertAckFilterIsFull(t, fwdPkgs[0], true) // Lastly, remove the completed forwarding package from disk. - if err := db.Update(func(tx *bolt.Tx) error { + if err := db.Update(func(tx *bbolt.Tx) error { return packager.RemovePkg(tx, fwdPkg.Height) }); err != nil { t.Fatalf("unable to remove fwdpkg: %v", err) @@ -778,11 +778,11 @@ func assertSettleFailFilterIsFull(t *testing.T, fwdPkg *channeldb.FwdPkg, expect // loadFwdPkgs is a helper method that reads all forwarding packages for a // particular packager. -func loadFwdPkgs(t *testing.T, db *bolt.DB, +func loadFwdPkgs(t *testing.T, db *bbolt.DB, packager channeldb.FwdPackager) []*channeldb.FwdPkg { var fwdPkgs []*channeldb.FwdPkg - if err := db.View(func(tx *bolt.Tx) error { + if err := db.View(func(tx *bbolt.Tx) error { var err error fwdPkgs, err = packager.LoadFwdPkgs(tx) return err @@ -795,7 +795,7 @@ func loadFwdPkgs(t *testing.T, db *bolt.DB, // makeFwdPkgDB initializes a test database for forwarding packages. If the // provided path is an empty, it will create a temp dir/file to use. -func makeFwdPkgDB(t *testing.T, path string) *bolt.DB { +func makeFwdPkgDB(t *testing.T, path string) *bbolt.DB { if path == "" { var err error path, err = ioutil.TempDir("", "fwdpkgdb") @@ -806,7 +806,7 @@ func makeFwdPkgDB(t *testing.T, path string) *bolt.DB { path = filepath.Join(path, "fwdpkg.db") } - db, err := bolt.Open(path, 0600, nil) + db, err := bbolt.Open(path, 0600, nil) if err != nil { t.Fatalf("unable to open boltdb: %v", err) } diff --git a/channeldb/graph.go b/channeldb/graph.go index 0fd9e0c8..70eb55ee 100644 --- a/channeldb/graph.go +++ b/channeldb/graph.go @@ -171,7 +171,7 @@ func (c *ChannelGraph) Database() *DB { func (c *ChannelGraph) ForEachChannel(cb func(*ChannelEdgeInfo, *ChannelEdgePolicy, *ChannelEdgePolicy) error) error { // TODO(roasbeef): ptr map to reduce # of allocs? no duplicates - return c.db.View(func(tx *bolt.Tx) error { + return c.db.View(func(tx *bbolt.Tx) error { // First, grab the node bucket. This will be used to populate // the Node pointers in each edge read from disk. nodes := tx.Bucket(nodeBucket) @@ -229,8 +229,8 @@ func (c *ChannelGraph) ForEachChannel(cb func(*ChannelEdgeInfo, *ChannelEdgePoli // // TODO(roasbeef): add iterator interface to allow for memory efficient graph // traversal when graph gets mega -func (c *ChannelGraph) ForEachNode(tx *bolt.Tx, cb func(*bolt.Tx, *LightningNode) error) error { - traversal := func(tx *bolt.Tx) error { +func (c *ChannelGraph) ForEachNode(tx *bbolt.Tx, cb func(*bbolt.Tx, *LightningNode) error) error { + traversal := func(tx *bbolt.Tx) error { // First grab the nodes bucket which stores the mapping from // pubKey to node information. nodes := tx.Bucket(nodeBucket) @@ -276,7 +276,7 @@ func (c *ChannelGraph) ForEachNode(tx *bolt.Tx, cb func(*bolt.Tx, *LightningNode // node based off the source node. func (c *ChannelGraph) SourceNode() (*LightningNode, error) { var source *LightningNode - err := c.db.View(func(tx *bolt.Tx) error { + err := c.db.View(func(tx *bbolt.Tx) error { node, err := c.sourceNode(tx) if err != nil { return err @@ -296,7 +296,7 @@ func (c *ChannelGraph) SourceNode() (*LightningNode, error) { // of the graph. The source node is treated as the center node within a // star-graph. This method may be used to kick off a path finding algorithm in // order to explore the reachability of another node based off the source node. -func (c *ChannelGraph) sourceNode(tx *bolt.Tx) (*LightningNode, error) { +func (c *ChannelGraph) sourceNode(tx *bbolt.Tx) (*LightningNode, error) { // First grab the nodes bucket which stores the mapping from // pubKey to node information. nodes := tx.Bucket(nodeBucket) @@ -326,7 +326,7 @@ func (c *ChannelGraph) sourceNode(tx *bolt.Tx) (*LightningNode, error) { func (c *ChannelGraph) SetSourceNode(node *LightningNode) error { nodePubBytes := node.PubKeyBytes[:] - return c.db.Update(func(tx *bolt.Tx) error { + return c.db.Update(func(tx *bbolt.Tx) error { // First grab the nodes bucket which stores the mapping from // pubKey to node information. nodes, err := tx.CreateBucketIfNotExists(nodeBucket) @@ -355,12 +355,12 @@ func (c *ChannelGraph) SetSourceNode(node *LightningNode) error { // // TODO(roasbeef): also need sig of announcement func (c *ChannelGraph) AddLightningNode(node *LightningNode) error { - return c.db.Update(func(tx *bolt.Tx) error { + return c.db.Update(func(tx *bbolt.Tx) error { return addLightningNode(tx, node) }) } -func addLightningNode(tx *bolt.Tx, node *LightningNode) error { +func addLightningNode(tx *bbolt.Tx, node *LightningNode) error { nodes, err := tx.CreateBucketIfNotExists(nodeBucket) if err != nil { return err @@ -386,7 +386,7 @@ func addLightningNode(tx *bolt.Tx, node *LightningNode) error { func (c *ChannelGraph) LookupAlias(pub *btcec.PublicKey) (string, error) { var alias string - err := c.db.View(func(tx *bolt.Tx) error { + err := c.db.View(func(tx *bbolt.Tx) error { nodes := tx.Bucket(nodeBucket) if nodes == nil { return ErrGraphNodesNotFound @@ -419,14 +419,14 @@ func (c *ChannelGraph) LookupAlias(pub *btcec.PublicKey) (string, error) { // from the database according to the node's public key. func (c *ChannelGraph) DeleteLightningNode(nodePub *btcec.PublicKey) error { // TODO(roasbeef): ensure dangling edges are removed... - return c.db.Update(func(tx *bolt.Tx) error { + return c.db.Update(func(tx *bbolt.Tx) error { return c.deleteLightningNode(tx, nodePub.SerializeCompressed()) }) } // deleteLightningNode uses an existing database transaction to remove a // vertex/node from the database according to the node's public key. -func (c *ChannelGraph) deleteLightningNode(tx *bolt.Tx, +func (c *ChannelGraph) deleteLightningNode(tx *bbolt.Tx, compressedPubKey []byte) error { nodes := tx.Bucket(nodeBucket) @@ -485,7 +485,7 @@ func (c *ChannelGraph) AddChannelEdge(edge *ChannelEdgeInfo) error { var chanKey [8]byte binary.BigEndian.PutUint64(chanKey[:], edge.ChannelID) - return c.db.Update(func(tx *bolt.Tx) error { + return c.db.Update(func(tx *bbolt.Tx) error { nodes, err := tx.CreateBucketIfNotExists(nodeBucket) if err != nil { return err @@ -591,7 +591,7 @@ func (c *ChannelGraph) HasChannelEdge(chanID uint64) (time.Time, time.Time, bool exists bool ) - if err := c.db.View(func(tx *bolt.Tx) error { + if err := c.db.View(func(tx *bbolt.Tx) error { edges := tx.Bucket(edgeBucket) if edges == nil { return ErrGraphNoEdgesFound @@ -651,7 +651,7 @@ func (c *ChannelGraph) UpdateChannelEdge(edge *ChannelEdgeInfo) error { var chanKey [8]byte binary.BigEndian.PutUint64(chanKey[:], edge.ChannelID) - return c.db.Update(func(tx *bolt.Tx) error { + return c.db.Update(func(tx *bbolt.Tx) error { edges, err := tx.CreateBucketIfNotExists(edgeBucket) if err != nil { return err @@ -690,7 +690,7 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint, var chansClosed []*ChannelEdgeInfo - err := c.db.Update(func(tx *bolt.Tx) error { + err := c.db.Update(func(tx *bbolt.Tx) error { // First grab the edges bucket which houses the information // we'd like to delete edges, err := tx.CreateBucketIfNotExists(edgeBucket) @@ -794,7 +794,7 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint, // that we only maintain a graph of reachable nodes. In the event that a pruned // node gains more channels, it will be re-added back to the graph. func (c *ChannelGraph) PruneGraphNodes() error { - return c.db.Update(func(tx *bolt.Tx) error { + return c.db.Update(func(tx *bbolt.Tx) error { nodes, err := tx.CreateBucketIfNotExists(nodeBucket) if err != nil { return err @@ -815,8 +815,8 @@ func (c *ChannelGraph) PruneGraphNodes() error { // pruneGraphNodes attempts to remove any nodes from the graph who have had a // channel closed within the current block. If the node still has existing // channels in the graph, this will act as a no-op. -func (c *ChannelGraph) pruneGraphNodes(tx *bolt.Tx, nodes *bolt.Bucket, - edgeIndex *bolt.Bucket) error { +func (c *ChannelGraph) pruneGraphNodes(tx *bbolt.Tx, nodes *bbolt.Bucket, + edgeIndex *bbolt.Bucket) error { log.Trace("Pruning nodes from graph with no open channels") @@ -939,7 +939,7 @@ func (c *ChannelGraph) DisconnectBlockAtHeight(height uint32) ([]*ChannelEdgeInf // Keep track of the channels that are removed from the graph. var removedChans []*ChannelEdgeInfo - if err := c.db.Update(func(tx *bolt.Tx) error { + if err := c.db.Update(func(tx *bbolt.Tx) error { edges, err := tx.CreateBucketIfNotExists(edgeBucket) if err != nil { return err @@ -1022,7 +1022,7 @@ func (c *ChannelGraph) PruneTip() (*chainhash.Hash, uint32, error) { tipHeight uint32 ) - err := c.db.View(func(tx *bolt.Tx) error { + err := c.db.View(func(tx *bbolt.Tx) error { graphMeta := tx.Bucket(graphMetaBucket) if graphMeta == nil { return ErrGraphNotFound @@ -1063,7 +1063,7 @@ func (c *ChannelGraph) DeleteChannelEdge(chanPoint *wire.OutPoint) error { // channels // TODO(roasbeef): don't delete both edges? - return c.db.Update(func(tx *bolt.Tx) error { + return c.db.Update(func(tx *bbolt.Tx) error { // First grab the edges bucket which houses the information // we'd like to delete edges, err := tx.CreateBucketIfNotExists(edgeBucket) @@ -1099,7 +1099,7 @@ func (c *ChannelGraph) ChannelID(chanPoint *wire.OutPoint) (uint64, error) { return 0, nil } - if err := c.db.View(func(tx *bolt.Tx) error { + if err := c.db.View(func(tx *bbolt.Tx) error { edges := tx.Bucket(edgeBucket) if edges == nil { return ErrGraphNoEdgesFound @@ -1132,7 +1132,7 @@ func (c *ChannelGraph) ChannelID(chanPoint *wire.OutPoint) (uint64, error) { func (c *ChannelGraph) HighestChanID() (uint64, error) { var cid uint64 - err := c.db.View(func(tx *bolt.Tx) error { + err := c.db.View(func(tx *bbolt.Tx) error { edges := tx.Bucket(edgeBucket) if edges == nil { return ErrGraphNoEdgesFound @@ -1191,7 +1191,7 @@ func (c *ChannelGraph) ChanUpdatesInHorizon(startTime, endTime time.Time) ([]Cha edgesSeen := make(map[uint64]struct{}) var edgesInHorizon []ChannelEdge - err := c.db.View(func(tx *bolt.Tx) error { + err := c.db.View(func(tx *bbolt.Tx) error { edges := tx.Bucket(edgeBucket) if edges == nil { return ErrGraphNoEdgesFound @@ -1293,7 +1293,7 @@ func (c *ChannelGraph) ChanUpdatesInHorizon(startTime, endTime time.Time) ([]Cha func (c *ChannelGraph) NodeUpdatesInHorizon(startTime, endTime time.Time) ([]LightningNode, error) { var nodesInHorizon []LightningNode - err := c.db.View(func(tx *bolt.Tx) error { + err := c.db.View(func(tx *bbolt.Tx) error { nodes := tx.Bucket(nodeBucket) if nodes == nil { return ErrGraphNodesNotFound @@ -1355,7 +1355,7 @@ func (c *ChannelGraph) NodeUpdatesInHorizon(startTime, endTime time.Time) ([]Lig func (c *ChannelGraph) FilterKnownChanIDs(chanIDs []uint64) ([]uint64, error) { var newChanIDs []uint64 - err := c.db.View(func(tx *bolt.Tx) error { + err := c.db.View(func(tx *bbolt.Tx) error { edges := tx.Bucket(edgeBucket) if edges == nil { return ErrGraphNoEdgesFound @@ -1415,7 +1415,7 @@ func (c *ChannelGraph) FilterChannelRange(startHeight, endHeight uint32) ([]uint byteOrder.PutUint64(chanIDStart[:], startChanID.ToUint64()) byteOrder.PutUint64(chanIDEnd[:], endChanID.ToUint64()) - err := c.db.View(func(tx *bolt.Tx) error { + err := c.db.View(func(tx *bbolt.Tx) error { edges := tx.Bucket(edgeBucket) if edges == nil { return ErrGraphNoEdgesFound @@ -1466,7 +1466,7 @@ func (c *ChannelGraph) FetchChanInfos(chanIDs []uint64) ([]ChannelEdge, error) { cidBytes [8]byte ) - err := c.db.View(func(tx *bolt.Tx) error { + err := c.db.View(func(tx *bbolt.Tx) error { edges := tx.Bucket(edgeBucket) if edges == nil { return ErrGraphNoEdgesFound @@ -1516,7 +1516,7 @@ func (c *ChannelGraph) FetchChanInfos(chanIDs []uint64) ([]ChannelEdge, error) { return chanEdges, nil } -func delEdgeUpdateIndexEntry(edgesBucket *bolt.Bucket, chanID uint64, +func delEdgeUpdateIndexEntry(edgesBucket *bbolt.Bucket, chanID uint64, edge1, edge2 *ChannelEdgePolicy) error { // First, we'll fetch the edge update index bucket which currently @@ -1555,8 +1555,8 @@ func delEdgeUpdateIndexEntry(edgesBucket *bolt.Bucket, chanID uint64, return nil } -func delChannelByEdge(edges *bolt.Bucket, edgeIndex *bolt.Bucket, - chanIndex *bolt.Bucket, nodes *bolt.Bucket, chanPoint *wire.OutPoint) error { +func delChannelByEdge(edges *bbolt.Bucket, edgeIndex *bbolt.Bucket, + chanIndex *bbolt.Bucket, nodes *bbolt.Bucket, chanPoint *wire.OutPoint) error { var b bytes.Buffer if err := writeOutpoint(&b, chanPoint); err != nil { return err @@ -1630,7 +1630,7 @@ func delChannelByEdge(edges *bolt.Bucket, edgeIndex *bolt.Bucket, // determined by the lexicographical ordering of the identity public keys of // the nodes on either side of the channel. func (c *ChannelGraph) UpdateEdgePolicy(edge *ChannelEdgePolicy) error { - return c.db.Update(func(tx *bolt.Tx) error { + return c.db.Update(func(tx *bbolt.Tx) error { edges, err := tx.CreateBucketIfNotExists(edgeBucket) if err != nil { return err @@ -1650,7 +1650,7 @@ func (c *ChannelGraph) UpdateEdgePolicy(edge *ChannelEdgePolicy) error { // updateEdgePolicy attempts to update an edge's policy within the relevant // buckets using an existing database transaction. -func updateEdgePolicy(edges, edgeIndex, nodes *bolt.Bucket, +func updateEdgePolicy(edges, edgeIndex, nodes *bbolt.Bucket, edge *ChannelEdgePolicy) error { // Create the channelID key be converting the channel ID @@ -1808,14 +1808,14 @@ func (l *LightningNode) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement, // isPublic determines whether the node is seen as public within the graph from // the source node's point of view. An existing database transaction can also be // specified. -func (l *LightningNode) isPublic(tx *bolt.Tx, sourcePubKey []byte) (bool, error) { +func (l *LightningNode) isPublic(tx *bbolt.Tx, sourcePubKey []byte) (bool, error) { // In order to determine whether this node is publicly advertised within // the graph, we'll need to look at all of its edges and check whether // they extend to any other node than the source node. errDone will be // used to terminate the check early. nodeIsPublic := false errDone := errors.New("done") - err := l.ForEachChannel(tx, func(_ *bolt.Tx, info *ChannelEdgeInfo, + err := l.ForEachChannel(tx, func(_ *bbolt.Tx, info *ChannelEdgeInfo, _, _ *ChannelEdgePolicy) error { // If this edge doesn't extend to the source node, we'll @@ -1852,7 +1852,7 @@ func (l *LightningNode) isPublic(tx *bolt.Tx, sourcePubKey []byte) (bool, error) func (c *ChannelGraph) FetchLightningNode(pub *btcec.PublicKey) (*LightningNode, error) { var node *LightningNode nodePub := pub.SerializeCompressed() - err := c.db.View(func(tx *bolt.Tx) error { + err := c.db.View(func(tx *bbolt.Tx) error { // First grab the nodes bucket which stores the mapping from // pubKey to node information. nodes := tx.Bucket(nodeBucket) @@ -1898,7 +1898,7 @@ func (c *ChannelGraph) HasLightningNode(nodePub [33]byte) (time.Time, bool, erro exists bool ) - err := c.db.View(func(tx *bolt.Tx) error { + err := c.db.View(func(tx *bbolt.Tx) error { // First grab the nodes bucket which stores the mapping from // pubKey to node information. nodes := tx.Bucket(nodeBucket) @@ -1947,12 +1947,12 @@ func (c *ChannelGraph) HasLightningNode(nodePub [33]byte) (time.Time, bool, erro // should be passed as the first argument. Otherwise the first argument should // be nil and a fresh transaction will be created to execute the graph // traversal. -func (l *LightningNode) ForEachChannel(tx *bolt.Tx, - cb func(*bolt.Tx, *ChannelEdgeInfo, *ChannelEdgePolicy, *ChannelEdgePolicy) error) error { +func (l *LightningNode) ForEachChannel(tx *bbolt.Tx, + cb func(*bbolt.Tx, *ChannelEdgeInfo, *ChannelEdgePolicy, *ChannelEdgePolicy) error) error { nodePub := l.PubKeyBytes[:] - traversal := func(tx *bolt.Tx) error { + traversal := func(tx *bbolt.Tx) error { nodes := tx.Bucket(nodeBucket) if nodes == nil { return ErrGraphNotFound @@ -2217,7 +2217,7 @@ func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) ( // the target node in the channel. This is useful when one knows the pubkey of // one of the nodes, and wishes to obtain the full LightningNode for the other // end of the channel. -func (c *ChannelEdgeInfo) FetchOtherNode(tx *bolt.Tx, thisNodeKey []byte) (*LightningNode, error) { +func (c *ChannelEdgeInfo) FetchOtherNode(tx *bbolt.Tx, thisNodeKey []byte) (*LightningNode, error) { // Ensure that the node passed in is actually a member of the channel. var targetNodeBytes [33]byte @@ -2231,7 +2231,7 @@ func (c *ChannelEdgeInfo) FetchOtherNode(tx *bolt.Tx, thisNodeKey []byte) (*Ligh } var targetNode *LightningNode - fetchNodeFunc := func(tx *bolt.Tx) error { + fetchNodeFunc := func(tx *bbolt.Tx) error { // First grab the nodes bucket which stores the mapping from // pubKey to node information. nodes := tx.Bucket(nodeBucket) @@ -2482,7 +2482,7 @@ func (c *ChannelGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (*ChannelE policy2 *ChannelEdgePolicy ) - err := c.db.View(func(tx *bolt.Tx) error { + err := c.db.View(func(tx *bbolt.Tx) error { // First, grab the node bucket. This will be used to populate // the Node pointers in each edge read from disk. nodes := tx.Bucket(nodeBucket) @@ -2561,7 +2561,7 @@ func (c *ChannelGraph) FetchChannelEdgesByID(chanID uint64) (*ChannelEdgeInfo, * channelID [8]byte ) - err := c.db.View(func(tx *bolt.Tx) error { + err := c.db.View(func(tx *bbolt.Tx) error { // First, grab the node bucket. This will be used to populate // the Node pointers in each edge read from disk. nodes := tx.Bucket(nodeBucket) @@ -2613,7 +2613,7 @@ func (c *ChannelGraph) FetchChannelEdgesByID(chanID uint64) (*ChannelEdgeInfo, * // source node's point of view. func (c *ChannelGraph) IsPublicNode(pubKey [33]byte) (bool, error) { var nodeIsPublic bool - err := c.db.View(func(tx *bolt.Tx) error { + err := c.db.View(func(tx *bbolt.Tx) error { nodes := tx.Bucket(nodeBucket) if nodes == nil { return ErrGraphNodesNotFound @@ -2699,7 +2699,7 @@ func (e *EdgePoint) String() string { // closes on the resident blockchain. func (c *ChannelGraph) ChannelView() ([]EdgePoint, error) { var edgePoints []EdgePoint - if err := c.db.View(func(tx *bolt.Tx) error { + if err := c.db.View(func(tx *bbolt.Tx) error { // We're going to iterate over the entire channel index, so // we'll need to fetch the edgeBucket to get to the index as // it's a sub-bucket. @@ -2762,8 +2762,8 @@ func (c *ChannelGraph) NewChannelEdgePolicy() *ChannelEdgePolicy { return &ChannelEdgePolicy{db: c.db} } -func putLightningNode(nodeBucket *bolt.Bucket, aliasBucket *bolt.Bucket, - updateIndex *bolt.Bucket, node *LightningNode) error { +func putLightningNode(nodeBucket *bbolt.Bucket, aliasBucket *bbolt.Bucket, + updateIndex *bbolt.Bucket, node *LightningNode) error { var ( scratch [16]byte @@ -2885,7 +2885,7 @@ func putLightningNode(nodeBucket *bolt.Bucket, aliasBucket *bolt.Bucket, return nodeBucket.Put(nodePub, b.Bytes()) } -func fetchLightningNode(nodeBucket *bolt.Bucket, +func fetchLightningNode(nodeBucket *bbolt.Bucket, nodePub []byte) (LightningNode, error) { nodeBytes := nodeBucket.Get(nodePub) @@ -2991,7 +2991,7 @@ func deserializeLightningNode(r io.Reader) (LightningNode, error) { return node, nil } -func putChanEdgeInfo(edgeIndex *bolt.Bucket, edgeInfo *ChannelEdgeInfo, chanID [8]byte) error { +func putChanEdgeInfo(edgeIndex *bbolt.Bucket, edgeInfo *ChannelEdgeInfo, chanID [8]byte) error { var b bytes.Buffer if _, err := b.Write(edgeInfo.NodeKey1Bytes[:]); err != nil { @@ -3057,7 +3057,7 @@ func putChanEdgeInfo(edgeIndex *bolt.Bucket, edgeInfo *ChannelEdgeInfo, chanID [ return edgeIndex.Put(chanID[:], b.Bytes()) } -func fetchChanEdgeInfo(edgeIndex *bolt.Bucket, +func fetchChanEdgeInfo(edgeIndex *bbolt.Bucket, chanID []byte) (ChannelEdgeInfo, error) { edgeInfoBytes := edgeIndex.Get(chanID) @@ -3146,7 +3146,7 @@ func deserializeChanEdgeInfo(r io.Reader) (ChannelEdgeInfo, error) { return edgeInfo, nil } -func putChanEdgePolicy(edges, nodes *bolt.Bucket, edge *ChannelEdgePolicy, +func putChanEdgePolicy(edges, nodes *bbolt.Bucket, edge *ChannelEdgePolicy, from, to []byte) error { var edgeKey [33 + 8]byte @@ -3248,7 +3248,7 @@ func putChanEdgePolicy(edges, nodes *bolt.Bucket, edge *ChannelEdgePolicy, // putChanEdgePolicyUnknown marks the edge policy as unknown // in the edges bucket. -func putChanEdgePolicyUnknown(edges *bolt.Bucket, channelID uint64, +func putChanEdgePolicyUnknown(edges *bbolt.Bucket, channelID uint64, from []byte) error { var edgeKey [33 + 8]byte @@ -3263,8 +3263,8 @@ func putChanEdgePolicyUnknown(edges *bolt.Bucket, channelID uint64, return edges.Put(edgeKey[:], unknownPolicy) } -func fetchChanEdgePolicy(edges *bolt.Bucket, chanID []byte, - nodePub []byte, nodes *bolt.Bucket) (*ChannelEdgePolicy, error) { +func fetchChanEdgePolicy(edges *bbolt.Bucket, chanID []byte, + nodePub []byte, nodes *bbolt.Bucket) (*ChannelEdgePolicy, error) { var edgeKey [33 + 8]byte copy(edgeKey[:], nodePub) @@ -3285,8 +3285,8 @@ func fetchChanEdgePolicy(edges *bolt.Bucket, chanID []byte, return deserializeChanEdgePolicy(edgeReader, nodes) } -func fetchChanEdgePolicies(edgeIndex *bolt.Bucket, edges *bolt.Bucket, - nodes *bolt.Bucket, chanID []byte, +func fetchChanEdgePolicies(edgeIndex *bbolt.Bucket, edges *bbolt.Bucket, + nodes *bbolt.Bucket, chanID []byte, db *DB) (*ChannelEdgePolicy, *ChannelEdgePolicy, error) { edgeInfo := edgeIndex.Get(chanID) @@ -3327,7 +3327,7 @@ func fetchChanEdgePolicies(edgeIndex *bolt.Bucket, edges *bolt.Bucket, } func deserializeChanEdgePolicy(r io.Reader, - nodes *bolt.Bucket) (*ChannelEdgePolicy, error) { + nodes *bbolt.Bucket) (*ChannelEdgePolicy, error) { edge := &ChannelEdgePolicy{} diff --git a/channeldb/graph_test.go b/channeldb/graph_test.go index 369bdc6f..cbd78721 100644 --- a/channeldb/graph_test.go +++ b/channeldb/graph_test.go @@ -837,7 +837,7 @@ func TestGraphTraversal(t *testing.T) { // Iterate over each node as returned by the graph, if all nodes are // reached, then the map created above should be empty. - err = graph.ForEachNode(nil, func(_ *bolt.Tx, node *LightningNode) error { + err = graph.ForEachNode(nil, func(_ *bbolt.Tx, node *LightningNode) error { delete(nodeIndex, node.Alias) return nil }) @@ -933,7 +933,7 @@ func TestGraphTraversal(t *testing.T) { // Finally, we want to test the ability to iterate over all the // outgoing channels for a particular node. numNodeChans := 0 - err = firstNode.ForEachChannel(nil, func(_ *bolt.Tx, _ *ChannelEdgeInfo, + err = firstNode.ForEachChannel(nil, func(_ *bbolt.Tx, _ *ChannelEdgeInfo, outEdge, inEdge *ChannelEdgePolicy) error { // All channels between first and second node should have fully @@ -1006,7 +1006,7 @@ func assertNumChans(t *testing.T, graph *ChannelGraph, n int) { func assertNumNodes(t *testing.T, graph *ChannelGraph, n int) { numNodes := 0 - err := graph.ForEachNode(nil, func(_ *bolt.Tx, _ *LightningNode) error { + err := graph.ForEachNode(nil, func(_ *bbolt.Tx, _ *LightningNode) error { numNodes++ return nil }) @@ -2015,7 +2015,7 @@ func TestIncompleteChannelPolicies(t *testing.T) { checkPolicies := func(node *LightningNode, expectedIn, expectedOut bool) { calls := 0 - node.ForEachChannel(nil, func(_ *bolt.Tx, _ *ChannelEdgeInfo, + node.ForEachChannel(nil, func(_ *bbolt.Tx, _ *ChannelEdgeInfo, outEdge, inEdge *ChannelEdgePolicy) error { if !expectedOut && outEdge != nil { @@ -2148,7 +2148,7 @@ func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) { timestampSet[t] = struct{}{} } - err := db.View(func(tx *bolt.Tx) error { + err := db.View(func(tx *bbolt.Tx) error { edges := tx.Bucket(edgeBucket) if edges == nil { return ErrGraphNoEdgesFound diff --git a/channeldb/invoices.go b/channeldb/invoices.go index 4b0edffe..428b6c11 100644 --- a/channeldb/invoices.go +++ b/channeldb/invoices.go @@ -185,7 +185,7 @@ func (d *DB) AddInvoice(newInvoice *Invoice) (uint64, error) { } var invoiceAddIndex uint64 - err := d.Update(func(tx *bolt.Tx) error { + err := d.Update(func(tx *bbolt.Tx) error { invoices, err := tx.CreateBucketIfNotExists(invoiceBucket) if err != nil { return err @@ -265,7 +265,7 @@ func (d *DB) InvoicesAddedSince(sinceAddIndex uint64) ([]Invoice, error) { var startIndex [8]byte byteOrder.PutUint64(startIndex[:], sinceAddIndex) - err := d.DB.View(func(tx *bolt.Tx) error { + err := d.DB.View(func(tx *bbolt.Tx) error { invoices := tx.Bucket(invoiceBucket) if invoices == nil { return ErrNoInvoicesCreated @@ -320,7 +320,7 @@ func (d *DB) InvoicesAddedSince(sinceAddIndex uint64) ([]Invoice, error) { // terms of the payment. func (d *DB) LookupInvoice(paymentHash [32]byte) (Invoice, error) { var invoice Invoice - err := d.View(func(tx *bolt.Tx) error { + err := d.View(func(tx *bbolt.Tx) error { invoices := tx.Bucket(invoiceBucket) if invoices == nil { return ErrNoInvoicesCreated @@ -360,7 +360,7 @@ func (d *DB) LookupInvoice(paymentHash [32]byte) (Invoice, error) { func (d *DB) FetchAllInvoices(pendingOnly bool) ([]Invoice, error) { var invoices []Invoice - err := d.View(func(tx *bolt.Tx) error { + err := d.View(func(tx *bbolt.Tx) error { invoiceB := tx.Bucket(invoiceBucket) if invoiceB == nil { return ErrNoInvoicesCreated @@ -449,7 +449,7 @@ func (d *DB) QueryInvoices(q InvoiceQuery) (InvoiceSlice, error) { InvoiceQuery: q, } - err := d.View(func(tx *bolt.Tx) error { + err := d.View(func(tx *bbolt.Tx) error { // If the bucket wasn't found, then there aren't any invoices // within the database yet, so we can simply exit. invoices := tx.Bucket(invoiceBucket) @@ -463,7 +463,7 @@ func (d *DB) QueryInvoices(q InvoiceQuery) (InvoiceSlice, error) { // keyForIndex is a helper closure that retrieves the invoice // key for the given add index of an invoice. - keyForIndex := func(c *bolt.Cursor, index uint64) []byte { + keyForIndex := func(c *bbolt.Cursor, index uint64) []byte { var keyIndex [8]byte byteOrder.PutUint64(keyIndex[:], index) _, invoiceKey := c.Seek(keyIndex[:]) @@ -472,7 +472,7 @@ func (d *DB) QueryInvoices(q InvoiceQuery) (InvoiceSlice, error) { // nextKey is a helper closure to determine what the next // invoice key is when iterating over the invoice add index. - nextKey := func(c *bolt.Cursor) ([]byte, []byte) { + nextKey := func(c *bbolt.Cursor) ([]byte, []byte) { if q.Reversed { return c.Prev() } @@ -573,7 +573,7 @@ func (d *DB) SettleInvoice(paymentHash [32]byte, amtPaid lnwire.MilliSatoshi) (*Invoice, error) { var settledInvoice *Invoice - err := d.Update(func(tx *bolt.Tx) error { + err := d.Update(func(tx *bbolt.Tx) error { invoices, err := tx.CreateBucketIfNotExists(invoiceBucket) if err != nil { return err @@ -634,7 +634,7 @@ func (d *DB) InvoicesSettledSince(sinceSettleIndex uint64) ([]Invoice, error) { var startIndex [8]byte byteOrder.PutUint64(startIndex[:], sinceSettleIndex) - err := d.DB.View(func(tx *bolt.Tx) error { + err := d.DB.View(func(tx *bbolt.Tx) error { invoices := tx.Bucket(invoiceBucket) if invoices == nil { return ErrNoInvoicesCreated @@ -676,7 +676,7 @@ func (d *DB) InvoicesSettledSince(sinceSettleIndex uint64) ([]Invoice, error) { return settledInvoices, nil } -func putInvoice(invoices, invoiceIndex, addIndex *bolt.Bucket, +func putInvoice(invoices, invoiceIndex, addIndex *bbolt.Bucket, i *Invoice, invoiceNum uint32) (uint64, error) { // Create the invoice key which is just the big-endian representation @@ -790,7 +790,7 @@ func serializeInvoice(w io.Writer, i *Invoice) error { return nil } -func fetchInvoice(invoiceNum []byte, invoices *bolt.Bucket) (Invoice, error) { +func fetchInvoice(invoiceNum []byte, invoices *bbolt.Bucket) (Invoice, error) { invoiceBytes := invoices.Get(invoiceNum) if invoiceBytes == nil { return Invoice{}, ErrInvoiceNotFound @@ -862,7 +862,7 @@ func deserializeInvoice(r io.Reader) (Invoice, error) { return invoice, nil } -func settleInvoice(invoices, settleIndex *bolt.Bucket, invoiceNum []byte, +func settleInvoice(invoices, settleIndex *bbolt.Bucket, invoiceNum []byte, amtPaid lnwire.MilliSatoshi) (*Invoice, error) { invoice, err := fetchInvoice(invoiceNum, invoices) diff --git a/channeldb/meta.go b/channeldb/meta.go index c0003b37..541559b4 100644 --- a/channeldb/meta.go +++ b/channeldb/meta.go @@ -1,8 +1,6 @@ package channeldb -import ( - "github.com/coreos/bbolt" -) +import "github.com/coreos/bbolt" var ( // metaBucket stores all the meta information concerning the state of @@ -22,10 +20,10 @@ type Meta struct { // FetchMeta fetches the meta data from boltdb and returns filled meta // structure. -func (d *DB) FetchMeta(tx *bolt.Tx) (*Meta, error) { +func (d *DB) FetchMeta(tx *bbolt.Tx) (*Meta, error) { meta := &Meta{} - err := d.View(func(tx *bolt.Tx) error { + err := d.View(func(tx *bbolt.Tx) error { return fetchMeta(meta, tx) }) if err != nil { @@ -38,7 +36,7 @@ func (d *DB) FetchMeta(tx *bolt.Tx) (*Meta, error) { // fetchMeta is an internal helper function used in order to allow callers to // re-use a database transaction. See the publicly exported FetchMeta method // for more information. -func fetchMeta(meta *Meta, tx *bolt.Tx) error { +func fetchMeta(meta *Meta, tx *bbolt.Tx) error { metaBucket := tx.Bucket(metaBucket) if metaBucket == nil { return ErrMetaNotFound @@ -56,7 +54,7 @@ func fetchMeta(meta *Meta, tx *bolt.Tx) error { // PutMeta writes the passed instance of the database met-data struct to disk. func (d *DB) PutMeta(meta *Meta) error { - return d.Update(func(tx *bolt.Tx) error { + return d.Update(func(tx *bbolt.Tx) error { return putMeta(meta, tx) }) } @@ -64,7 +62,7 @@ func (d *DB) PutMeta(meta *Meta) error { // putMeta is an internal helper function used in order to allow callers to // re-use a database transaction. See the publicly exported PutMeta method for // more information. -func putMeta(meta *Meta, tx *bolt.Tx) error { +func putMeta(meta *Meta, tx *bbolt.Tx) error { metaBucket, err := tx.CreateBucketIfNotExists(metaBucket) if err != nil { return err @@ -73,7 +71,7 @@ func putMeta(meta *Meta, tx *bolt.Tx) error { return putDbVersion(metaBucket, meta) } -func putDbVersion(metaBucket *bolt.Bucket, meta *Meta) error { +func putDbVersion(metaBucket *bbolt.Bucket, meta *Meta) error { scratch := make([]byte, 4) byteOrder.PutUint32(scratch, meta.DbVersionNumber) return metaBucket.Put(dbVersionKey, scratch) diff --git a/channeldb/meta_test.go b/channeldb/meta_test.go index c98999b4..921e55c5 100644 --- a/channeldb/meta_test.go +++ b/channeldb/meta_test.go @@ -108,11 +108,11 @@ func TestOrderOfMigrations(t *testing.T) { versions := []version{ {0, nil}, {1, nil}, - {2, func(tx *bolt.Tx) error { + {2, func(tx *bbolt.Tx) error { appliedMigration = 2 return nil }}, - {3, func(tx *bolt.Tx) error { + {3, func(tx *bbolt.Tx) error { appliedMigration = 3 return nil }}, @@ -184,7 +184,7 @@ func TestMigrationWithPanic(t *testing.T) { beforeMigrationFunc := func(d *DB) { // Insert data in database and in order then make sure that the // key isn't changes in case of panic or fail. - d.Update(func(tx *bolt.Tx) error { + d.Update(func(tx *bbolt.Tx) error { bucket, err := tx.CreateBucketIfNotExists(bucketPrefix) if err != nil { return err @@ -197,7 +197,7 @@ func TestMigrationWithPanic(t *testing.T) { // Create migration function which changes the initially created data and // throw the panic, in this case we pretending that something goes. - migrationWithPanic := func(tx *bolt.Tx) error { + migrationWithPanic := func(tx *bbolt.Tx) error { bucket, err := tx.CreateBucketIfNotExists(bucketPrefix) if err != nil { return err @@ -218,7 +218,7 @@ func TestMigrationWithPanic(t *testing.T) { t.Fatal("migration panicked but version is changed") } - err = d.Update(func(tx *bolt.Tx) error { + err = d.Update(func(tx *bbolt.Tx) error { bucket, err := tx.CreateBucketIfNotExists(bucketPrefix) if err != nil { return err @@ -255,7 +255,7 @@ func TestMigrationWithFatal(t *testing.T) { afterMigration := []byte("aftermigration") beforeMigrationFunc := func(d *DB) { - d.Update(func(tx *bolt.Tx) error { + d.Update(func(tx *bbolt.Tx) error { bucket, err := tx.CreateBucketIfNotExists(bucketPrefix) if err != nil { return err @@ -269,7 +269,7 @@ func TestMigrationWithFatal(t *testing.T) { // Create migration function which changes the initially created data and // return the error, in this case we pretending that something goes // wrong. - migrationWithFatal := func(tx *bolt.Tx) error { + migrationWithFatal := func(tx *bbolt.Tx) error { bucket, err := tx.CreateBucketIfNotExists(bucketPrefix) if err != nil { return err @@ -290,7 +290,7 @@ func TestMigrationWithFatal(t *testing.T) { t.Fatal("migration failed but version is changed") } - err = d.Update(func(tx *bolt.Tx) error { + err = d.Update(func(tx *bbolt.Tx) error { bucket, err := tx.CreateBucketIfNotExists(bucketPrefix) if err != nil { return err @@ -328,7 +328,7 @@ func TestMigrationWithoutErrors(t *testing.T) { // Populate database with initial data. beforeMigrationFunc := func(d *DB) { - d.Update(func(tx *bolt.Tx) error { + d.Update(func(tx *bbolt.Tx) error { bucket, err := tx.CreateBucketIfNotExists(bucketPrefix) if err != nil { return err @@ -340,7 +340,7 @@ func TestMigrationWithoutErrors(t *testing.T) { } // Create migration function which changes the initially created data. - migrationWithoutErrors := func(tx *bolt.Tx) error { + migrationWithoutErrors := func(tx *bbolt.Tx) error { bucket, err := tx.CreateBucketIfNotExists(bucketPrefix) if err != nil { return err @@ -362,7 +362,7 @@ func TestMigrationWithoutErrors(t *testing.T) { "successfully applied migration") } - err = d.Update(func(tx *bolt.Tx) error { + err = d.Update(func(tx *bbolt.Tx) error { bucket, err := tx.CreateBucketIfNotExists(bucketPrefix) if err != nil { return err @@ -406,7 +406,7 @@ func TestMigrationReversion(t *testing.T) { // Update the database metadata to point to one more than the highest // known version. - err = cdb.Update(func(tx *bolt.Tx) error { + err = cdb.Update(func(tx *bbolt.Tx) error { newMeta := &Meta{ DbVersionNumber: getLatestDBVersion(dbVersions) + 1, } diff --git a/channeldb/migrations.go b/channeldb/migrations.go index cddf6278..ffac8a51 100644 --- a/channeldb/migrations.go +++ b/channeldb/migrations.go @@ -14,7 +14,7 @@ import ( // (one for nodes and one for edges) to keep track of the last time a node or // edge was updated on the network. These new indexes allow us to implement the // new graph sync protocol added. -func migrateNodeAndEdgeUpdateIndex(tx *bolt.Tx) error { +func migrateNodeAndEdgeUpdateIndex(tx *bbolt.Tx) error { // First, we'll populating the node portion of the new index. Before we // can add new values to the index, we'll first create the new bucket // where these items will be housed. @@ -119,7 +119,7 @@ func migrateNodeAndEdgeUpdateIndex(tx *bolt.Tx) error { // invoices an index in the add and/or the settle index. Additionally, all // existing invoices will have their bytes padded out in order to encode the // add+settle index as well as the amount paid. -func migrateInvoiceTimeSeries(tx *bolt.Tx) error { +func migrateInvoiceTimeSeries(tx *bbolt.Tx) error { invoices, err := tx.CreateBucketIfNotExists(invoiceBucket) if err != nil { return err @@ -238,7 +238,7 @@ func migrateInvoiceTimeSeries(tx *bolt.Tx) error { // migrateInvoiceTimeSeries migration. As at the time of writing, the // OutgoingPayment struct embeddeds an instance of the Invoice struct. As a // result, we also need to migrate the internal invoice to the new format. -func migrateInvoiceTimeSeriesOutgoingPayments(tx *bolt.Tx) error { +func migrateInvoiceTimeSeriesOutgoingPayments(tx *bbolt.Tx) error { payBucket := tx.Bucket(paymentBucket) if payBucket == nil { return nil @@ -307,7 +307,7 @@ func migrateInvoiceTimeSeriesOutgoingPayments(tx *bolt.Tx) error { // bucket. It ensure that edges with unknown policies will also have an entry // in the bucket. After the migration, there will be two edge entries for // every channel, regardless of whether the policies are known. -func migrateEdgePolicies(tx *bolt.Tx) error { +func migrateEdgePolicies(tx *bbolt.Tx) error { nodes := tx.Bucket(nodeBucket) if nodes == nil { return nil @@ -379,7 +379,7 @@ func migrateEdgePolicies(tx *bolt.Tx) error { // paymentStatusesMigration is a database migration intended for adding payment // statuses for each existing payment entity in bucket to be able control // transitions of statuses and prevent cases such as double payment -func paymentStatusesMigration(tx *bolt.Tx) error { +func paymentStatusesMigration(tx *bbolt.Tx) error { // Get the bucket dedicated to storing statuses of payments, // where a key is payment hash, value is payment status. paymentStatuses, err := tx.CreateBucketIfNotExists(paymentStatusBucket) @@ -466,7 +466,7 @@ func paymentStatusesMigration(tx *bolt.Tx) error { // migration also fixes the case where the public keys within edge policies were // being serialized with an extra byte, causing an even greater error when // attempting to perform the offset calculation described earlier. -func migratePruneEdgeUpdateIndex(tx *bolt.Tx) error { +func migratePruneEdgeUpdateIndex(tx *bbolt.Tx) error { // To begin the migration, we'll retrieve the update index bucket. If it // does not exist, we have nothing left to do so we can simply exit. edges := tx.Bucket(edgeBucket) @@ -577,7 +577,7 @@ func migratePruneEdgeUpdateIndex(tx *bolt.Tx) error { // migrateOptionalChannelCloseSummaryFields migrates the serialized format of // ChannelCloseSummary to a format where optional fields' presence is indicated // with boolean markers. -func migrateOptionalChannelCloseSummaryFields(tx *bolt.Tx) error { +func migrateOptionalChannelCloseSummaryFields(tx *bbolt.Tx) error { closedChanBucket := tx.Bucket(closedChannelBucket) if closedChanBucket == nil { return nil diff --git a/channeldb/migrations_test.go b/channeldb/migrations_test.go index 02c61b22..ed2829c0 100644 --- a/channeldb/migrations_test.go +++ b/channeldb/migrations_test.go @@ -55,7 +55,7 @@ func TestPaymentStatusesMigration(t *testing.T) { // locally-sourced payment should end up with an InFlight // status, while the other should remain unchanged, which // defaults to Grounded. - err = d.Update(func(tx *bolt.Tx) error { + err = d.Update(func(tx *bbolt.Tx) error { circuits, err := tx.CreateBucketIfNotExists( []byte("circuit-adds"), ) @@ -382,7 +382,7 @@ func TestMigrateOptionalChannelCloseSummaryFields(t *testing.T) { // Get the old serialization format for this test's // close summary, and it to the closed channel bucket. old := test.oldSerialization(test.closeSummary) - err = d.Update(func(tx *bolt.Tx) error { + err = d.Update(func(tx *bbolt.Tx) error { closedChanBucket, err := tx.CreateBucketIfNotExists( closedChannelBucket, ) @@ -418,7 +418,7 @@ func TestMigrateOptionalChannelCloseSummaryFields(t *testing.T) { newSerialization := b.Bytes() var dbSummary []byte - err = d.View(func(tx *bolt.Tx) error { + err = d.View(func(tx *bbolt.Tx) error { closedChanBucket := tx.Bucket(closedChannelBucket) if closedChanBucket == nil { return errors.New("unable to find bucket") diff --git a/channeldb/nodes.go b/channeldb/nodes.go index 054e88e6..43729d33 100644 --- a/channeldb/nodes.go +++ b/channeldb/nodes.go @@ -101,7 +101,7 @@ func (l *LinkNode) Sync() error { // Finally update the database by storing the link node and updating // any relevant indexes. - return l.db.Update(func(tx *bolt.Tx) error { + return l.db.Update(func(tx *bbolt.Tx) error { nodeMetaBucket := tx.Bucket(nodeInfoBucket) if nodeMetaBucket == nil { return ErrLinkNodesNotFound @@ -114,7 +114,7 @@ func (l *LinkNode) Sync() error { // putLinkNode serializes then writes the encoded version of the passed link // node into the nodeMetaBucket. This function is provided in order to allow // the ability to re-use a database transaction across many operations. -func putLinkNode(nodeMetaBucket *bolt.Bucket, l *LinkNode) error { +func putLinkNode(nodeMetaBucket *bbolt.Bucket, l *LinkNode) error { // First serialize the LinkNode into its raw-bytes encoding. var b bytes.Buffer if err := serializeLinkNode(&b, l); err != nil { @@ -130,12 +130,12 @@ func putLinkNode(nodeMetaBucket *bolt.Bucket, l *LinkNode) error { // DeleteLinkNode removes the link node with the given identity from the // database. func (db *DB) DeleteLinkNode(identity *btcec.PublicKey) error { - return db.Update(func(tx *bolt.Tx) error { + return db.Update(func(tx *bbolt.Tx) error { return db.deleteLinkNode(tx, identity) }) } -func (db *DB) deleteLinkNode(tx *bolt.Tx, identity *btcec.PublicKey) error { +func (db *DB) deleteLinkNode(tx *bbolt.Tx, identity *btcec.PublicKey) error { nodeMetaBucket := tx.Bucket(nodeInfoBucket) if nodeMetaBucket == nil { return ErrLinkNodesNotFound @@ -154,7 +154,7 @@ func (db *DB) FetchLinkNode(identity *btcec.PublicKey) (*LinkNode, error) { err error ) - err = db.View(func(tx *bolt.Tx) error { + err = db.View(func(tx *bbolt.Tx) error { // First fetch the bucket for storing node metadata, bailing // out early if it hasn't been created yet. nodeMetaBucket := tx.Bucket(nodeInfoBucket) @@ -187,7 +187,7 @@ func (db *DB) FetchLinkNode(identity *btcec.PublicKey) (*LinkNode, error) { // whom we have active channels with. func (db *DB) FetchAllLinkNodes() ([]*LinkNode, error) { var linkNodes []*LinkNode - err := db.View(func(tx *bolt.Tx) error { + err := db.View(func(tx *bbolt.Tx) error { nodes, err := db.fetchAllLinkNodes(tx) if err != nil { return err @@ -205,7 +205,7 @@ func (db *DB) FetchAllLinkNodes() ([]*LinkNode, error) { // fetchAllLinkNodes uses an existing database transaction to fetch all nodes // with whom we have active channels with. -func (db *DB) fetchAllLinkNodes(tx *bolt.Tx) ([]*LinkNode, error) { +func (db *DB) fetchAllLinkNodes(tx *bbolt.Tx) ([]*LinkNode, error) { nodeMetaBucket := tx.Bucket(nodeInfoBucket) if nodeMetaBucket == nil { return nil, ErrLinkNodesNotFound diff --git a/channeldb/payments.go b/channeldb/payments.go index 7d32f20c..e51f2ce1 100644 --- a/channeldb/payments.go +++ b/channeldb/payments.go @@ -118,7 +118,7 @@ func (db *DB) AddPayment(payment *OutgoingPayment) error { } paymentBytes := b.Bytes() - return db.Batch(func(tx *bolt.Tx) error { + return db.Batch(func(tx *bbolt.Tx) error { payments, err := tx.CreateBucketIfNotExists(paymentBucket) if err != nil { return err @@ -144,7 +144,7 @@ func (db *DB) AddPayment(payment *OutgoingPayment) error { func (db *DB) FetchAllPayments() ([]*OutgoingPayment, error) { var payments []*OutgoingPayment - err := db.View(func(tx *bolt.Tx) error { + err := db.View(func(tx *bbolt.Tx) error { bucket := tx.Bucket(paymentBucket) if bucket == nil { return ErrNoPaymentsCreated @@ -176,9 +176,9 @@ func (db *DB) FetchAllPayments() ([]*OutgoingPayment, error) { // DeleteAllPayments deletes all payments from DB. func (db *DB) DeleteAllPayments() error { - return db.Update(func(tx *bolt.Tx) error { + return db.Update(func(tx *bbolt.Tx) error { err := tx.DeleteBucket(paymentBucket) - if err != nil && err != bolt.ErrBucketNotFound { + if err != nil && err != bbolt.ErrBucketNotFound { return err } @@ -190,7 +190,7 @@ func (db *DB) DeleteAllPayments() error { // UpdatePaymentStatus sets the payment status for outgoing/finished payments in // local database. func (db *DB) UpdatePaymentStatus(paymentHash [32]byte, status PaymentStatus) error { - return db.Batch(func(tx *bolt.Tx) error { + return db.Batch(func(tx *bbolt.Tx) error { return UpdatePaymentStatusTx(tx, paymentHash, status) }) } @@ -199,7 +199,7 @@ func (db *DB) UpdatePaymentStatus(paymentHash [32]byte, status PaymentStatus) er // outgoing/finished payments in the local database. This method accepts a // boltdb transaction such that the operation can be composed into other // database transactions. -func UpdatePaymentStatusTx(tx *bolt.Tx, +func UpdatePaymentStatusTx(tx *bbolt.Tx, paymentHash [32]byte, status PaymentStatus) error { paymentStatuses, err := tx.CreateBucketIfNotExists(paymentStatusBucket) @@ -214,7 +214,7 @@ func UpdatePaymentStatusTx(tx *bolt.Tx, // If status of the payment isn't found, it will default to "StatusGrounded". func (db *DB) FetchPaymentStatus(paymentHash [32]byte) (PaymentStatus, error) { var paymentStatus = StatusGrounded - err := db.View(func(tx *bolt.Tx) error { + err := db.View(func(tx *bbolt.Tx) error { var err error paymentStatus, err = FetchPaymentStatusTx(tx, paymentHash) return err @@ -230,7 +230,7 @@ func (db *DB) FetchPaymentStatus(paymentHash [32]byte) (PaymentStatus, error) { // outgoing payment. If status of the payment isn't found, it will default to // "StatusGrounded". It accepts the boltdb transactions such that this method // can be composed into other atomic operations. -func FetchPaymentStatusTx(tx *bolt.Tx, paymentHash [32]byte) (PaymentStatus, error) { +func FetchPaymentStatusTx(tx *bbolt.Tx, paymentHash [32]byte) (PaymentStatus, error) { // The default status for all payments that aren't recorded in database. var paymentStatus = StatusGrounded diff --git a/channeldb/waitingproof.go b/channeldb/waitingproof.go index 28749d8f..74b80a51 100644 --- a/channeldb/waitingproof.go +++ b/channeldb/waitingproof.go @@ -61,7 +61,7 @@ func (s *WaitingProofStore) Add(proof *WaitingProof) error { s.mu.Lock() defer s.mu.Unlock() - err := s.db.Update(func(tx *bolt.Tx) error { + err := s.db.Update(func(tx *bbolt.Tx) error { var err error var b bytes.Buffer @@ -100,7 +100,7 @@ func (s *WaitingProofStore) Remove(key WaitingProofKey) error { return ErrWaitingProofNotFound } - err := s.db.Update(func(tx *bolt.Tx) error { + err := s.db.Update(func(tx *bbolt.Tx) error { // Get or create the top bucket. bucket := tx.Bucket(waitingProofsBucketKey) if bucket == nil { @@ -123,7 +123,7 @@ func (s *WaitingProofStore) Remove(key WaitingProofKey) error { // ForAll iterates thought all waiting proofs and passing the waiting proof // in the given callback. func (s *WaitingProofStore) ForAll(cb func(*WaitingProof) error) error { - return s.db.View(func(tx *bolt.Tx) error { + return s.db.View(func(tx *bbolt.Tx) error { bucket := tx.Bucket(waitingProofsBucketKey) if bucket == nil { return ErrWaitingProofNotFound @@ -158,7 +158,7 @@ func (s *WaitingProofStore) Get(key WaitingProofKey) (*WaitingProof, error) { return nil, ErrWaitingProofNotFound } - err := s.db.View(func(tx *bolt.Tx) error { + err := s.db.View(func(tx *bbolt.Tx) error { bucket := tx.Bucket(waitingProofsBucketKey) if bucket == nil { return ErrWaitingProofNotFound diff --git a/channeldb/witness_cache.go b/channeldb/witness_cache.go index 4b0a7739..5a7b7db7 100644 --- a/channeldb/witness_cache.go +++ b/channeldb/witness_cache.go @@ -76,7 +76,7 @@ func (d *DB) NewWitnessCache() *WitnessCache { // // TODO(roasbeef): fake closure to map instead a constructor? func (w *WitnessCache) AddWitness(wType WitnessType, witness []byte) error { - return w.db.Batch(func(tx *bolt.Tx) error { + return w.db.Batch(func(tx *bbolt.Tx) error { witnessBucket, err := tx.CreateBucketIfNotExists(witnessBucketKey) if err != nil { return err @@ -111,7 +111,7 @@ func (w *WitnessCache) AddWitness(wType WitnessType, witness []byte) error { // will be returned. func (w *WitnessCache) LookupWitness(wType WitnessType, witnessKey []byte) ([]byte, error) { var witness []byte - err := w.db.View(func(tx *bolt.Tx) error { + err := w.db.View(func(tx *bbolt.Tx) error { witnessBucket := tx.Bucket(witnessBucketKey) if witnessBucket == nil { return ErrNoWitnesses @@ -145,7 +145,7 @@ func (w *WitnessCache) LookupWitness(wType WitnessType, witnessKey []byte) ([]by // DeleteWitness attempts to delete a particular witness from the database. func (w *WitnessCache) DeleteWitness(wType WitnessType, witnessKey []byte) error { - return w.db.Batch(func(tx *bolt.Tx) error { + return w.db.Batch(func(tx *bbolt.Tx) error { witnessBucket, err := tx.CreateBucketIfNotExists(witnessBucketKey) if err != nil { return err @@ -169,7 +169,7 @@ func (w *WitnessCache) DeleteWitness(wType WitnessType, witnessKey []byte) error // DeleteWitnessClass attempts to delete an *entire* class of witnesses. After // this function return with a non-nil error, func (w *WitnessCache) DeleteWitnessClass(wType WitnessType) error { - return w.db.Batch(func(tx *bolt.Tx) error { + return w.db.Batch(func(tx *bbolt.Tx) error { witnessBucket, err := tx.CreateBucketIfNotExists(witnessBucketKey) if err != nil { return err diff --git a/contractcourt/briefcase.go b/contractcourt/briefcase.go index d7da21ea..76840fc2 100644 --- a/contractcourt/briefcase.go +++ b/contractcourt/briefcase.go @@ -281,7 +281,7 @@ var ( // boltArbitratorLog is an implementation of the ArbitratorLog interface backed // by a bolt DB instance. type boltArbitratorLog struct { - db *bolt.DB + db *bbolt.DB cfg ChannelArbitratorConfig @@ -290,7 +290,7 @@ type boltArbitratorLog struct { // newBoltArbitratorLog returns a new instance of the boltArbitratorLog given // an arbitrator config, and the items needed to create its log scope. -func newBoltArbitratorLog(db *bolt.DB, cfg ChannelArbitratorConfig, +func newBoltArbitratorLog(db *bbolt.DB, cfg ChannelArbitratorConfig, chainHash chainhash.Hash, chanPoint wire.OutPoint) (*boltArbitratorLog, error) { scope, err := newLogScope(chainHash, chanPoint) @@ -309,7 +309,7 @@ func newBoltArbitratorLog(db *bolt.DB, cfg ChannelArbitratorConfig, // interface. var _ ArbitratorLog = (*boltArbitratorLog)(nil) -func fetchContractReadBucket(tx *bolt.Tx, scopeKey []byte) (*bolt.Bucket, error) { +func fetchContractReadBucket(tx *bbolt.Tx, scopeKey []byte) (*bbolt.Bucket, error) { scopeBucket := tx.Bucket(scopeKey) if scopeBucket == nil { return nil, errScopeBucketNoExist @@ -323,7 +323,7 @@ func fetchContractReadBucket(tx *bolt.Tx, scopeKey []byte) (*bolt.Bucket, error) return contractBucket, nil } -func fetchContractWriteBucket(tx *bolt.Tx, scopeKey []byte) (*bolt.Bucket, error) { +func fetchContractWriteBucket(tx *bbolt.Tx, scopeKey []byte) (*bbolt.Bucket, error) { scopeBucket, err := tx.CreateBucketIfNotExists(scopeKey) if err != nil { return nil, err @@ -341,7 +341,7 @@ func fetchContractWriteBucket(tx *bolt.Tx, scopeKey []byte) (*bolt.Bucket, error // writeResolver is a helper method that writes a contract resolver and stores // it it within the passed contractBucket using its unique resolutionsKey key. -func (b *boltArbitratorLog) writeResolver(contractBucket *bolt.Bucket, +func (b *boltArbitratorLog) writeResolver(contractBucket *bbolt.Bucket, res ContractResolver) error { // First, we'll write to the buffer the type of this resolver. Using @@ -382,7 +382,7 @@ func (b *boltArbitratorLog) writeResolver(contractBucket *bolt.Bucket, // NOTE: Part of the ContractResolver interface. func (b *boltArbitratorLog) CurrentState() (ArbitratorState, error) { var s ArbitratorState - err := b.db.View(func(tx *bolt.Tx) error { + err := b.db.View(func(tx *bbolt.Tx) error { scopeBucket := tx.Bucket(b.scopeKey[:]) if scopeBucket == nil { return errScopeBucketNoExist @@ -407,7 +407,7 @@ func (b *boltArbitratorLog) CurrentState() (ArbitratorState, error) { // // NOTE: Part of the ContractResolver interface. func (b *boltArbitratorLog) CommitState(s ArbitratorState) error { - return b.db.Batch(func(tx *bolt.Tx) error { + return b.db.Batch(func(tx *bbolt.Tx) error { scopeBucket, err := tx.CreateBucketIfNotExists(b.scopeKey[:]) if err != nil { return err @@ -427,7 +427,7 @@ func (b *boltArbitratorLog) FetchUnresolvedContracts() ([]ContractResolver, erro Checkpoint: b.checkpointContract, } var contracts []ContractResolver - err := b.db.View(func(tx *bolt.Tx) error { + err := b.db.View(func(tx *bbolt.Tx) error { contractBucket, err := fetchContractReadBucket(tx, b.scopeKey[:]) if err != nil { return err @@ -518,7 +518,7 @@ func (b *boltArbitratorLog) FetchUnresolvedContracts() ([]ContractResolver, erro // // NOTE: Part of the ContractResolver interface. func (b *boltArbitratorLog) InsertUnresolvedContracts(resolvers ...ContractResolver) error { - return b.db.Batch(func(tx *bolt.Tx) error { + return b.db.Batch(func(tx *bbolt.Tx) error { contractBucket, err := fetchContractWriteBucket(tx, b.scopeKey[:]) if err != nil { return err @@ -541,7 +541,7 @@ func (b *boltArbitratorLog) InsertUnresolvedContracts(resolvers ...ContractResol // // NOTE: Part of the ContractResolver interface. func (b *boltArbitratorLog) SwapContract(oldContract, newContract ContractResolver) error { - return b.db.Batch(func(tx *bolt.Tx) error { + return b.db.Batch(func(tx *bbolt.Tx) error { contractBucket, err := fetchContractWriteBucket(tx, b.scopeKey[:]) if err != nil { return err @@ -561,7 +561,7 @@ func (b *boltArbitratorLog) SwapContract(oldContract, newContract ContractResolv // // NOTE: Part of the ContractResolver interface. func (b *boltArbitratorLog) ResolveContract(res ContractResolver) error { - return b.db.Batch(func(tx *bolt.Tx) error { + return b.db.Batch(func(tx *bbolt.Tx) error { contractBucket, err := fetchContractWriteBucket(tx, b.scopeKey[:]) if err != nil { return err @@ -579,7 +579,7 @@ func (b *boltArbitratorLog) ResolveContract(res ContractResolver) error { // // NOTE: Part of the ContractResolver interface. func (b *boltArbitratorLog) LogContractResolutions(c *ContractResolutions) error { - return b.db.Batch(func(tx *bolt.Tx) error { + return b.db.Batch(func(tx *bbolt.Tx) error { scopeBucket, err := tx.CreateBucketIfNotExists(b.scopeKey[:]) if err != nil { return err @@ -640,7 +640,7 @@ func (b *boltArbitratorLog) LogContractResolutions(c *ContractResolutions) error // NOTE: Part of the ContractResolver interface. func (b *boltArbitratorLog) FetchContractResolutions() (*ContractResolutions, error) { c := &ContractResolutions{} - err := b.db.View(func(tx *bolt.Tx) error { + err := b.db.View(func(tx *bbolt.Tx) error { scopeBucket := tx.Bucket(b.scopeKey[:]) if scopeBucket == nil { return errScopeBucketNoExist @@ -726,7 +726,7 @@ func (b *boltArbitratorLog) FetchContractResolutions() (*ContractResolutions, er // // NOTE: Part of the ContractResolver interface. func (b *boltArbitratorLog) LogChainActions(actions ChainActionMap) error { - return b.db.Batch(func(tx *bolt.Tx) error { + return b.db.Batch(func(tx *bbolt.Tx) error { scopeBucket, err := tx.CreateBucketIfNotExists(b.scopeKey[:]) if err != nil { return err @@ -765,7 +765,7 @@ func (b *boltArbitratorLog) LogChainActions(actions ChainActionMap) error { func (b *boltArbitratorLog) FetchChainActions() (ChainActionMap, error) { actionsMap := make(ChainActionMap) - err := b.db.View(func(tx *bolt.Tx) error { + err := b.db.View(func(tx *bbolt.Tx) error { scopeBucket := tx.Bucket(b.scopeKey[:]) if scopeBucket == nil { return errScopeBucketNoExist @@ -807,7 +807,7 @@ func (b *boltArbitratorLog) FetchChainActions() (ChainActionMap, error) { // // NOTE: Part of the ContractResolver interface. func (b *boltArbitratorLog) WipeHistory() error { - return b.db.Update(func(tx *bolt.Tx) error { + return b.db.Update(func(tx *bbolt.Tx) error { scopeBucket, err := tx.CreateBucketIfNotExists(b.scopeKey[:]) if err != nil { return err @@ -870,7 +870,7 @@ func (b *boltArbitratorLog) WipeHistory() error { // ContractResolver instances to checkpoint their state once they reach // milestones during contract resolution. func (b *boltArbitratorLog) checkpointContract(c ContractResolver) error { - return b.db.Batch(func(tx *bolt.Tx) error { + return b.db.Batch(func(tx *bbolt.Tx) error { contractBucket, err := fetchContractWriteBucket(tx, b.scopeKey[:]) if err != nil { return err diff --git a/contractcourt/briefcase_test.go b/contractcourt/briefcase_test.go index 5010cde9..f0c8f937 100644 --- a/contractcourt/briefcase_test.go +++ b/contractcourt/briefcase_test.go @@ -95,7 +95,7 @@ var ( } ) -func makeTestDB() (*bolt.DB, func(), error) { +func makeTestDB() (*bbolt.DB, func(), error) { // First, create a temporary directory to be used for the duration of // this test. tempDirName, err := ioutil.TempDir("", "arblog") @@ -103,7 +103,7 @@ func makeTestDB() (*bolt.DB, func(), error) { return nil, nil, err } - db, err := bolt.Open(tempDirName+"/test.db", 0600, nil) + db, err := bbolt.Open(tempDirName+"/test.db", 0600, nil) if err != nil { return nil, nil, err } diff --git a/discovery/gossiper.go b/discovery/gossiper.go index 064cb52e..e488e220 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -826,7 +826,7 @@ func (d *AuthenticatedGossiper) resendAnnounceSignatures() error { // TODO(halseth): database access should be abstracted // behind interface. var msgsResend []msgTuple - if err := d.cfg.DB.View(func(tx *bolt.Tx) error { + if err := d.cfg.DB.View(func(tx *bbolt.Tx) error { bucket := tx.Bucket(messageStoreKey) if bucket == nil { return nil @@ -872,7 +872,7 @@ func (d *AuthenticatedGossiper) resendAnnounceSignatures() error { deleteMsg := func(t msgTuple) error { log.Debugf("Deleting message for chanID=%v from "+ "messageStore", t.msg.ChannelID) - if err := d.cfg.DB.Update(func(tx *bolt.Tx) error { + if err := d.cfg.DB.Update(func(tx *bbolt.Tx) error { bucket := tx.Bucket(messageStoreKey) if bucket == nil { return fmt.Errorf("bucket " + @@ -2429,7 +2429,7 @@ func (d *AuthenticatedGossiper) sendAnnSigReliably( copy(key[:33], remotePeer.SerializeCompressed()) binary.BigEndian.PutUint64(key[33:], msg.ShortChannelID.ToUint64()) - err := d.cfg.DB.Update(func(tx *bolt.Tx) error { + err := d.cfg.DB.Update(func(tx *bbolt.Tx) error { bucket, err := tx.CreateBucketIfNotExists(messageStoreKey) if err != nil { return err diff --git a/fundingmanager.go b/fundingmanager.go index a84cbb8b..2bf15789 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -3028,7 +3028,7 @@ func copyPubKey(pub *btcec.PublicKey) *btcec.PublicKey { // chanPoint to the channelOpeningStateBucket. func (f *fundingManager) saveChannelOpeningState(chanPoint *wire.OutPoint, state channelOpeningState, shortChanID *lnwire.ShortChannelID) error { - return f.cfg.Wallet.Cfg.Database.Update(func(tx *bolt.Tx) error { + return f.cfg.Wallet.Cfg.Database.Update(func(tx *bbolt.Tx) error { bucket, err := tx.CreateBucketIfNotExists(channelOpeningStateBucket) if err != nil { @@ -3058,7 +3058,7 @@ func (f *fundingManager) getChannelOpeningState(chanPoint *wire.OutPoint) ( var state channelOpeningState var shortChanID lnwire.ShortChannelID - err := f.cfg.Wallet.Cfg.Database.View(func(tx *bolt.Tx) error { + err := f.cfg.Wallet.Cfg.Database.View(func(tx *bbolt.Tx) error { bucket := tx.Bucket(channelOpeningStateBucket) if bucket == nil { @@ -3090,7 +3090,7 @@ func (f *fundingManager) getChannelOpeningState(chanPoint *wire.OutPoint) ( // deleteChannelOpeningState removes any state for chanPoint from the database. func (f *fundingManager) deleteChannelOpeningState(chanPoint *wire.OutPoint) error { - return f.cfg.Wallet.Cfg.Database.Update(func(tx *bolt.Tx) error { + return f.cfg.Wallet.Cfg.Database.Update(func(tx *bbolt.Tx) error { bucket := tx.Bucket(channelOpeningStateBucket) if bucket == nil { return fmt.Errorf("Bucket not found") diff --git a/htlcswitch/circuit_map.go b/htlcswitch/circuit_map.go index 27c9096f..5db36b88 100644 --- a/htlcswitch/circuit_map.go +++ b/htlcswitch/circuit_map.go @@ -212,7 +212,7 @@ func NewCircuitMap(cfg *CircuitMapConfig) (CircuitMap, error) { // initBuckets ensures that the primary buckets used by the circuit are // initialized so that we can assume their existence after startup. func (cm *circuitMap) initBuckets() error { - return cm.cfg.DB.Update(func(tx *bolt.Tx) error { + return cm.cfg.DB.Update(func(tx *bbolt.Tx) error { _, err := tx.CreateBucketIfNotExists(circuitKeystoneKey) if err != nil { return err @@ -237,7 +237,7 @@ func (cm *circuitMap) restoreMemState() error { pending = make(map[CircuitKey]*PaymentCircuit) ) - if err := cm.cfg.DB.Update(func(tx *bolt.Tx) error { + if err := cm.cfg.DB.Update(func(tx *bbolt.Tx) error { // Restore any of the circuits persisted in the circuit bucket // back into memory. circuitBkt := tx.Bucket(circuitAddKey) @@ -462,7 +462,7 @@ func (cm *circuitMap) TrimOpenCircuits(chanID lnwire.ShortChannelID, return nil } - return cm.cfg.DB.Update(func(tx *bolt.Tx) error { + return cm.cfg.DB.Update(func(tx *bbolt.Tx) error { keystoneBkt := tx.Bucket(circuitKeystoneKey) if keystoneBkt == nil { return ErrCorruptedCircuitMap @@ -615,7 +615,7 @@ func (cm *circuitMap) CommitCircuits(circuits ...*PaymentCircuit) ( // Write the entire batch of circuits to the persistent circuit bucket // using bolt's Batch write. This method must be called from multiple, // distinct goroutines to have any impact on performance. - err := cm.cfg.DB.Batch(func(tx *bolt.Tx) error { + err := cm.cfg.DB.Batch(func(tx *bbolt.Tx) error { circuitBkt := tx.Bucket(circuitAddKey) if circuitBkt == nil { return ErrCorruptedCircuitMap @@ -705,7 +705,7 @@ func (cm *circuitMap) OpenCircuits(keystones ...Keystone) error { } cm.mtx.RUnlock() - err := cm.cfg.DB.Update(func(tx *bolt.Tx) error { + err := cm.cfg.DB.Update(func(tx *bbolt.Tx) error { // Now, load the circuit bucket to which we will write the // already serialized circuit. keystoneBkt := tx.Bucket(circuitKeystoneKey) @@ -846,7 +846,7 @@ func (cm *circuitMap) DeleteCircuits(inKeys ...CircuitKey) error { } cm.mtx.Unlock() - err := cm.cfg.DB.Batch(func(tx *bolt.Tx) error { + err := cm.cfg.DB.Batch(func(tx *bbolt.Tx) error { for _, circuit := range removedCircuits { // If this htlc made it to an outgoing link, load the // keystone bucket from which we will remove the diff --git a/htlcswitch/control_tower.go b/htlcswitch/control_tower.go index 47b5bd3d..380fb787 100644 --- a/htlcswitch/control_tower.go +++ b/htlcswitch/control_tower.go @@ -81,7 +81,7 @@ func NewPaymentControl(strict bool, db *channeldb.DB) ControlTower { // payment identified by the same payment hash. func (p *paymentControl) ClearForTakeoff(htlc *lnwire.UpdateAddHTLC) error { var takeoffErr error - err := p.db.Batch(func(tx *bolt.Tx) error { + err := p.db.Batch(func(tx *bbolt.Tx) error { // Retrieve current status of payment from local database. paymentStatus, err := channeldb.FetchPaymentStatusTx( tx, htlc.PaymentHash, @@ -133,7 +133,7 @@ func (p *paymentControl) ClearForTakeoff(htlc *lnwire.UpdateAddHTLC) error { // attempts for the same payment hash. func (p *paymentControl) Success(paymentHash [32]byte) error { var updateErr error - err := p.db.Batch(func(tx *bolt.Tx) error { + err := p.db.Batch(func(tx *bbolt.Tx) error { paymentStatus, err := channeldb.FetchPaymentStatusTx( tx, paymentHash, ) @@ -190,7 +190,7 @@ func (p *paymentControl) Success(paymentHash [32]byte) error { // for the same payment hash. func (p *paymentControl) Fail(paymentHash [32]byte) error { var updateErr error - err := p.db.Batch(func(tx *bolt.Tx) error { + err := p.db.Batch(func(tx *bbolt.Tx) error { paymentStatus, err := channeldb.FetchPaymentStatusTx( tx, paymentHash, ) diff --git a/htlcswitch/decayedlog.go b/htlcswitch/decayedlog.go index d6845002..d713a121 100644 --- a/htlcswitch/decayedlog.go +++ b/htlcswitch/decayedlog.go @@ -56,7 +56,7 @@ type DecayedLog struct { dbPath string - db *bolt.DB + db *bbolt.DB notifier chainntnfs.ChainNotifier @@ -92,7 +92,7 @@ func (d *DecayedLog) Start() error { // Open the boltdb for use. var err error - if d.db, err = bolt.Open(d.dbPath, dbPermissions, nil); err != nil { + if d.db, err = bbolt.Open(d.dbPath, dbPermissions, nil); err != nil { return fmt.Errorf("Could not open boltdb: %v", err) } @@ -119,7 +119,7 @@ func (d *DecayedLog) Start() error { // initBuckets initializes the primary buckets used by the decayed log, namely // the shared hash bucket, and batch replay func (d *DecayedLog) initBuckets() error { - return d.db.Update(func(tx *bolt.Tx) error { + return d.db.Update(func(tx *bbolt.Tx) error { _, err := tx.CreateBucketIfNotExists(sharedHashBucket) if err != nil { return ErrDecayedLogInit @@ -196,7 +196,7 @@ func (d *DecayedLog) garbageCollector(epochClient *chainntnfs.BlockEpochEvent) { func (d *DecayedLog) gcExpiredHashes(height uint32) (uint32, error) { var numExpiredHashes uint32 - err := d.db.Batch(func(tx *bolt.Tx) error { + err := d.db.Batch(func(tx *bbolt.Tx) error { numExpiredHashes = 0 // Grab the shared hash bucket @@ -246,7 +246,7 @@ func (d *DecayedLog) gcExpiredHashes(height uint32) (uint32, error) { // Delete removes a key-pair from the // sharedHashBucket. func (d *DecayedLog) Delete(hash *sphinx.HashPrefix) error { - return d.db.Batch(func(tx *bolt.Tx) error { + return d.db.Batch(func(tx *bbolt.Tx) error { sharedHashes := tx.Bucket(sharedHashBucket) if sharedHashes == nil { return ErrDecayedLogCorrupted @@ -261,7 +261,7 @@ func (d *DecayedLog) Delete(hash *sphinx.HashPrefix) error { func (d *DecayedLog) Get(hash *sphinx.HashPrefix) (uint32, error) { var value uint32 - err := d.db.View(func(tx *bolt.Tx) error { + err := d.db.View(func(tx *bbolt.Tx) error { // Grab the shared hash bucket which stores the mapping from // truncated sha-256 hashes of shared secrets to CLTV's. sharedHashes := tx.Bucket(sharedHashBucket) @@ -294,7 +294,7 @@ func (d *DecayedLog) Put(hash *sphinx.HashPrefix, cltv uint32) error { var scratch [4]byte binary.BigEndian.PutUint32(scratch[:], cltv) - return d.db.Batch(func(tx *bolt.Tx) error { + return d.db.Batch(func(tx *bbolt.Tx) error { sharedHashes := tx.Bucket(sharedHashBucket) if sharedHashes == nil { return ErrDecayedLogCorrupted @@ -327,7 +327,7 @@ func (d *DecayedLog) PutBatch(b *sphinx.Batch) (*sphinx.ReplaySet, error) { // to generate the complete replay set. If this batch was previously // processed, the replay set will be deserialized from disk. var replays *sphinx.ReplaySet - if err := d.db.Batch(func(tx *bolt.Tx) error { + if err := d.db.Batch(func(tx *bbolt.Tx) error { sharedHashes := tx.Bucket(sharedHashBucket) if sharedHashes == nil { return ErrDecayedLogCorrupted diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index 1fb4ccc3..f52225c3 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -4797,32 +4797,32 @@ type mockPackager struct { failLoadFwdPkgs bool } -func (*mockPackager) AddFwdPkg(tx *bolt.Tx, fwdPkg *channeldb.FwdPkg) error { +func (*mockPackager) AddFwdPkg(tx *bbolt.Tx, fwdPkg *channeldb.FwdPkg) error { return nil } -func (*mockPackager) SetFwdFilter(tx *bolt.Tx, height uint64, +func (*mockPackager) SetFwdFilter(tx *bbolt.Tx, height uint64, fwdFilter *channeldb.PkgFilter) error { return nil } -func (*mockPackager) AckAddHtlcs(tx *bolt.Tx, +func (*mockPackager) AckAddHtlcs(tx *bbolt.Tx, addRefs ...channeldb.AddRef) error { return nil } -func (m *mockPackager) LoadFwdPkgs(tx *bolt.Tx) ([]*channeldb.FwdPkg, error) { +func (m *mockPackager) LoadFwdPkgs(tx *bbolt.Tx) ([]*channeldb.FwdPkg, error) { if m.failLoadFwdPkgs { return nil, fmt.Errorf("failing LoadFwdPkgs") } return nil, nil } -func (*mockPackager) RemovePkg(tx *bolt.Tx, height uint64) error { +func (*mockPackager) RemovePkg(tx *bbolt.Tx, height uint64) error { return nil } -func (*mockPackager) AckSettleFails(tx *bolt.Tx, +func (*mockPackager) AckSettleFails(tx *bbolt.Tx, settleFailRefs ...channeldb.SettleFailRef) error { return nil } diff --git a/htlcswitch/sequencer.go b/htlcswitch/sequencer.go index 27b21a3a..3a5247db 100644 --- a/htlcswitch/sequencer.go +++ b/htlcswitch/sequencer.go @@ -87,7 +87,7 @@ func (s *persistentSequencer) NextID() (uint64, error) { // allocated will start from the last known tip on disk, which is fine // as we only require uniqueness of the allocated numbers. var nextHorizonID uint64 - if err := s.db.Update(func(tx *bolt.Tx) error { + if err := s.db.Update(func(tx *bbolt.Tx) error { nextIDBkt := tx.Bucket(nextPaymentIDKey) if nextIDBkt == nil { return ErrSequencerCorrupted @@ -121,7 +121,7 @@ func (s *persistentSequencer) NextID() (uint64, error) { // initDB populates the bucket used to generate payment sequence numbers. func (s *persistentSequencer) initDB() error { - return s.db.Update(func(tx *bolt.Tx) error { + return s.db.Update(func(tx *bbolt.Tx) error { _, err := tx.CreateBucketIfNotExists(nextPaymentIDKey) return err }) diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index ecd3b3d8..11faf286 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -1350,7 +1350,7 @@ func (s *Switch) closeCircuit(pkt *htlcPacket) (*PaymentCircuit, error) { // we're the originator of the payment, so the link stops attempting to // re-broadcast. func (s *Switch) ackSettleFail(settleFailRef channeldb.SettleFailRef) error { - return s.cfg.DB.Batch(func(tx *bolt.Tx) error { + return s.cfg.DB.Batch(func(tx *bbolt.Tx) error { return s.cfg.SwitchPackager.AckSettleFails(tx, settleFailRef) }) } @@ -1760,7 +1760,7 @@ func (s *Switch) reforwardResponses() error { func (s *Switch) loadChannelFwdPkgs(source lnwire.ShortChannelID) ([]*channeldb.FwdPkg, error) { var fwdPkgs []*channeldb.FwdPkg - if err := s.cfg.DB.Update(func(tx *bolt.Tx) error { + if err := s.cfg.DB.Update(func(tx *bbolt.Tx) error { var err error fwdPkgs, err = s.cfg.SwitchPackager.LoadChannelFwdPkgs( tx, source, diff --git a/htlcswitch/test_utils.go b/htlcswitch/test_utils.go index 45a86403..358a586d 100644 --- a/htlcswitch/test_utils.go +++ b/htlcswitch/test_utils.go @@ -405,7 +405,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte, aliceStoredChannels, err := dbAlice.FetchOpenChannels(aliceKeyPub) switch err { case nil: - case bolt.ErrDatabaseNotOpen: + case bbolt.ErrDatabaseNotOpen: dbAlice, err = channeldb.Open(dbAlice.Path()) if err != nil { return nil, nil, errors.Errorf("unable to reopen alice "+ @@ -444,7 +444,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte, bobStoredChannels, err := dbBob.FetchOpenChannels(bobKeyPub) switch err { case nil: - case bolt.ErrDatabaseNotOpen: + case bbolt.ErrDatabaseNotOpen: dbBob, err = channeldb.Open(dbBob.Path()) if err != nil { return nil, nil, errors.Errorf("unable to reopen bob "+ diff --git a/lnwallet/interface_test.go b/lnwallet/interface_test.go index 3adcc475..23fc296b 100644 --- a/lnwallet/interface_test.go +++ b/lnwallet/interface_test.go @@ -2659,7 +2659,7 @@ func runTests(t *testing.T, walletDriver *lnwallet.WalletDriver, // node's chainstate to initial level, cleanly // wipe buckets if err := clearWalletStates(alice, bob); err != - nil && err != bolt.ErrBucketNotFound { + nil && err != bbolt.ErrBucketNotFound { t.Fatalf("unable to wipe wallet state: %v", err) } } diff --git a/macaroons/service.go b/macaroons/service.go index 618eb0f8..21134ace 100644 --- a/macaroons/service.go +++ b/macaroons/service.go @@ -6,6 +6,7 @@ import ( "os" "path" + "github.com/coreos/bbolt" "google.golang.org/grpc" "google.golang.org/grpc/metadata" @@ -14,8 +15,6 @@ import ( macaroon "gopkg.in/macaroon.v2" "golang.org/x/net/context" - - "github.com/coreos/bbolt" ) var ( @@ -50,8 +49,8 @@ func NewService(dir string, checks ...Checker) (*Service, error) { // Open the database that we'll use to store the primary macaroon key, // and all generated macaroons+caveats. - macaroonDB, err := bolt.Open( - path.Join(dir, DBFilename), 0600, bolt.DefaultOptions, + macaroonDB, err := bbolt.Open( + path.Join(dir, DBFilename), 0600, bbolt.DefaultOptions, ) if err != nil { return nil, err diff --git a/macaroons/service_test.go b/macaroons/service_test.go index f7164afe..0bcc8a69 100644 --- a/macaroons/service_test.go +++ b/macaroons/service_test.go @@ -33,8 +33,8 @@ func setupTestRootKeyStorage(t *testing.T) string { if err != nil { t.Fatalf("Error creating temp dir: %v", err) } - db, err := bolt.Open(path.Join(tempDir, "macaroons.db"), 0600, - bolt.DefaultOptions) + db, err := bbolt.Open(path.Join(tempDir, "macaroons.db"), 0600, + bbolt.DefaultOptions) if err != nil { t.Fatalf("Error opening store DB: %v", err) } diff --git a/macaroons/store.go b/macaroons/store.go index 443162d7..ac766e5f 100644 --- a/macaroons/store.go +++ b/macaroons/store.go @@ -46,16 +46,16 @@ var ( // RootKeyStorage implements the bakery.RootKeyStorage interface. type RootKeyStorage struct { - *bolt.DB + *bbolt.DB encKey *snacl.SecretKey } // NewRootKeyStorage creates a RootKeyStorage instance. // TODO(aakselrod): Add support for encryption of data with passphrase. -func NewRootKeyStorage(db *bolt.DB) (*RootKeyStorage, error) { +func NewRootKeyStorage(db *bbolt.DB) (*RootKeyStorage, error) { // If the store's bucket doesn't exist, create it. - err := db.Update(func(tx *bolt.Tx) error { + err := db.Update(func(tx *bbolt.Tx) error { _, err := tx.CreateBucketIfNotExists(rootKeyBucketName) return err }) @@ -80,7 +80,7 @@ func (r *RootKeyStorage) CreateUnlock(password *[]byte) error { return ErrPasswordRequired } - return r.Update(func(tx *bolt.Tx) error { + return r.Update(func(tx *bbolt.Tx) error { bucket := tx.Bucket(rootKeyBucketName) dbKey := bucket.Get(encryptedKeyID) if len(dbKey) > 0 { @@ -124,7 +124,7 @@ func (r *RootKeyStorage) Get(_ context.Context, id []byte) ([]byte, error) { return nil, ErrStoreLocked } var rootKey []byte - err := r.View(func(tx *bolt.Tx) error { + err := r.View(func(tx *bbolt.Tx) error { dbKey := tx.Bucket(rootKeyBucketName).Get(id) if len(dbKey) == 0 { return fmt.Errorf("root key with id %s doesn't exist", @@ -156,7 +156,7 @@ func (r *RootKeyStorage) RootKey(_ context.Context) ([]byte, []byte, error) { } var rootKey []byte id := defaultRootKeyID - err := r.Update(func(tx *bolt.Tx) error { + err := r.Update(func(tx *bbolt.Tx) error { ns := tx.Bucket(rootKeyBucketName) dbKey := ns.Get(id) diff --git a/macaroons/store_test.go b/macaroons/store_test.go index 48e9f175..4b3188ac 100644 --- a/macaroons/store_test.go +++ b/macaroons/store_test.go @@ -21,8 +21,8 @@ func TestStore(t *testing.T) { } defer os.RemoveAll(tempDir) - db, err := bolt.Open(path.Join(tempDir, "weks.db"), 0600, - bolt.DefaultOptions) + db, err := bbolt.Open(path.Join(tempDir, "weks.db"), 0600, + bbolt.DefaultOptions) if err != nil { t.Fatalf("Error opening store DB: %v", err) } @@ -75,8 +75,8 @@ func TestStore(t *testing.T) { // Between here and the re-opening of the store, it's possible to get // a double-close, but that's not such a big deal since the tests will // fail anyway in that case. - db, err = bolt.Open(path.Join(tempDir, "weks.db"), 0600, - bolt.DefaultOptions) + db, err = bbolt.Open(path.Join(tempDir, "weks.db"), 0600, + bbolt.DefaultOptions) if err != nil { t.Fatalf("Error opening store DB: %v", err) } diff --git a/nursery_store.go b/nursery_store.go index 4b6edbc0..95ce5847 100644 --- a/nursery_store.go +++ b/nursery_store.go @@ -307,7 +307,7 @@ func newNurseryStore(chainHash *chainhash.Hash, // CSV-delayed outputs (commitment and incoming HTLC's), commitment output and // a list of outgoing two-stage htlc outputs. func (ns *nurseryStore) Incubate(kids []kidOutput, babies []babyOutput) error { - return ns.db.Update(func(tx *bolt.Tx) error { + return ns.db.Update(func(tx *bbolt.Tx) error { // If we have any kid outputs to incubate, then we'll attempt // to add each of them to the nursery store. Any duplicate // outputs will be ignored. @@ -334,7 +334,7 @@ func (ns *nurseryStore) Incubate(kids []kidOutput, babies []babyOutput) error { // kindergarten bucket. The now mature kidOutput contained in the babyOutput // will be stored as it waits out the kidOutput's CSV delay. func (ns *nurseryStore) CribToKinder(bby *babyOutput) error { - return ns.db.Update(func(tx *bolt.Tx) error { + return ns.db.Update(func(tx *bbolt.Tx) error { // First, retrieve or create the channel bucket corresponding to // the baby output's origin channel point. @@ -416,7 +416,7 @@ func (ns *nurseryStore) CribToKinder(bby *babyOutput) error { // the kindergarten bucket. This transition should be executed after receiving // confirmation of the preschool output's commitment transaction. func (ns *nurseryStore) PreschoolToKinder(kid *kidOutput) error { - return ns.db.Update(func(tx *bolt.Tx) error { + return ns.db.Update(func(tx *bbolt.Tx) error { // Create or retrieve the channel bucket corresponding to the // kid output's origin channel point. chanPoint := kid.OriginChanPoint() @@ -521,7 +521,7 @@ func (ns *nurseryStore) PreschoolToKinder(kid *kidOutput) error { // kindergarten sweep txn. The height bucket will be opportunistically pruned // from the height index as outputs are removed. func (ns *nurseryStore) GraduateKinder(height uint32) error { - return ns.db.Update(func(tx *bolt.Tx) error { + return ns.db.Update(func(tx *bbolt.Tx) error { // Since all kindergarten outputs at a particular height are // swept in a single txn, we can now safely delete the finalized @@ -606,7 +606,7 @@ func (ns *nurseryStore) GraduateKinder(height uint32) error { func (ns *nurseryStore) FinalizeKinder(height uint32, finalTx *wire.MsgTx) error { - return ns.db.Update(func(tx *bolt.Tx) error { + return ns.db.Update(func(tx *bbolt.Tx) error { return ns.finalizeKinder(tx, height, finalTx) }) } @@ -615,7 +615,7 @@ func (ns *nurseryStore) FinalizeKinder(height uint32, // graduated height. func (ns *nurseryStore) GraduateHeight(height uint32) error { - return ns.db.Update(func(tx *bolt.Tx) error { + return ns.db.Update(func(tx *bbolt.Tx) error { return ns.putLastGraduatedHeight(tx, height) }) } @@ -632,7 +632,7 @@ func (ns *nurseryStore) FetchClass( var finalTx *wire.MsgTx var kids []kidOutput var babies []babyOutput - if err := ns.db.View(func(tx *bolt.Tx) error { + if err := ns.db.View(func(tx *bbolt.Tx) error { var err error finalTx, err = ns.getFinalizedTxn(tx, height) @@ -693,7 +693,7 @@ func (ns *nurseryStore) FetchClass( // preschool bucket. func (ns *nurseryStore) FetchPreschools() ([]kidOutput, error) { var kids []kidOutput - if err := ns.db.View(func(tx *bolt.Tx) error { + if err := ns.db.View(func(tx *bbolt.Tx) error { // Retrieve the existing chain bucket for this nursery store. chainBucket := tx.Bucket(ns.pfxChainKey) @@ -766,7 +766,7 @@ func (ns *nurseryStore) FetchPreschools() ([]kidOutput, error) { // index at or below the provided upper bound. func (ns *nurseryStore) HeightsBelowOrEqual(height uint32) ([]uint32, error) { var activeHeights []uint32 - err := ns.db.View(func(tx *bolt.Tx) error { + err := ns.db.View(func(tx *bbolt.Tx) error { // Ensure that the chain bucket for this nursery store exists. chainBucket := tx.Bucket(ns.pfxChainKey) if chainBucket == nil { @@ -811,7 +811,7 @@ func (ns *nurseryStore) HeightsBelowOrEqual(height uint32) ([]uint32, error) { func (ns *nurseryStore) ForChanOutputs(chanPoint *wire.OutPoint, callback func([]byte, []byte) error) error { - return ns.db.View(func(tx *bolt.Tx) error { + return ns.db.View(func(tx *bbolt.Tx) error { return ns.forChanOutputs(tx, chanPoint, callback) }) } @@ -819,7 +819,7 @@ func (ns *nurseryStore) ForChanOutputs(chanPoint *wire.OutPoint, // ListChannels returns all channels the nursery is currently tracking. func (ns *nurseryStore) ListChannels() ([]wire.OutPoint, error) { var activeChannels []wire.OutPoint - if err := ns.db.View(func(tx *bolt.Tx) error { + if err := ns.db.View(func(tx *bbolt.Tx) error { // Retrieve the existing chain bucket for this nursery store. chainBucket := tx.Bucket(ns.pfxChainKey) if chainBucket == nil { @@ -853,7 +853,7 @@ func (ns *nurseryStore) ListChannels() ([]wire.OutPoint, error) { // IsMatureChannel determines the whether or not all of the outputs in a // particular channel bucket have been marked as graduated. func (ns *nurseryStore) IsMatureChannel(chanPoint *wire.OutPoint) (bool, error) { - err := ns.db.View(func(tx *bolt.Tx) error { + err := ns.db.View(func(tx *bbolt.Tx) error { // Iterate over the contents of the channel bucket, computing // both total number of outputs, and those that have the grad // prefix. @@ -882,7 +882,7 @@ var ErrImmatureChannel = errors.New("cannot remove immature channel, " + // provided channel point. // NOTE: The channel's entries in the height index are assumed to be removed. func (ns *nurseryStore) RemoveChannel(chanPoint *wire.OutPoint) error { - return ns.db.Update(func(tx *bolt.Tx) error { + return ns.db.Update(func(tx *bbolt.Tx) error { // Retrieve the existing chain bucket for this nursery store. chainBucket := tx.Bucket(ns.pfxChainKey) if chainBucket == nil { @@ -942,7 +942,7 @@ func (ns *nurseryStore) RemoveChannel(chanPoint *wire.OutPoint) error { // store has finalized a kindergarten class. func (ns *nurseryStore) LastFinalizedHeight() (uint32, error) { var lastFinalizedHeight uint32 - err := ns.db.View(func(tx *bolt.Tx) error { + err := ns.db.View(func(tx *bbolt.Tx) error { var err error lastFinalizedHeight, err = ns.getLastFinalizedHeight(tx) return err @@ -955,7 +955,7 @@ func (ns *nurseryStore) LastFinalizedHeight() (uint32, error) { // store has successfully graduated all outputs. func (ns *nurseryStore) LastGraduatedHeight() (uint32, error) { var lastGraduatedHeight uint32 - err := ns.db.View(func(tx *bolt.Tx) error { + err := ns.db.View(func(tx *bbolt.Tx) error { var err error lastGraduatedHeight, err = ns.getLastGraduatedHeight(tx) return err @@ -970,7 +970,7 @@ func (ns *nurseryStore) LastGraduatedHeight() (uint32, error) { // its two-stage process of sweeping funds back to the user's wallet. These // outputs are persisted in the nursery store in the crib state, and will be // revisited after the first-stage output's CLTV has expired. -func (ns *nurseryStore) enterCrib(tx *bolt.Tx, baby *babyOutput) error { +func (ns *nurseryStore) enterCrib(tx *bbolt.Tx, baby *babyOutput) error { // First, retrieve or create the channel bucket corresponding to the // baby output's origin channel point. chanPoint := baby.OriginChanPoint() @@ -1025,7 +1025,7 @@ func (ns *nurseryStore) enterCrib(tx *bolt.Tx, baby *babyOutput) error { // through a single stage before sweeping. Outputs are stored in the preschool // bucket until the commitment transaction has been confirmed, at which point // they will be moved to the kindergarten bucket. -func (ns *nurseryStore) enterPreschool(tx *bolt.Tx, kid *kidOutput) error { +func (ns *nurseryStore) enterPreschool(tx *bbolt.Tx, kid *kidOutput) error { // First, retrieve or create the channel bucket corresponding to the // baby output's origin channel point. chanPoint := kid.OriginChanPoint() @@ -1058,8 +1058,8 @@ func (ns *nurseryStore) enterPreschool(tx *bolt.Tx, kid *kidOutput) error { // createChannelBucket creates or retrieves a channel bucket for the provided // channel point. -func (ns *nurseryStore) createChannelBucket(tx *bolt.Tx, - chanPoint *wire.OutPoint) (*bolt.Bucket, error) { +func (ns *nurseryStore) createChannelBucket(tx *bbolt.Tx, + chanPoint *wire.OutPoint) (*bbolt.Bucket, error) { // Ensure that the chain bucket for this nursery store exists. chainBucket, err := tx.CreateBucketIfNotExists(ns.pfxChainKey) @@ -1089,8 +1089,8 @@ func (ns *nurseryStore) createChannelBucket(tx *bolt.Tx, // getChannelBucket retrieves an existing channel bucket from the nursery store, // using the given channel point. If the bucket does not exist, or any bucket // along its path does not exist, a nil value is returned. -func (ns *nurseryStore) getChannelBucket(tx *bolt.Tx, - chanPoint *wire.OutPoint) *bolt.Bucket { +func (ns *nurseryStore) getChannelBucket(tx *bbolt.Tx, + chanPoint *wire.OutPoint) *bbolt.Bucket { // Retrieve the existing chain bucket for this nursery store. chainBucket := tx.Bucket(ns.pfxChainKey) @@ -1116,8 +1116,8 @@ func (ns *nurseryStore) getChannelBucket(tx *bolt.Tx, // createHeightBucket creates or retrieves an existing bucket from the height // index, corresponding to the provided height. -func (ns *nurseryStore) createHeightBucket(tx *bolt.Tx, - height uint32) (*bolt.Bucket, error) { +func (ns *nurseryStore) createHeightBucket(tx *bbolt.Tx, + height uint32) (*bbolt.Bucket, error) { // Ensure that the chain bucket for this nursery store exists. chainBucket, err := tx.CreateBucketIfNotExists(ns.pfxChainKey) @@ -1144,8 +1144,8 @@ func (ns *nurseryStore) createHeightBucket(tx *bolt.Tx, // getHeightBucketPath retrieves an existing height bucket from the nursery // store, using the provided block height. If the bucket does not exist, or any // bucket along its path does not exist, a nil value is returned. -func (ns *nurseryStore) getHeightBucketPath(tx *bolt.Tx, - height uint32) (*bolt.Bucket, *bolt.Bucket, *bolt.Bucket) { +func (ns *nurseryStore) getHeightBucketPath(tx *bbolt.Tx, + height uint32) (*bbolt.Bucket, *bbolt.Bucket, *bbolt.Bucket) { // Retrieve the existing chain bucket for this nursery store. chainBucket := tx.Bucket(ns.pfxChainKey) @@ -1170,8 +1170,8 @@ func (ns *nurseryStore) getHeightBucketPath(tx *bolt.Tx, // getHeightBucket retrieves an existing height bucket from the nursery store, // using the provided block height. If the bucket does not exist, or any bucket // along its path does not exist, a nil value is returned. -func (ns *nurseryStore) getHeightBucket(tx *bolt.Tx, - height uint32) *bolt.Bucket { +func (ns *nurseryStore) getHeightBucket(tx *bbolt.Tx, + height uint32) *bbolt.Bucket { _, _, hghtBucket := ns.getHeightBucketPath(tx, height) return hghtBucket @@ -1180,8 +1180,8 @@ func (ns *nurseryStore) getHeightBucket(tx *bolt.Tx, // createHeightChanBucket creates or retrieves an existing height-channel bucket // for the provided block height and channel point. This method will attempt to // instantiate all buckets along the path if required. -func (ns *nurseryStore) createHeightChanBucket(tx *bolt.Tx, - height uint32, chanPoint *wire.OutPoint) (*bolt.Bucket, error) { +func (ns *nurseryStore) createHeightChanBucket(tx *bbolt.Tx, + height uint32, chanPoint *wire.OutPoint) (*bbolt.Bucket, error) { // Ensure that the height bucket for this nursery store exists. hghtBucket, err := ns.createHeightBucket(tx, height) @@ -1206,8 +1206,8 @@ func (ns *nurseryStore) createHeightChanBucket(tx *bolt.Tx, // nursery store, using the provided block height and channel point. if the // bucket does not exist, or any bucket along its path does not exist, a nil // value is returned. -func (ns *nurseryStore) getHeightChanBucket(tx *bolt.Tx, - height uint32, chanPoint *wire.OutPoint) *bolt.Bucket { +func (ns *nurseryStore) getHeightChanBucket(tx *bbolt.Tx, + height uint32, chanPoint *wire.OutPoint) *bbolt.Bucket { // Retrieve the existing height bucket from this nursery store. hghtBucket := ns.getHeightBucket(tx, height) @@ -1233,7 +1233,7 @@ func (ns *nurseryStore) getHeightChanBucket(tx *bolt.Tx, // enumerate crib and kindergarten outputs at a particular height. The callback // is invoked with serialized bytes retrieved for each output of interest, // allowing the caller to deserialize them into the appropriate type. -func (ns *nurseryStore) forEachHeightPrefix(tx *bolt.Tx, prefix []byte, +func (ns *nurseryStore) forEachHeightPrefix(tx *bbolt.Tx, prefix []byte, height uint32, callback func([]byte) error) error { // Start by retrieving the height bucket corresponding to the provided @@ -1321,7 +1321,7 @@ func (ns *nurseryStore) forEachHeightPrefix(tx *bolt.Tx, prefix []byte, // provided callback. The callback accepts a key-value pair of byte slices // corresponding to the prefixed-output key and the serialized output, // respectively. -func (ns *nurseryStore) forChanOutputs(tx *bolt.Tx, chanPoint *wire.OutPoint, +func (ns *nurseryStore) forChanOutputs(tx *bbolt.Tx, chanPoint *wire.OutPoint, callback func([]byte, []byte) error) error { chanBucket := ns.getChannelBucket(tx, chanPoint) @@ -1334,7 +1334,7 @@ func (ns *nurseryStore) forChanOutputs(tx *bolt.Tx, chanPoint *wire.OutPoint, // getLastFinalizedHeight is a helper method that retrieves the last height for // which the database finalized its persistent state. -func (ns *nurseryStore) getLastFinalizedHeight(tx *bolt.Tx) (uint32, error) { +func (ns *nurseryStore) getLastFinalizedHeight(tx *bbolt.Tx) (uint32, error) { // Retrieve the chain bucket associated with the given nursery store. chainBucket := tx.Bucket(ns.pfxChainKey) if chainBucket == nil { @@ -1362,7 +1362,7 @@ func (ns *nurseryStore) getLastFinalizedHeight(tx *bolt.Tx) (uint32, error) { // finalized, and we skip the process of writing the txn. When the class is // loaded, a nil value will be returned if no txn has been written to a // finalized height bucket. -func (ns *nurseryStore) finalizeKinder(tx *bolt.Tx, height uint32, +func (ns *nurseryStore) finalizeKinder(tx *bbolt.Tx, height uint32, finalTx *wire.MsgTx) error { // TODO(conner) ensure height is greater that current finalized height. @@ -1409,7 +1409,7 @@ func (ns *nurseryStore) finalizeKinder(tx *bolt.Tx, height uint32, // getFinalizedTxn retrieves the finalized kindergarten sweep txn at the given // height, returning nil if one was not found. -func (ns *nurseryStore) getFinalizedTxn(tx *bolt.Tx, +func (ns *nurseryStore) getFinalizedTxn(tx *bbolt.Tx, height uint32) (*wire.MsgTx, error) { hghtBucket := ns.getHeightBucket(tx, height) @@ -1435,7 +1435,7 @@ func (ns *nurseryStore) getFinalizedTxn(tx *bolt.Tx, // getLastGraduatedHeight is a helper method that retrieves the last height for // which the database graduated all outputs successfully. -func (ns *nurseryStore) getLastGraduatedHeight(tx *bolt.Tx) (uint32, error) { +func (ns *nurseryStore) getLastGraduatedHeight(tx *bbolt.Tx) (uint32, error) { // Retrieve the chain bucket associated with the given nursery store. chainBucket := tx.Bucket(ns.pfxChainKey) if chainBucket == nil { @@ -1455,7 +1455,7 @@ func (ns *nurseryStore) getLastGraduatedHeight(tx *bolt.Tx) (uint32, error) { // pubLastGraduatedHeight is a helper method that writes the provided height under // the last graduated height key. -func (ns *nurseryStore) putLastGraduatedHeight(tx *bolt.Tx, height uint32) error { +func (ns *nurseryStore) putLastGraduatedHeight(tx *bbolt.Tx, height uint32) error { // Ensure that the chain bucket for this nursery store exists. chainBucket, err := tx.CreateBucketIfNotExists(ns.pfxChainKey) @@ -1478,7 +1478,7 @@ var errBucketNotEmpty = errors.New("bucket is not empty, cannot be pruned") // removeOutputFromHeight will delete the given output from the specified // height-channel bucket, and attempt to prune the upstream directories if they // are empty. -func (ns *nurseryStore) removeOutputFromHeight(tx *bolt.Tx, height uint32, +func (ns *nurseryStore) removeOutputFromHeight(tx *bbolt.Tx, height uint32, chanPoint *wire.OutPoint, pfxKey []byte) error { // Retrieve the height-channel bucket and delete the prefixed output. @@ -1530,7 +1530,7 @@ func (ns *nurseryStore) removeOutputFromHeight(tx *bolt.Tx, height uint32, // all active outputs at this height have been removed from their respective // height-channel buckets. The returned boolean value indicated whether or not // this invocation successfully pruned the height bucket. -func (ns *nurseryStore) pruneHeight(tx *bolt.Tx, height uint32) (bool, error) { +func (ns *nurseryStore) pruneHeight(tx *bbolt.Tx, height uint32) (bool, error) { // Fetch the existing height index and height bucket. _, hghtIndex, hghtBucket := ns.getHeightBucketPath(tx, height) if hghtBucket == nil { @@ -1576,7 +1576,7 @@ func (ns *nurseryStore) pruneHeight(tx *bolt.Tx, height uint32) (bool, error) { // removeBucketIfEmpty attempts to delete a bucket specified by name from the // provided parent bucket. -func removeBucketIfEmpty(parent *bolt.Bucket, bktName []byte) error { +func removeBucketIfEmpty(parent *bbolt.Bucket, bktName []byte) error { // Attempt to fetch the named bucket from its parent. bkt := parent.Bucket(bktName) if bkt == nil { @@ -1594,7 +1594,7 @@ func removeBucketIfEmpty(parent *bolt.Bucket, bktName []byte) error { // removeBucketIfExists safely deletes the named bucket by first checking // that it exists in the parent bucket. -func removeBucketIfExists(parent *bolt.Bucket, bktName []byte) error { +func removeBucketIfExists(parent *bbolt.Bucket, bktName []byte) error { // Attempt to fetch the named bucket from its parent. bkt := parent.Bucket(bktName) if bkt == nil { @@ -1607,7 +1607,7 @@ func removeBucketIfExists(parent *bolt.Bucket, bktName []byte) error { // isBucketEmpty returns errBucketNotEmpty if the bucket has a non-zero number // of children. -func isBucketEmpty(parent *bolt.Bucket) error { +func isBucketEmpty(parent *bbolt.Bucket) error { return parent.ForEach(func(_, _ []byte) error { return errBucketNotEmpty }) diff --git a/routing/missioncontrol.go b/routing/missioncontrol.go index b722b942..f7103016 100644 --- a/routing/missioncontrol.go +++ b/routing/missioncontrol.go @@ -269,7 +269,7 @@ func generateBandwidthHints(sourceNode *channeldb.LightningNode, // First, we'll collect the set of outbound edges from the target // source node. var localChans []*channeldb.ChannelEdgeInfo - err := sourceNode.ForEachChannel(nil, func(tx *bolt.Tx, + err := sourceNode.ForEachChannel(nil, func(tx *bbolt.Tx, edgeInfo *channeldb.ChannelEdgeInfo, _, _ *channeldb.ChannelEdgePolicy) error { diff --git a/routing/pathfind.go b/routing/pathfind.go index dad7abba..7ab7ef8c 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -457,7 +457,7 @@ func edgeWeight(lockedAmt lnwire.MilliSatoshi, fee lnwire.MilliSatoshi, // destination node back to source. This is to properly accumulate fees // that need to be paid along the path and accurately check the amount // to forward at every node against the available bandwidth. -func findPath(tx *bolt.Tx, graph *channeldb.ChannelGraph, +func findPath(tx *bbolt.Tx, graph *channeldb.ChannelGraph, additionalEdges map[Vertex][]*channeldb.ChannelEdgePolicy, sourceNode *channeldb.LightningNode, target *btcec.PublicKey, ignoredNodes map[Vertex]struct{}, ignoredEdges map[uint64]struct{}, @@ -483,7 +483,7 @@ func findPath(tx *bolt.Tx, graph *channeldb.ChannelGraph, // also returns the source node, so there is no need to add the source // node explicitly. distance := make(map[Vertex]nodeWithDist) - if err := graph.ForEachNode(tx, func(_ *bolt.Tx, node *channeldb.LightningNode) error { + if err := graph.ForEachNode(tx, func(_ *bbolt.Tx, node *channeldb.LightningNode) error { // TODO(roasbeef): with larger graph can just use disk seeks // with a visited map distance[Vertex(node.PubKeyBytes)] = nodeWithDist{ @@ -682,7 +682,7 @@ func findPath(tx *bolt.Tx, graph *channeldb.ChannelGraph, // examine all the incoming edges (channels) from this node to // further our graph traversal. pivot := Vertex(bestNode.PubKeyBytes) - err := bestNode.ForEachChannel(tx, func(tx *bolt.Tx, + err := bestNode.ForEachChannel(tx, func(tx *bbolt.Tx, edgeInfo *channeldb.ChannelEdgeInfo, _, inEdge *channeldb.ChannelEdgePolicy) error { @@ -783,7 +783,7 @@ func findPath(tx *bolt.Tx, graph *channeldb.ChannelGraph, // make our inner path finding algorithm aware of our k-shortest paths // algorithm, rather than attempting to use an unmodified path finding // algorithm in a block box manner. -func findPaths(tx *bolt.Tx, graph *channeldb.ChannelGraph, +func findPaths(tx *bbolt.Tx, graph *channeldb.ChannelGraph, source *channeldb.LightningNode, target *btcec.PublicKey, amt lnwire.MilliSatoshi, feeLimit lnwire.MilliSatoshi, numPaths uint32, bandwidthHints map[uint64]lnwire.MilliSatoshi) ([][]*channeldb.ChannelEdgePolicy, error) { diff --git a/routing/router.go b/routing/router.go index 31a269e4..c68a960f 100644 --- a/routing/router.go +++ b/routing/router.go @@ -2185,7 +2185,7 @@ func (r *ChannelRouter) FetchLightningNode(node Vertex) (*channeldb.LightningNod // // NOTE: This method is part of the ChannelGraphSource interface. func (r *ChannelRouter) ForEachNode(cb func(*channeldb.LightningNode) error) error { - return r.cfg.Graph.ForEachNode(nil, func(_ *bolt.Tx, n *channeldb.LightningNode) error { + return r.cfg.Graph.ForEachNode(nil, func(_ *bbolt.Tx, n *channeldb.LightningNode) error { return cb(n) }) } @@ -2197,7 +2197,7 @@ func (r *ChannelRouter) ForEachNode(cb func(*channeldb.LightningNode) error) err func (r *ChannelRouter) ForAllOutgoingChannels(cb func(*channeldb.ChannelEdgeInfo, *channeldb.ChannelEdgePolicy) error) error { - return r.selfNode.ForEachChannel(nil, func(_ *bolt.Tx, c *channeldb.ChannelEdgeInfo, + return r.selfNode.ForEachChannel(nil, func(_ *bbolt.Tx, c *channeldb.ChannelEdgeInfo, e, _ *channeldb.ChannelEdgePolicy) error { if e == nil { diff --git a/rpcserver.go b/rpcserver.go index 73125c6c..990c94e6 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -3436,7 +3436,7 @@ func (r *rpcServer) DescribeGraph(ctx context.Context, // First iterate through all the known nodes (connected or unconnected // within the graph), collating their current state into the RPC // response. - err := graph.ForEachNode(nil, func(_ *bolt.Tx, node *channeldb.LightningNode) error { + err := graph.ForEachNode(nil, func(_ *bbolt.Tx, node *channeldb.LightningNode) error { nodeAddrs := make([]*lnrpc.NodeAddress, 0) for _, addr := range node.Addresses { nodeAddr := &lnrpc.NodeAddress{ @@ -3588,7 +3588,7 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context, numChannels uint32 totalCapacity btcutil.Amount ) - if err := node.ForEachChannel(nil, func(_ *bolt.Tx, edge *channeldb.ChannelEdgeInfo, + if err := node.ForEachChannel(nil, func(_ *bbolt.Tx, edge *channeldb.ChannelEdgeInfo, _, _ *channeldb.ChannelEdgePolicy) error { numChannels++ @@ -3873,7 +3873,7 @@ func (r *rpcServer) GetNetworkInfo(ctx context.Context, // network, tallying up the total number of nodes, and also gathering // each node so we can measure the graph diameter and degree stats // below. - if err := graph.ForEachNode(nil, func(tx *bolt.Tx, node *channeldb.LightningNode) error { + if err := graph.ForEachNode(nil, func(tx *bbolt.Tx, node *channeldb.LightningNode) error { // Increment the total number of nodes with each iteration. numNodes++ @@ -3883,7 +3883,7 @@ func (r *rpcServer) GetNetworkInfo(ctx context.Context, // through the db transaction from the outer view so we can // re-use it within this inner view. var outDegree uint32 - if err := node.ForEachChannel(tx, func(_ *bolt.Tx, + if err := node.ForEachChannel(tx, func(_ *bbolt.Tx, edge *channeldb.ChannelEdgeInfo, _, _ *channeldb.ChannelEdgePolicy) error { // Bump up the out degree for this node for each @@ -4254,7 +4254,7 @@ func (r *rpcServer) FeeReport(ctx context.Context, } var feeReports []*lnrpc.ChannelFeeReport - err = selfNode.ForEachChannel(nil, func(_ *bolt.Tx, chanInfo *channeldb.ChannelEdgeInfo, + err = selfNode.ForEachChannel(nil, func(_ *bbolt.Tx, chanInfo *channeldb.ChannelEdgeInfo, edgePolicy, _ *channeldb.ChannelEdgePolicy) error { // Self node should always have policies for its channels. diff --git a/server.go b/server.go index 2539745c..7969bc70 100644 --- a/server.go +++ b/server.go @@ -1642,7 +1642,7 @@ func (s *server) establishPersistentConnections() error { // TODO(roasbeef): instead iterate over link nodes and query graph for // each of the nodes. err = sourceNode.ForEachChannel(nil, func( - _ *bolt.Tx, + _ *bbolt.Tx, _ *channeldb.ChannelEdgeInfo, policy, _ *channeldb.ChannelEdgePolicy) error { From 0936aebf1de7ab3838e56b7b5a539f93bdf7df8e Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 29 Nov 2018 20:05:05 -0800 Subject: [PATCH 03/13] build: remove glide usage to build btcd from Makefile We no longer need glide to build btcd as btcd itself now uses go modules as we do. --- Makefile | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 7894d120..38243b3c 100644 --- a/Makefile +++ b/Makefile @@ -2,18 +2,15 @@ PKG := github.com/lightningnetwork/lnd ESCPKG := github.com\/lightningnetwork\/lnd BTCD_PKG := github.com/btcsuite/btcd -GLIDE_PKG := github.com/Masterminds/glide GOVERALLS_PKG := github.com/mattn/goveralls LINT_PKG := gopkg.in/alecthomas/gometalinter.v2 GO_BIN := ${GOPATH}/bin BTCD_BIN := $(GO_BIN)/btcd -GLIDE_BIN := $(GO_BIN)/glide GOVERALLS_BIN := $(GO_BIN)/goveralls LINT_BIN := $(GO_BIN)/gometalinter.v2 HAVE_BTCD := $(shell command -v $(BTCD_BIN) 2> /dev/null) -HAVE_GLIDE := $(shell command -v $(GLIDE_BIN) 2> /dev/null) HAVE_GOVERALLS := $(shell command -v $(GOVERALLS_BIN) 2> /dev/null) HAVE_LINTER := $(shell command -v $(LINT_BIN) 2> /dev/null) @@ -22,7 +19,6 @@ BTCD_DIR :=${GOPATH}/src/$(BTCD_PKG) COMMIT := $(shell git describe --abbrev=40 --dirty) LDFLAGS := -ldflags "-X $(PKG)/build.Commit=$(COMMIT)" -GLIDE_COMMIT := 84607742b10f492430762d038e954236bbaf23f7 BTCD_COMMIT := $(shell cat go.sum | \ grep $(BTCD_PKG) | \ tail -n1 | \ @@ -32,7 +28,7 @@ BTCD_COMMIT := $(shell cat go.sum | \ GOBUILD := GO111MODULE=on go build -v GOINSTALL := GO111MODULE=on go install -v -GOTEST := go test -v +GOTEST := GO111MODULE=on go test -v GOLIST := go list $(PKG)/... | grep -v '/vendor/' GOLISTCOVER := $(shell go list -f '{{.ImportPath}}' ./... | sed -e 's/^$(ESCPKG)/./') @@ -91,12 +87,6 @@ all: scratch check install # DEPENDENCIES # ============ -$(GLIDE_BIN): - @$(call print, "Fetching glide.") - go get -d $(GLIDE_PKG) - cd ${GOPATH}/src/$(GLIDE_PKG) && ( git checkout $(GLIDE_COMMIT) || ( git fetch --all && git checkout $(GLIDE_COMMIT) ) ) - $(GOINSTALL) $(GLIDE_PKG) - $(GOVERALLS_BIN): @$(call print, "Fetching goveralls.") go get -u $(GOVERALLS_PKG) @@ -109,9 +99,9 @@ $(BTCD_DIR): @$(call print, "Fetching btcd.") go get -d github.com/btcsuite/btcd -btcd: $(GLIDE_BIN) $(BTCD_DIR) +btcd: $(BTCD_DIR) @$(call print, "Compiling btcd dependencies.") - cd $(BTCD_DIR) && ( git checkout $(BTCD_COMMIT) || ( git fetch --all && git checkout $(BTCD_COMMIT) ) ) && glide install + cd $(BTCD_DIR) && ( git checkout $(BTCD_COMMIT) || ( git fetch --all && git checkout $(BTCD_COMMIT) ) ) @$(call print, "Installing btcd and btcctl.") $(GOINSTALL) $(BTCD_PKG) $(GOINSTALL) $(BTCD_PKG)/cmd/btcctl From 9bdc1dc2f29c6aadd5fe0ff005f41b62f521231e Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 29 Nov 2018 20:05:32 -0800 Subject: [PATCH 04/13] make: add env before go test for unit tests to support modules --- make/testing_flags.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/testing_flags.mk b/make/testing_flags.mk index e232b39b..1eedc3df 100644 --- a/make/testing_flags.mk +++ b/make/testing_flags.mk @@ -49,7 +49,7 @@ UNIT_RACE := $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) -race $(UNI endif ifeq ($(UNIT_TARGETED), no) -UNIT := $(GOLIST) | $(XARGS) $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) +UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) UNIT_RACE := $(UNIT) -race endif From 00001e7dad802af0cdcf18764c28fe4e5f46aefa Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 29 Nov 2018 21:25:53 -0800 Subject: [PATCH 05/13] watchtower: fix linter errors --- watchtower/lookout/lookout.go | 2 +- watchtower/lookout/punisher.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/watchtower/lookout/lookout.go b/watchtower/lookout/lookout.go index 6cda3c3d..1f6d0fb4 100644 --- a/watchtower/lookout/lookout.go +++ b/watchtower/lookout/lookout.go @@ -134,7 +134,7 @@ func (l *Lookout) watchBlocks(epochs *chainntnfs.BlockEpochEvent) { // that we are monitoring on behalf of our clients. err = l.processEpoch(epoch, block) if err != nil { - log.Errorf("Unable to process %s: %v", + log.Errorf("Unable to process %v: %v", epoch, err) } diff --git a/watchtower/lookout/punisher.go b/watchtower/lookout/punisher.go index f695ef6e..57a6e3a1 100644 --- a/watchtower/lookout/punisher.go +++ b/watchtower/lookout/punisher.go @@ -45,7 +45,7 @@ func (p *BreachPunisher) Punish(desc *JusticeDescriptor, quit <-chan struct{}) e err = p.cfg.PublishTx(justiceTxn) if err != nil && err != lnwallet.ErrDoubleSpend { - log.Errorf("Unable to publish justice txn for client=%s", + log.Errorf("Unable to publish justice txn for client=%s"+ "with breach-txid=%x: %v", desc.SessionInfo.ID, desc.BreachedCommitTx.TxHash(), err) return err From 910757d30e8da20086b4b344d03ad584f88d94fb Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 29 Nov 2018 21:26:25 -0800 Subject: [PATCH 06/13] build: force go modules off when using metalinter in makefile --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 38243b3c..e344d107 100644 --- a/Makefile +++ b/Makefile @@ -93,7 +93,7 @@ $(GOVERALLS_BIN): $(LINT_BIN): @$(call print, "Fetching gometalinter.v2") - go get -u $(LINT_PKG) + GO111MODULE=off go get -u $(LINT_PKG) $(BTCD_DIR): @$(call print, "Fetching btcd.") @@ -176,7 +176,7 @@ fmt: lint: $(LINT_BIN) @$(call print, "Linting source.") - $(LINT_BIN) --install 1> /dev/null + GO111MODULE=off $(LINT_BIN) --install 1> /dev/null test -z "$$($(LINT))" list: From ac04306dcfe3e12723dcf69807460a322009f59c Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 29 Nov 2018 21:27:49 -0800 Subject: [PATCH 07/13] travis: collapse commands into single instance to ensure exit on fail Before this commit, if for example the linter failed, then we would go on to all the other tests rather than halting. We fix this by instead chaining the relevant commands, and eliminating the LINT env variable in the build matrix. --- .travis.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6b4b61c6..5f438056 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,9 +15,9 @@ env: global: - GOCACHE=$HOME/.go-build matrix: - - RACE=true LINT=true + - RACE=true - ITEST=true - - COVER=true + - COVER=true sudo: required install: @@ -32,19 +32,14 @@ script: # Common for all builds. - make btcd - # Run linter if LINT=true. - - 'if [ "$LINT" = true ]; then make lint ; fi' - # Run unit tests with race condition detector. - 'if [ "$RACE" = true ]; then make unit-race ; fi' # Run integration tests. - - 'if [ "$ITEST" = true ]; then make build ; fi' - - 'if [ "$ITEST" = true ]; then make itest-only ; fi' + - 'if [ "$ITEST" = true ]; then make build && make itest-only; fi' # Run unit tests and generate coverage report. - - 'if [ "$COVER" = true ]; then make unit-cover; fi' - - 'if [ "$COVER" = true ]; then make goveralls; fi' + - 'if [ "$COVER" = true ]; then make lint && make unit-cover && make goveralls; fi' after_script: - echo "Uploading to termbin.com..." && find *.log | xargs -I{} sh -c "cat {} | nc termbin.com 9999 | xargs -r0 printf '{} uploaded to %s'" From 1483af79daa40fe37ac8d2e91e4b32bbb84086f1 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 29 Nov 2018 21:35:46 -0800 Subject: [PATCH 08/13] build: force gomodules when executing linter --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e344d107..6b8c2f7f 100644 --- a/Makefile +++ b/Makefile @@ -177,7 +177,7 @@ fmt: lint: $(LINT_BIN) @$(call print, "Linting source.") GO111MODULE=off $(LINT_BIN) --install 1> /dev/null - test -z "$$($(LINT))" + GO111MODULE=on test -z "$$($(LINT))" list: @$(call print, "Listing commands.") From 9e5ba86cef46ce2aa23d161f430b458cbc6d58b3 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 29 Nov 2018 21:40:47 -0800 Subject: [PATCH 09/13] build: force modules at the travis script level --- .travis.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f438056..087e9066 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ install: - export PATH=$PATH:$PWD/linux-amd64/ script: - - env GO111MODULE=on + - export GO111MODULE=on # Common for all builds. - make btcd diff --git a/Makefile b/Makefile index 6b8c2f7f..e344d107 100644 --- a/Makefile +++ b/Makefile @@ -177,7 +177,7 @@ fmt: lint: $(LINT_BIN) @$(call print, "Linting source.") GO111MODULE=off $(LINT_BIN) --install 1> /dev/null - GO111MODULE=on test -z "$$($(LINT))" + test -z "$$($(LINT))" list: @$(call print, "Listing commands.") From eafee05dd205e55c9e3a99c53d7b6fc45abc0431 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 30 Nov 2018 13:59:34 -0800 Subject: [PATCH 10/13] build: update go.mod and go.sum with latest btcd+neutrino+btcwallet --- go.mod | 19 ++++++++++++++----- go.sum | 17 +++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 8a14720a..b4eed4a6 100644 --- a/go.mod +++ b/go.mod @@ -6,16 +6,21 @@ require ( github.com/NebulousLabs/go-upnp v0.0.0-20180202185039-29b680b06c82 github.com/Yawning/aez v0.0.0-20180114000226-4dad034d9db2 github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect + github.com/aead/siphash v1.0.1 // indirect + github.com/boltdb/bolt v1.3.1 // indirect github.com/btcsuite/btcd v0.0.0-20180824064422-b6c71b40a82170695049917527b460e796d33ed7 github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60ae4834a1f57511e20c17b5f78be4b - github.com/btcsuite/btcwallet v0.0.0-20181116030035-284e2e0e696e33d5be388f7f3d9a26db703e0c06 + github.com/btcsuite/btcwallet v0.0.0-20181130215035-a6439bb0d20b github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941 + github.com/btcsuite/goleveldb v1.0.0 // indirect github.com/coreos/bbolt v0.0.0-20180223184059-7ee3ded59d4835e10f3e7d0f7603c42aa5e83820 github.com/davecgh/go-spew v1.1.1 + github.com/fsnotify/fsnotify v1.4.7 // indirect github.com/go-errors/errors v1.0.1 github.com/golang/protobuf v1.2.0 github.com/grpc-ecosystem/grpc-gateway v0.0.0-20170724004829-f2862b476edc + github.com/hpcloud/tail v1.0.0 // indirect github.com/jackpal/gateway v1.0.4 github.com/jackpal/go-nat-pmp v0.0.0-20170405195558-28a68d0c24ad github.com/jessevdk/go-flags v0.0.0-20170926144705-f88afde2fa19 @@ -28,20 +33,24 @@ require ( github.com/juju/utils v0.0.0-20180820210520-bf9cc5bdd62d // indirect github.com/juju/version v0.0.0-20180108022336-b64dbd566305 // indirect github.com/kkdai/bstream v0.0.0-20181106074824-b3251f7901ec - github.com/lightninglabs/neutrino v0.0.0-20181026005035-c86e4463aec4e292dd46c7b506d8dfc9cd3fe031 + github.com/lightninglabs/neutrino v0.0.0-20181130031424-c86e4463aec4 github.com/lightningnetwork/lightning-onion v0.0.0-20180605012408-ac4d9da8f1d6 github.com/ltcsuite/ltcd v0.0.0-20180701083835-cdab10132e8c github.com/miekg/dns v0.0.0-20171125082028-79bfde677fa8 github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af // indirect github.com/tv42/zbase32 v0.0.0-20160707012821-501572607d02 github.com/urfave/cli v1.18.0 + go.etcd.io/bbolt v1.3.0 // indirect golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85 - golang.org/x/net v0.0.0-20180826012351-8a410e7b638d + golang.org/x/net v0.0.0-20181106065722-10aee1819953 + golang.org/x/sync v0.0.0-20181108010431-42b317875d0f // indirect golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 - google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 - google.golang.org/grpc v1.15.0 + google.golang.org/genproto v0.0.0-20181127195345-31ac5d88444a + google.golang.org/grpc v1.16.0 gopkg.in/errgo.v1 v1.0.0 // indirect + gopkg.in/fsnotify.v1 v1.4.7 // indirect gopkg.in/macaroon-bakery.v2 v2.0.1 gopkg.in/macaroon.v2 v2.0.0 gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce // indirect + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect ) diff --git a/go.sum b/go.sum index b8b040ea..18296f3f 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+q github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60ae4834a1f57511e20c17b5f78be4b h1:sa+k743hEDlacUmuzqYlpxx4gp61C9Cf531bPaOneWo= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60ae4834a1f57511e20c17b5f78be4b/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcwallet v0.0.0-20180904010540-284e2e0e696e33d5be388f7f3d9a26db703e0c06/go.mod h1:/d7QHZsfUAruXuBhyPITqoYOmJ+nq35qPsJjz/aSpCg= -github.com/btcsuite/btcwallet v0.0.0-20181116030035-284e2e0e696e33d5be388f7f3d9a26db703e0c06 h1:4v35CTTwAliWecZvAMxpIuk2fZvuuBzWaZslnp0YAvs= -github.com/btcsuite/btcwallet v0.0.0-20181116030035-284e2e0e696e33d5be388f7f3d9a26db703e0c06/go.mod h1:/d7QHZsfUAruXuBhyPITqoYOmJ+nq35qPsJjz/aSpCg= +github.com/btcsuite/btcwallet v0.0.0-20181130215035-a6439bb0d20b h1:XrhU5M1FbwQVwg7PdlCrVf83R3XP0vrmVRChoVcVnOA= +github.com/btcsuite/btcwallet v0.0.0-20181130215035-a6439bb0d20b/go.mod h1:4KsJcXv/0qE4iLnJGuz9ILeFEuJcv3QUFvothS6247k= github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941 h1:kij1x2aL7VE6gtx8KMIt8PGPgI5GV9LgtHFG5KaEMPY= github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941/go.mod h1:QcFA8DZHtuIAdYKCq/BzELOaznRsCvwf4zTPmaYwaig= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw= @@ -92,8 +92,9 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lightninglabs/gozmq v0.0.0-20180324010646-462a8a753885 h1:fTLuPUkaKIIV0+gA1IxiBDvDxtF8tzpSF6N6NfFGmsU= github.com/lightninglabs/gozmq v0.0.0-20180324010646-462a8a753885/go.mod h1:KUh15naRlx/TmUMFS/p4JJrCrE6F7RGF7rsnvuu45E4= github.com/lightninglabs/neutrino v0.0.0-20181017011010-4d6069299130/go.mod h1:KJq43Fu9ceitbJsSXMILcT4mGDNI/crKmPIkDOZXFyM= -github.com/lightninglabs/neutrino v0.0.0-20181026005035-c86e4463aec4e292dd46c7b506d8dfc9cd3fe031 h1:gXqBl67K2v6SUDJpCxJiRzmdkZzxp/tt4z1ezXWjQqE= -github.com/lightninglabs/neutrino v0.0.0-20181026005035-c86e4463aec4e292dd46c7b506d8dfc9cd3fe031/go.mod h1:Y8IaaFZEKKGiyuRmUmKLR/n9+8m61mMDTkQBIMTc/Fw= +github.com/lightninglabs/neutrino v0.0.0-20181017011010-c86e4463aec4e292dd46c7b506d8dfc9cd3fe031/go.mod h1:Y8IaaFZEKKGiyuRmUmKLR/n9+8m61mMDTkQBIMTc/Fw= +github.com/lightninglabs/neutrino v0.0.0-20181130031424-c86e4463aec4 h1:ayVtgne10h+3hvfhOULWbkoVUNy84XRuKOH7SkHxxTY= +github.com/lightninglabs/neutrino v0.0.0-20181130031424-c86e4463aec4/go.mod h1:Y8IaaFZEKKGiyuRmUmKLR/n9+8m61mMDTkQBIMTc/Fw= github.com/lightningnetwork/lightning-onion v0.0.0-20180605012408-ac4d9da8f1d6 h1:ONLGrYJVQdbtP6CE/ff1KNWZtygRGEh12RzonTiCzPs= github.com/lightningnetwork/lightning-onion v0.0.0-20180605012408-ac4d9da8f1d6/go.mod h1:8EgEt4a/NUOVQd+3kk6n9aZCJ1Ssj96Pb6lCrci+6oc= github.com/ltcsuite/ltcd v0.0.0-20180701083835-cdab10132e8c h1:rdKAF0qixVZQy+Hkrojg2vHTZOxJEHns2ymbevTDPms= @@ -120,6 +121,8 @@ golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20180821023952-922f4815f713/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d h1:g9qWBGx4puODJTMVyoPrpoxPFgVGd+z1DZwjfRu4d0I= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181106065722-10aee1819953 h1:LuZIitY8waaxUfNIdtajyE/YzA/zyf0YxXG27VpLrkg= +golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -137,9 +140,11 @@ golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGm google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20181127195345-31ac5d88444a h1:Weemm+oF2juintSvD0c+ZG4lDmCwgYKrM/kPI6gFINY= +google.golang.org/genproto v0.0.0-20181127195345-31ac5d88444a/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.15.0 h1:Az/KuahOM4NAidTEuJCv/RonAA7rYsTPkqXVjr+8OOw= -google.golang.org/grpc v1.15.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= +google.golang.org/grpc v1.16.0 h1:dz5IJGuC2BB7qXR5AyHNwAUBhZscK2xVez7mznh72sY= +google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 24ab9970bfb3dec3ef0d8a1fe34dc217d742d62c Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 30 Nov 2018 14:00:46 -0800 Subject: [PATCH 11/13] build: modify make file to use go get with precise btcd hash --- Makefile | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index e344d107..fe0c0429 100644 --- a/Makefile +++ b/Makefile @@ -95,16 +95,9 @@ $(LINT_BIN): @$(call print, "Fetching gometalinter.v2") GO111MODULE=off go get -u $(LINT_PKG) -$(BTCD_DIR): - @$(call print, "Fetching btcd.") - go get -d github.com/btcsuite/btcd - -btcd: $(BTCD_DIR) - @$(call print, "Compiling btcd dependencies.") - cd $(BTCD_DIR) && ( git checkout $(BTCD_COMMIT) || ( git fetch --all && git checkout $(BTCD_COMMIT) ) ) - @$(call print, "Installing btcd and btcctl.") - $(GOINSTALL) $(BTCD_PKG) - $(GOINSTALL) $(BTCD_PKG)/cmd/btcctl +btcd: + @$(call print, "Installing btcd...") + go get -v github.com/btcsuite/btcd/@v0.0.0-20180823030728-$(BTCD_COMMIT) # ============ # INSTALLATION From 0734e53260f4aa339675146c47cc017f5dca1a9c Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 30 Nov 2018 14:01:53 -0800 Subject: [PATCH 12/13] build: inline travis btcd build --- .travis.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 087e9066..0c0c240e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: go cache: directories: - - vendor/ - $GOCACHE - $GOPATH/pkg/mod - $GOPATH/src/github.com/btcsuite @@ -29,17 +28,14 @@ install: script: - export GO111MODULE=on - # Common for all builds. - - make btcd - # Run unit tests with race condition detector. - - 'if [ "$RACE" = true ]; then make unit-race ; fi' + - 'if [ "$RACE" = true ]; then make btcd && make unit-race ; fi' # Run integration tests. - - 'if [ "$ITEST" = true ]; then make build && make itest-only; fi' + - 'if [ "$ITEST" = true ]; then make btcd && make build && make itest-only; fi' # Run unit tests and generate coverage report. - - 'if [ "$COVER" = true ]; then make lint && make unit-cover && make goveralls; fi' + - 'if [ "$COVER" = true ]; then make btcd && make lint && make unit-cover && make goveralls; fi' after_script: - echo "Uploading to termbin.com..." && find *.log | xargs -I{} sh -c "cat {} | nc termbin.com 9999 | xargs -r0 printf '{} uploaded to %s'" From 41fde4c7963c96661575e0e3e74045fa63165a12 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 30 Nov 2018 14:25:33 -0800 Subject: [PATCH 13/13] build: update to latest btcd, neutrino, btcwallet --- go.mod | 7 +++---- go.sum | 17 ++++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index b4eed4a6..3a437aa3 100644 --- a/go.mod +++ b/go.mod @@ -6,12 +6,11 @@ require ( github.com/NebulousLabs/go-upnp v0.0.0-20180202185039-29b680b06c82 github.com/Yawning/aez v0.0.0-20180114000226-4dad034d9db2 github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect - github.com/aead/siphash v1.0.1 // indirect github.com/boltdb/bolt v1.3.1 // indirect - github.com/btcsuite/btcd v0.0.0-20180824064422-b6c71b40a82170695049917527b460e796d33ed7 + github.com/btcsuite/btcd v0.0.0-20180824064422-7d2daa5bfef28c5e282571bc06416516936115ee github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60ae4834a1f57511e20c17b5f78be4b - github.com/btcsuite/btcwallet v0.0.0-20181130215035-a6439bb0d20b + github.com/btcsuite/btcwallet v0.0.0-20181130221647-e59e51f8e13c github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941 github.com/btcsuite/goleveldb v1.0.0 // indirect github.com/coreos/bbolt v0.0.0-20180223184059-7ee3ded59d4835e10f3e7d0f7603c42aa5e83820 @@ -33,7 +32,7 @@ require ( github.com/juju/utils v0.0.0-20180820210520-bf9cc5bdd62d // indirect github.com/juju/version v0.0.0-20180108022336-b64dbd566305 // indirect github.com/kkdai/bstream v0.0.0-20181106074824-b3251f7901ec - github.com/lightninglabs/neutrino v0.0.0-20181130031424-c86e4463aec4 + github.com/lightninglabs/neutrino v0.0.0-20181130220745-8d09312ac266 github.com/lightningnetwork/lightning-onion v0.0.0-20180605012408-ac4d9da8f1d6 github.com/ltcsuite/ltcd v0.0.0-20180701083835-cdab10132e8c github.com/miekg/dns v0.0.0-20171125082028-79bfde677fa8 diff --git a/go.sum b/go.sum index 18296f3f..77c5a83c 100644 --- a/go.sum +++ b/go.sum @@ -14,28 +14,31 @@ github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBA github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/btcsuite/btcd v0.0.0-20180823030728-d81d8877b8f3/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= -github.com/btcsuite/btcd v0.0.0-20180824064422-b6c71b40a82170695049917527b460e796d33ed7 h1:hvyEQzI9fgZ0WNl6WEQraBoHiXeGYQ3Urbk7jzBNBBc= -github.com/btcsuite/btcd v0.0.0-20180824064422-b6c71b40a82170695049917527b460e796d33ed7/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= +github.com/btcsuite/btcd v0.0.0-20180824064422-7d2daa5bfef28c5e282571bc06416516936115ee h1:YSiTy2Hn6a5TaPnmcyk0+OTc13E1rbmCCgo/J0LDxtA= +github.com/btcsuite/btcd v0.0.0-20180824064422-7d2daa5bfef28c5e282571bc06416516936115ee/go.mod h1:Jr9bmNVGZ7TH2Ux1QuP0ec+yGgh0gE9FIlkzQiI5bR0= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60ae4834a1f57511e20c17b5f78be4b h1:sa+k743hEDlacUmuzqYlpxx4gp61C9Cf531bPaOneWo= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60ae4834a1f57511e20c17b5f78be4b/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcwallet v0.0.0-20180904010540-284e2e0e696e33d5be388f7f3d9a26db703e0c06/go.mod h1:/d7QHZsfUAruXuBhyPITqoYOmJ+nq35qPsJjz/aSpCg= -github.com/btcsuite/btcwallet v0.0.0-20181130215035-a6439bb0d20b h1:XrhU5M1FbwQVwg7PdlCrVf83R3XP0vrmVRChoVcVnOA= -github.com/btcsuite/btcwallet v0.0.0-20181130215035-a6439bb0d20b/go.mod h1:4KsJcXv/0qE4iLnJGuz9ILeFEuJcv3QUFvothS6247k= +github.com/btcsuite/btcwallet v0.0.0-20181130221647-e59e51f8e13c h1:k39UlSgW6cR0cIEleF9Or3S4uSP7NgvRLPd/WNYScbU= +github.com/btcsuite/btcwallet v0.0.0-20181130221647-e59e51f8e13c/go.mod h1:mHSlZHtkxbCzvqKCzkQOSDb7Lc5iqoD8+pj6qc0yDBU= github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941 h1:kij1x2aL7VE6gtx8KMIt8PGPgI5GV9LgtHFG5KaEMPY= github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941/go.mod h1:QcFA8DZHtuIAdYKCq/BzELOaznRsCvwf4zTPmaYwaig= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/golangcrypto v0.0.0-20150304025918-53f62d9b43e8 h1:nOsAWScwueMVk/VLm/dvQQD7DuanyvAUb6B3P3eT274= github.com/btcsuite/golangcrypto v0.0.0-20150304025918-53f62d9b43e8/go.mod h1:tYvUd8KLhm/oXvUeSEs2VlLghFjQt9+ZaF9ghH0JNjc= +github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= github.com/btcsuite/goleveldb v1.0.0 h1:Tvd0BfvqX9o823q1j2UZ/epQo09eJh6dTcRp79ilIN4= github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= +github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/snappy-go v1.0.0 h1:ZxaA6lo2EpxGddsA8JwWOcxlzRybb444sgmeJQMJGQE= github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/bbolt v0.0.0-20180223184059-7ee3ded59d4835e10f3e7d0f7603c42aa5e83820 h1:W1bWzjKRrqKEpWlFsJ6Yef9Q4LUhdfJmS6sQrQj5L6c= github.com/coreos/bbolt v0.0.0-20180223184059-7ee3ded59d4835e10f3e7d0f7603c42aa5e83820/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= @@ -92,9 +95,9 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lightninglabs/gozmq v0.0.0-20180324010646-462a8a753885 h1:fTLuPUkaKIIV0+gA1IxiBDvDxtF8tzpSF6N6NfFGmsU= github.com/lightninglabs/gozmq v0.0.0-20180324010646-462a8a753885/go.mod h1:KUh15naRlx/TmUMFS/p4JJrCrE6F7RGF7rsnvuu45E4= github.com/lightninglabs/neutrino v0.0.0-20181017011010-4d6069299130/go.mod h1:KJq43Fu9ceitbJsSXMILcT4mGDNI/crKmPIkDOZXFyM= -github.com/lightninglabs/neutrino v0.0.0-20181017011010-c86e4463aec4e292dd46c7b506d8dfc9cd3fe031/go.mod h1:Y8IaaFZEKKGiyuRmUmKLR/n9+8m61mMDTkQBIMTc/Fw= -github.com/lightninglabs/neutrino v0.0.0-20181130031424-c86e4463aec4 h1:ayVtgne10h+3hvfhOULWbkoVUNy84XRuKOH7SkHxxTY= -github.com/lightninglabs/neutrino v0.0.0-20181130031424-c86e4463aec4/go.mod h1:Y8IaaFZEKKGiyuRmUmKLR/n9+8m61mMDTkQBIMTc/Fw= +github.com/lightninglabs/neutrino v0.0.0-20181017011010-8d09312ac266916a00d367abeaf05fbd8bccf5d8/go.mod h1:/ie0+o5CLo6NDM52EpoMAJsMPq25DqpK1APv6MzZj7U= +github.com/lightninglabs/neutrino v0.0.0-20181130220745-8d09312ac266 h1:2WHiUpriTMc4cLWvS4syzNHLS9+hPVLJjNeZuhq5HR4= +github.com/lightninglabs/neutrino v0.0.0-20181130220745-8d09312ac266/go.mod h1:/ie0+o5CLo6NDM52EpoMAJsMPq25DqpK1APv6MzZj7U= github.com/lightningnetwork/lightning-onion v0.0.0-20180605012408-ac4d9da8f1d6 h1:ONLGrYJVQdbtP6CE/ff1KNWZtygRGEh12RzonTiCzPs= github.com/lightningnetwork/lightning-onion v0.0.0-20180605012408-ac4d9da8f1d6/go.mod h1:8EgEt4a/NUOVQd+3kk6n9aZCJ1Ssj96Pb6lCrci+6oc= github.com/ltcsuite/ltcd v0.0.0-20180701083835-cdab10132e8c h1:rdKAF0qixVZQy+Hkrojg2vHTZOxJEHns2ymbevTDPms=