diff --git a/.travis.yml b/.travis.yml index 8f8eada..e28fa2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,13 @@ language: go go: - - "1.9.4" - - "1.10" + - "1.11.x" sudo: false -before_install: - - GLIDE_TAG=v0.12.3 - - GLIDE_DOWNLOAD="https://github.com/Masterminds/glide/releases/download/$GLIDE_TAG/glide-$GLIDE_TAG-linux-amd64.tar.gz" - - curl -L $GLIDE_DOWNLOAD | tar -xvz - - export PATH=$PATH:$PWD/linux-amd64/ - - glide install install: - - go install -v $(glide novendor) - - go get -v golang.org/x/tools/cmd/cover - - go get -v golang.org/x/lint/golint - - go get -v github.com/davecgh/go-spew/spew + - GO111MODULE=on go install -v ./... + - GO111MODULE=off go get -v golang.org/x/tools/cmd/cover + - GO111MODULE=off go get -v golang.org/x/lint/golint + - GO111MODULE=off go get -v github.com/davecgh/go-spew/spew script: - export PATH=$PATH:$HOME/gopath/bin + - export GO111MODULE=on - ./goclean.sh diff --git a/glide.lock b/glide.lock deleted file mode 100644 index 5de3592..0000000 --- a/glide.lock +++ /dev/null @@ -1,136 +0,0 @@ -hash: fd238231109616b821cfb40783aab5b96fa5d9026de065411507b5c3431166e5 -updated: 2018-10-16T18:17:51.368476548-07:00 -imports: -- name: github.com/aead/siphash - version: 83563a290f60225eb120d724600b9690c3fb536f -- name: github.com/btcsuite/btcd - version: d81d8877b8f327112e94e814937143a71d1692a7 - subpackages: - - addrmgr - - blockchain - - btcec - - btcjson - - chaincfg - - chaincfg/chainhash - - connmgr - - database - - peer - - rpcclient - - txscript - - wire -- name: github.com/btcsuite/btclog - version: 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a -- name: github.com/btcsuite/btcutil - version: ab6388e0c60ae4834a1f57511e20c17b5f78be4b - subpackages: - - base58 - - bech32 - - gcs - - gcs/builder - - hdkeychain -- name: github.com/btcsuite/go-socks - version: 4720035b7bfd2a9bb130b1c184f8bbe41b6f0d0f - subpackages: - - socks -- name: github.com/btcsuite/golangcrypto - version: 53f62d9b43e87a6c56975cf862af7edf33a8d0df - subpackages: - - nacl/secretbox - - pbkdf2 - - poly1305 - - ripemd160 - - salsa20/salsa - - scrypt - - ssh/terminal -- name: github.com/btcsuite/websocket - version: 31079b6807923eb23992c421b114992b95131b55 -- name: github.com/coreos/bbolt - version: 4f5275f4ebbf6fe7cb772de987fa96ee674460a7 -- name: github.com/davecgh/go-spew - version: ecdeabc65495df2dec95d7c4a4c3e021903035e5 - subpackages: - - spew -- name: github.com/golang/protobuf - version: b27b920f9e71b439b873b17bf99f56467623814a - subpackages: - - proto - - ptypes - - ptypes/any - - ptypes/duration - - ptypes/timestamp -- name: github.com/jessevdk/go-flags - version: 1679536dcc895411a9f5848d9a0250be7856448c -- name: github.com/jrick/logrotate - version: a93b200c26cbae3bb09dd0dc2c7c7fe1468a034a - subpackages: - - rotator -- name: github.com/kkdai/bstream - version: f391b8402d23024e7c0f624b31267a89998fca95 -- name: github.com/lightninglabs/gozmq - version: 462a8a75388506b68f76661af8d649f0b88e5301 -- name: github.com/lightninglabs/neutrino - version: 4d60692991302a44509d1a9234ccd51373c120b4 - subpackages: - - cache - - cache/lru - - filterdb - - headerfs - - headerlist -- name: golang.org/x/crypto - version: 9419663f5a44be8b34ca85f08abc5fe1be11f8a3 - subpackages: - - ripemd160 - - ssh/terminal -- name: golang.org/x/net - version: 922f4815f713f213882e8ef45e0d315b164d705c - subpackages: - - context - - http/httpguts - - http2 - - http2/hpack - - idna - - internal/timeseries - - trace -- name: golang.org/x/sys - version: 3b58ed4ad3395d483fc92d5d14123ce2c3581fec - subpackages: - - unix - - windows -- name: golang.org/x/text - version: 6e3c4e7365ddcc329f090f96e4348398f6310088 - subpackages: - - secure/bidirule - - transform - - unicode/bidi - - unicode/norm -- name: google.golang.org/genproto - version: c66870c02cf823ceb633bcd05be3c7cda29976f4 - subpackages: - - googleapis/rpc/status -- name: google.golang.org/grpc - version: 41344da2231b913fa3d983840a57a6b1b7b631a1 - subpackages: - - balancer - - balancer/base - - balancer/roundrobin - - channelz - - codes - - connectivity - - credentials - - encoding - - encoding/proto - - grpclb/grpc_lb_v1/messages - - grpclog - - internal - - keepalive - - metadata - - naming - - peer - - resolver - - resolver/dns - - resolver/passthrough - - stats - - status - - tap - - transport -testImports: [] diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index c046ee8..0000000 --- a/glide.yaml +++ /dev/null @@ -1,50 +0,0 @@ -package: github.com/btcsuite/btcwallet -import: -- package: github.com/coreos/bbolt - version: 4f5275f4ebbf6fe7cb772de987fa96ee674460a7 -- package: github.com/btcsuite/btcd - version: d81d8877b8f327112e94e814937143a71d1692a7 - subpackages: - - blockchain - - btcec - - btcjson - - chaincfg - - chaincfg/chainhash - - txscript - - wire -- package: github.com/btcsuite/btclog -- package: github.com/btcsuite/btcutil - version: ab6388e0c60ae4834a1f57511e20c17b5f78be4b - subpackages: - - hdkeychain -- package: github.com/lightninglabs/neutrino - version: 4d60692991302a44509d1a9234ccd51373c120b4 -- package: github.com/btcsuite/golangcrypto - subpackages: - - nacl/secretbox - - ripemd160 - - scrypt - - ssh/terminal -- package: github.com/btcsuite/websocket -- package: github.com/golang/protobuf - subpackages: - - proto -- package: github.com/jessevdk/go-flags - version: 1679536dcc895411a9f5848d9a0250be7856448c -- package: golang.org/x/net - subpackages: - - context -- package: google.golang.org/grpc - version: 41344da2231b913fa3d983840a57a6b1b7b631a1 - subpackages: - - codes - - credentials - - grpclog -- package: github.com/jrick/logrotate - subpackages: - - rotator -- package: github.com/lightninglabs/gozmq -testImport: -- package: github.com/davecgh/go-spew - subpackages: - - spew diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..3d9bb43 --- /dev/null +++ b/go.mod @@ -0,0 +1,33 @@ +module github.com/btcsuite/btcwallet + +require ( + github.com/aead/siphash v1.0.1 // indirect + github.com/boltdb/bolt v1.3.1 // indirect + github.com/btcsuite/btcd v0.0.0-20180823030728-d81d8877b8f3 + github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f + github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a + github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect + github.com/btcsuite/golangcrypto v0.0.0-20150304025918-53f62d9b43e8 + github.com/btcsuite/goleveldb v1.0.0 // indirect + github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 + github.com/coreos/bbolt v0.0.0-20180223184059-7ee3ded59d4835e10f3e7d0f7603c42aa5e83820 + github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495 + github.com/fsnotify/fsnotify v1.4.7 // indirect + github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect + github.com/golang/protobuf v0.0.0-20180821051752-b27b920f9e71 + github.com/hpcloud/tail v1.0.0 // indirect + github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89 + github.com/jrick/logrotate v1.0.0 + github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 // indirect + github.com/lightninglabs/gozmq v0.0.0-20180324010646-462a8a753885 + github.com/lightninglabs/neutrino v0.0.0-20181017011010-4d6069299130 + go.etcd.io/bbolt v1.3.0 // indirect + golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44 + golang.org/x/net v0.0.0-20180821023952-922f4815f713 + golang.org/x/sync v0.0.0-20181108010431-42b317875d0f // indirect + golang.org/x/sys v0.0.0-20180821140842-3b58ed4ad339 // indirect + google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 // indirect + google.golang.org/grpc v1.12.0 + gopkg.in/fsnotify.v1 v1.4.7 // indirect + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..7282e79 --- /dev/null +++ b/go.sum @@ -0,0 +1,71 @@ +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/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 h1:735/yW58gql5+VuK/pAczEiSXEfNSqLyQsmmbx3cPMI= +github.com/btcsuite/btcd v0.0.0-20180823030728-d81d8877b8f3/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/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 v1.0.0 h1:Tvd0BfvqX9o823q1j2UZ/epQo09eJh6dTcRp79ilIN4= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= +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/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 h1:6IyqGr3fnd0tM3YxipK27TUskaOVUjU2nG45yzwcQKY= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/protobuf v0.0.0-20180821051752-b27b920f9e71 h1:lw3A98tUozFBzO6h57nMVyeuMpZKhIGBPXcBAhwjSs0= +github.com/golang/protobuf v0.0.0-20180821051752-b27b920f9e71/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89 h1:12K8AlpT0/6QUXSfV0yi4Q0jkbq8NDtIKFtF61AoqV0= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jrick/logrotate v1.0.0 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI= +github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= +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/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 h1:6sZc23+5VbEz2uiHxW12xvS4JYZ3hhgkE5qxzwxaXzg= +github.com/lightninglabs/neutrino v0.0.0-20181017011010-4d6069299130/go.mod h1:KJq43Fu9ceitbJsSXMILcT4mGDNI/crKmPIkDOZXFyM= +github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.1 h1:PZSj/UFNaVp3KxrzHOcS7oyuWA7LoOY/77yCTEFu21U= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +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 h1:9lP3x0pW80sDI6t1UMSLA4to18W7R7imwAI/sWS9S8Q= +golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180821023952-922f4815f713 h1:rMJUcaDGbG+X967I4zGKCq5laYqcGKJmpB+3jhpOhPw= +golang.org/x/net v0.0.0-20180821023952-922f4815f713/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +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 h1:0w2EXzxbB03VAzqwe3csbadu4CPhMRtxCz/rjw9gkic= +golang.org/x/sys v0.0.0-20180821140842-3b58ed4ad339/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= +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 h1:Mm8atZtkT+P6R43n/dqNDWkPPu5BwRVu/1rJnJCeZH8= +google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/goclean.sh b/goclean.sh index 6422d0c..0a123f9 100755 --- a/goclean.sh +++ b/goclean.sh @@ -7,12 +7,17 @@ set -ex +test_targets=$(go list ./...) + # Automatic checks -test -z "$(go fmt $(glide novendor) | tee /dev/stderr)" +test -z "$(go fmt $test_targets | tee /dev/stderr)" + # test -z "$(goimports -l -w . | tee /dev/stderr)" -test -z "$(for package in $(glide novendor); do golint $package; done | grep -v 'ALL_CAPS\|OP_\|NewFieldVal\|RpcCommand\|RpcRawCommand\|RpcSend\|Dns\|api.pb.go\|StartConsensusRpc\|factory_test.go\|legacy\|UnstableAPI' | tee /dev/stderr)" -test -z "$(go vet $(glide novendor) 2>&1 | grep -v '^exit status \|Example\|newestSha\| not a string in call to Errorf$' | tee /dev/stderr)" -env GORACE="history_size=7 halt_on_errors=1" go test -race $(glide novendor) +test -z "$(for package in $test_targets; do golint $package; done | grep -v 'ALL_CAPS\|OP_\|NewFieldVal\|RpcCommand\|RpcRawCommand\|RpcSend\|Dns\|api.pb.go\|StartConsensusRpc\|factory_test.go\|legacy\|UnstableAPI' | tee /dev/stderr)" + +test -z "$(go vet $test_targets 2>&1 | grep -v '^exit status \|Example\|newestSha\| not a string in call to Errorf$' | tee /dev/stderr)" + +env GORACE="history_size=7 halt_on_errors=1" go test -v -race $test_targets # Run test coverage on each subdirectories and merge the coverage profile. diff --git a/walletdb/bdb/db.go b/walletdb/bdb/db.go index 8685adc..86ba173 100644 --- a/walletdb/bdb/db.go +++ b/walletdb/bdb/db.go @@ -16,31 +16,31 @@ import ( func convertErr(err error) error { switch err { // Database open/create errors. - case bolt.ErrDatabaseNotOpen: + case bbolt.ErrDatabaseNotOpen: return walletdb.ErrDbNotOpen - case bolt.ErrInvalid: + case bbolt.ErrInvalid: return walletdb.ErrInvalid // Transaction errors. - case bolt.ErrTxNotWritable: + case bbolt.ErrTxNotWritable: return walletdb.ErrTxNotWritable - case bolt.ErrTxClosed: + case bbolt.ErrTxClosed: return walletdb.ErrTxClosed // Value/bucket errors. - case bolt.ErrBucketNotFound: + case bbolt.ErrBucketNotFound: return walletdb.ErrBucketNotFound - case bolt.ErrBucketExists: + case bbolt.ErrBucketExists: return walletdb.ErrBucketExists - case bolt.ErrBucketNameRequired: + case bbolt.ErrBucketNameRequired: return walletdb.ErrBucketNameRequired - case bolt.ErrKeyRequired: + case bbolt.ErrKeyRequired: return walletdb.ErrKeyRequired - case bolt.ErrKeyTooLarge: + case bbolt.ErrKeyTooLarge: return walletdb.ErrKeyTooLarge - case bolt.ErrValueTooLarge: + case bbolt.ErrValueTooLarge: return walletdb.ErrValueTooLarge - case bolt.ErrIncompatibleValue: + case bbolt.ErrIncompatibleValue: return walletdb.ErrIncompatibleValue } @@ -52,7 +52,7 @@ func convertErr(err error) error { // read-write and implements the walletdb Tx interfaces. The transaction // provides a root bucket against which all read and writes occur. type transaction struct { - boltTx *bolt.Tx + boltTx *bbolt.Tx } func (tx *transaction) ReadBucket(key []byte) walletdb.ReadBucket { @@ -101,7 +101,7 @@ func (tx *transaction) Rollback() error { // bucket is an internal type used to represent a collection of key/value pairs // and implements the walletdb Bucket interfaces. -type bucket bolt.Bucket +type bucket bbolt.Bucket // Enforce bucket implements the walletdb Bucket interfaces. var _ walletdb.ReadWriteBucket = (*bucket)(nil) @@ -111,7 +111,7 @@ var _ walletdb.ReadWriteBucket = (*bucket)(nil) // // This function is part of the walletdb.ReadWriteBucket interface implementation. func (b *bucket) NestedReadWriteBucket(key []byte) walletdb.ReadWriteBucket { - boltBucket := (*bolt.Bucket)(b).Bucket(key) + boltBucket := (*bbolt.Bucket)(b).Bucket(key) // Don't return a non-nil interface to a nil pointer. if boltBucket == nil { return nil @@ -130,7 +130,7 @@ func (b *bucket) NestedReadBucket(key []byte) walletdb.ReadBucket { // // This function is part of the walletdb.Bucket interface implementation. func (b *bucket) CreateBucket(key []byte) (walletdb.ReadWriteBucket, error) { - boltBucket, err := (*bolt.Bucket)(b).CreateBucket(key) + boltBucket, err := (*bbolt.Bucket)(b).CreateBucket(key) if err != nil { return nil, convertErr(err) } @@ -143,7 +143,7 @@ func (b *bucket) CreateBucket(key []byte) (walletdb.ReadWriteBucket, error) { // // This function is part of the walletdb.Bucket interface implementation. func (b *bucket) CreateBucketIfNotExists(key []byte) (walletdb.ReadWriteBucket, error) { - boltBucket, err := (*bolt.Bucket)(b).CreateBucketIfNotExists(key) + boltBucket, err := (*bbolt.Bucket)(b).CreateBucketIfNotExists(key) if err != nil { return nil, convertErr(err) } @@ -156,7 +156,7 @@ func (b *bucket) CreateBucketIfNotExists(key []byte) (walletdb.ReadWriteBucket, // // This function is part of the walletdb.Bucket interface implementation. func (b *bucket) DeleteNestedBucket(key []byte) error { - return convertErr((*bolt.Bucket)(b).DeleteBucket(key)) + return convertErr((*bbolt.Bucket)(b).DeleteBucket(key)) } // ForEach invokes the passed function with every key/value pair in the bucket. @@ -169,7 +169,7 @@ func (b *bucket) DeleteNestedBucket(key []byte) error { // // This function is part of the walletdb.Bucket interface implementation. func (b *bucket) ForEach(fn func(k, v []byte) error) error { - return convertErr((*bolt.Bucket)(b).ForEach(fn)) + return convertErr((*bbolt.Bucket)(b).ForEach(fn)) } // Put saves the specified key/value pair to the bucket. Keys that do not @@ -178,7 +178,7 @@ func (b *bucket) ForEach(fn func(k, v []byte) error) error { // // This function is part of the walletdb.Bucket interface implementation. func (b *bucket) Put(key, value []byte) error { - return convertErr((*bolt.Bucket)(b).Put(key, value)) + return convertErr((*bbolt.Bucket)(b).Put(key, value)) } // Get returns the value for the given key. Returns nil if the key does @@ -190,7 +190,7 @@ func (b *bucket) Put(key, value []byte) error { // // This function is part of the walletdb.Bucket interface implementation. func (b *bucket) Get(key []byte) []byte { - return (*bolt.Bucket)(b).Get(key) + return (*bbolt.Bucket)(b).Get(key) } // Delete removes the specified key from the bucket. Deleting a key that does @@ -199,7 +199,7 @@ func (b *bucket) Get(key []byte) []byte { // // This function is part of the walletdb.Bucket interface implementation. func (b *bucket) Delete(key []byte) error { - return convertErr((*bolt.Bucket)(b).Delete(key)) + return convertErr((*bbolt.Bucket)(b).Delete(key)) } func (b *bucket) ReadCursor() walletdb.ReadCursor { @@ -211,7 +211,7 @@ func (b *bucket) ReadCursor() walletdb.ReadCursor { // // This function is part of the walletdb.Bucket interface implementation. func (b *bucket) ReadWriteCursor() walletdb.ReadWriteCursor { - return (*cursor)((*bolt.Bucket)(b).Cursor()) + return (*cursor)((*bbolt.Bucket)(b).Cursor()) } // cursor represents a cursor over key/value pairs and nested buckets of a @@ -221,7 +221,7 @@ func (b *bucket) ReadWriteCursor() walletdb.ReadWriteCursor { // modifications to the bucket, with the exception of cursor.Delete, invalidate // the cursor. After invalidation, the cursor must be repositioned, or the keys // and values returned may be unpredictable. -type cursor bolt.Cursor +type cursor bbolt.Cursor // Delete removes the current key/value pair the cursor is at without // invalidating the cursor. Returns ErrTxNotWritable if attempted on a read-only @@ -230,35 +230,35 @@ type cursor bolt.Cursor // // This function is part of the walletdb.Cursor interface implementation. func (c *cursor) Delete() error { - return convertErr((*bolt.Cursor)(c).Delete()) + return convertErr((*bbolt.Cursor)(c).Delete()) } // First positions the cursor at the first key/value pair and returns the pair. // // This function is part of the walletdb.Cursor interface implementation. func (c *cursor) First() (key, value []byte) { - return (*bolt.Cursor)(c).First() + return (*bbolt.Cursor)(c).First() } // Last positions the cursor at the last key/value pair and returns the pair. // // This function is part of the walletdb.Cursor interface implementation. func (c *cursor) Last() (key, value []byte) { - return (*bolt.Cursor)(c).Last() + return (*bbolt.Cursor)(c).Last() } // Next moves the cursor one key/value pair forward and returns the new pair. // // This function is part of the walletdb.Cursor interface implementation. func (c *cursor) Next() (key, value []byte) { - return (*bolt.Cursor)(c).Next() + return (*bbolt.Cursor)(c).Next() } // Prev moves the cursor one key/value pair backward and returns the new pair. // // This function is part of the walletdb.Cursor interface implementation. func (c *cursor) Prev() (key, value []byte) { - return (*bolt.Cursor)(c).Prev() + return (*bbolt.Cursor)(c).Prev() } // Seek positions the cursor at the passed seek key. If the key does not exist, @@ -266,19 +266,19 @@ func (c *cursor) Prev() (key, value []byte) { // // This function is part of the walletdb.Cursor interface implementation. func (c *cursor) Seek(seek []byte) (key, value []byte) { - return (*bolt.Cursor)(c).Seek(seek) + return (*bbolt.Cursor)(c).Seek(seek) } // db represents a collection of namespaces which are persisted and implements // the walletdb.Db interface. All database access is performed through // transactions which are obtained through the specific Namespace. -type db bolt.DB +type db bbolt.DB // Enforce db implements the walletdb.Db interface. var _ walletdb.DB = (*db)(nil) func (db *db) beginTx(writable bool) (*transaction, error) { - boltTx, err := (*bolt.DB)(db).Begin(writable) + boltTx, err := (*bbolt.DB)(db).Begin(writable) if err != nil { return nil, convertErr(err) } @@ -298,7 +298,7 @@ func (db *db) BeginReadWriteTx() (walletdb.ReadWriteTx, error) { // // This function is part of the walletdb.Db interface implementation. func (db *db) Copy(w io.Writer) error { - return convertErr((*bolt.DB)(db).View(func(tx *bolt.Tx) error { + return convertErr((*bbolt.DB)(db).View(func(tx *bbolt.Tx) error { return tx.Copy(w) })) } @@ -307,7 +307,7 @@ func (db *db) Copy(w io.Writer) error { // // This function is part of the walletdb.Db interface implementation. func (db *db) Close() error { - return convertErr((*bolt.DB)(db).Close()) + return convertErr((*bbolt.DB)(db).Close()) } // filesExists reports whether the named file or directory exists. @@ -327,6 +327,6 @@ func openDB(dbPath string, create bool) (walletdb.DB, error) { return nil, walletdb.ErrDbDoesNotExist } - boltDB, err := bolt.Open(dbPath, 0600, nil) + boltDB, err := bbolt.Open(dbPath, 0600, nil) return (*db)(boltDB), convertErr(err) }