Skip to content
This repository was archived by the owner on Feb 25, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions armbian/base/config/redis/factorysettings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ SET base:hostname bitbox-base
SET base:update:allow-unsigned 0
SET base:updating 0
SET base:setup 0
ZADD base:descriptionCode 0 0
SET base:stateCode 0

SET middleware:passwordSetup 0
SET middleware:datadir /data/bbbmiddleware
Expand Down
2 changes: 1 addition & 1 deletion middleware/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.13

require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/digitalbitbox/bitbox02-api-go v0.0.0-20191122093321-5bacb3c08094
github.com/digitalbitbox/bitbox02-api-go v0.0.0-20191204135529-eb28ed7e9cbd
github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6
github.com/gomodule/redigo v2.0.0+incompatible
github.com/gorilla/mux v1.7.3
Expand Down
4 changes: 2 additions & 2 deletions middleware/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ 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/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/digitalbitbox/bitbox02-api-go v0.0.0-20191122093321-5bacb3c08094 h1:jcYoFlcJJQWJENsG2HPNEnp0jNx8H2pmvIv3oa9qLyE=
github.com/digitalbitbox/bitbox02-api-go v0.0.0-20191122093321-5bacb3c08094/go.mod h1:yMwrh5lnSF+UDy+PLdCySxWHZubd2Tk/t2EQ1++4mgA=
github.com/digitalbitbox/bitbox02-api-go v0.0.0-20191204135529-eb28ed7e9cbd h1:K29fNVgdarWFPuhnR05ZdZYuNeMe63Ym/18nJQohwsU=
github.com/digitalbitbox/bitbox02-api-go v0.0.0-20191204135529-eb28ed7e9cbd/go.mod h1:yMwrh5lnSF+UDy+PLdCySxWHZubd2Tk/t2EQ1++4mgA=
github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6 h1:u/UEqS66A5ckRmS4yNpjmVH56sVtS/RfclBAYocb4as=
github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
Expand Down
36 changes: 36 additions & 0 deletions middleware/src/logtags/logtags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package logtags

// These LogTags are shared logtags between the Middleware and the Supervisor.
// The supervisor watches these and triggers the corresponding handler.
const (
// LogTagMWUpdateStart is logged by the middleware when the update progress
// is started. This triggers the Supervisor to set the
// `BitBoxBaseHeartbeatRequest_DOWNLOAD_UPDATE` descriptionCode to active and
// sets the `BitBoxBaseHeartbeatRequest_UPDATE_FAILED` descriptionCode to
// inactive.
LogTagMWUpdateStart string = "LogTag:Middleware:Base_Image_Update_Start"

// LogTagMWUpdateSuccess is logged by the middleware when the update progress
// ends with the success case. This triggers the supervisor to set the
// `BitBoxBaseHeartbeatRequest_DOWNLOAD_UPDATE` descriptionCode to inactive.
LogTagMWUpdateSuccess string = "LogTag:Middleware:Base_Image_Update_Success"

// LogTagMWUpdateFailure is logged by the middleware when the update progress
// ends with the success case. This triggers the supervisor to set the
// `BitBoxBaseHeartbeatRequest_DOWNLOAD_UPDATE` descriptionCode to inactive
// and sets the `BitBoxBaseHeartbeatRequest_UPDATE_FAILED` descriptionCode to
// active.
LogTagMWUpdateFailure string = "LogTag:Middleware:Base_Image_Update_Failure"

// LogTagMWReboot is logged by the middleware when a Base reboot is started
// via RPC. This triggers the supervisor to set the descriptionCode
// `BitBoxBaseHeartbeatRequest_REBOOT` to active. This descriptionCode is
// reset on every start of the Supervisor.
LogTagMWReboot string = "LogTag:Middleware:Base_Reboot"

// LogTagMWShutdown is logged by the middleware when a Base shutdown is
// started via RPC. This triggers the supervisor to set the descriptionCode
// `BitBoxBaseHeartbeatRequest_SHUTDOWN` to active. This descriptionCode is
// reset on every start of the Supervisor.
LogTagMWShutdown string = "LogTag:Middleware:Base_Shutdown"
)
1 change: 1 addition & 0 deletions middleware/src/redis/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ const (
MiddlewareAuth BaseRedisKey = "middleware:auth"
BaseSetupDone BaseRedisKey = "base:setup"
BaseSSHDPasswordLogin BaseRedisKey = "base:sshd:passwordlogin"
BitcoindIBDClearnet BaseRedisKey = "bitcoind:ibd-clearnet"
)
46 changes: 46 additions & 0 deletions middleware/src/redis/redis.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package redis implements a communication interface with the redis server
// running on the BitBoxBase.
package redis

import (
Expand All @@ -15,6 +17,9 @@ type Redis interface {
GetInt(BaseRedisKey) (int, error)
GetString(BaseRedisKey) (string, error)
SetString(BaseRedisKey, string) error
AddToSortedSet(BaseRedisKey, int, string) error
RemoveFromSortedSet(BaseRedisKey, string) error
GetTopFromSortedSet(BaseRedisKey) (string, error)
}

// Client is a redis client
Expand Down Expand Up @@ -111,6 +116,47 @@ func (c Client) SetString(key BaseRedisKey, value string) error {
return nil
}

// AddToSortedSet adds a element to a redis sorted set. The interger score
// defines the position in the sorted set.
//
// Note: Redis supports double precision for scores, but that's not implemented
// here yet. Additionally Redis supports multiple insertions in one call. That's
// not implemented here either.
func (c Client) AddToSortedSet(key BaseRedisKey, score int, element string) error {
conn := c.getConnection()
_, err := conn.Do("ZADD", key, score, element)
if err != nil {
return fmt.Errorf("could not ZADD key %s: %w", key, err)
}
return nil
}

// RemoveFromSortedSet removes an element from a Redis sorted set if present.
func (c Client) RemoveFromSortedSet(key BaseRedisKey, element string) error {
conn := c.getConnection()
_, err := conn.Do("ZREM", key, element)
if err != nil {
return fmt.Errorf("could not ZREM key %s element %s: %w", key, element, err)
}
return nil
}

// GetTopFromSortedSet gets the element with the hightest score from a Redis
// sorted set.
func (c Client) GetTopFromSortedSet(key BaseRedisKey) (string, error) {
conn := c.getConnection()
elements, err := redis.Strings(conn.Do("ZREVRANGE", key, 0, 0))
if err != nil {
return "", fmt.Errorf("could not ZREVRANGE key %s: %w", key, err)
}
// The redis call should only ever return one element for `ZREVRANGE <key> 0 0`
if len(elements) != 1 {
return "", fmt.Errorf("expected exactly one element, but got %d", len(elements))
}

return elements[0], nil
}

// ConvertErrorToErrorResponse converts an error returned by Redis to an ErrorResponse
func (c Client) ConvertErrorToErrorResponse(err error) rpcmessages.ErrorResponse {
return rpcmessages.ErrorResponse{
Expand Down
19 changes: 19 additions & 0 deletions middleware/src/redis/redis_mock.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package redis

import (
"log"
"strconv"

"github.com/digitalbitbox/bitbox-base/middleware/src/rpcmessages"
Expand Down Expand Up @@ -41,6 +42,24 @@ func (mc *MockClient) GetBool(key BaseRedisKey) (val bool, err error) {
return valAsInt == 1, err
}

// AddToSortedSet is a dummy that does nothing but printing the arguments.
func (mc *MockClient) AddToSortedSet(key BaseRedisKey, score int, element string) error {
log.Printf("AddToSortedSet dummy: key %q, score %q, element %q", key, score, element)
return nil
}

// RemoveFromSortedSet is a dummy that does nothing but printing the arguments.
func (mc *MockClient) RemoveFromSortedSet(key BaseRedisKey, element string) error {
log.Printf("RemoveFromSortedSet dummy: key %q, element %q", key, element)
return nil
}

// GetTopFromSortedSet is a dummy that does nothing but printing the arguments.
func (mc *MockClient) GetTopFromSortedSet(key BaseRedisKey) (string, error) {
log.Printf("GetTopFromSortedSet dummy: key %q", key)
return "dummy mock", nil
}

// GetString gets an string for a given key.
func (mc *MockClient) GetString(key BaseRedisKey) (val string, err error) {
return mc.mockRedisMap[string(key)], nil
Expand Down
6 changes: 3 additions & 3 deletions tools/bbbsupervisor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/digitalbitbox/bitbox-base/tools/bbbsupervisor
go 1.13

require (
github.com/gomodule/redigo v2.0.0+incompatible
github.com/stretchr/testify v1.4.0 // indirect
github.com/tidwall/gjson v1.3.2
github.com/digitalbitbox/bitbox-base/middleware v0.0.0-20191204153728-1128dd782517
github.com/digitalbitbox/bitbox02-api-go v0.0.0-20191204135529-eb28ed7e9cbd
github.com/tidwall/gjson v1.3.4
)
56 changes: 54 additions & 2 deletions tools/bbbsupervisor/go.sum
Original file line number Diff line number Diff line change
@@ -1,19 +1,71 @@
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY=
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
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/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/digitalbitbox/bitbox-base/middleware v0.0.0-20191204153728-1128dd782517 h1:b34ka1KKniF6hzIW+5n7sDfBhEfzzAZAiE6srtmSnDM=
github.com/digitalbitbox/bitbox-base/middleware v0.0.0-20191204153728-1128dd782517/go.mod h1:UidGto4vnuuvotQdGoNHY5ipVmDWHkbnkaAo3Q5qTPw=
github.com/digitalbitbox/bitbox02-api-go v0.0.0-20191204135529-eb28ed7e9cbd h1:K29fNVgdarWFPuhnR05ZdZYuNeMe63Ym/18nJQohwsU=
github.com/digitalbitbox/bitbox02-api-go v0.0.0-20191204135529-eb28ed7e9cbd/go.mod h1:yMwrh5lnSF+UDy+PLdCySxWHZubd2Tk/t2EQ1++4mgA=
github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/tidwall/gjson v1.3.2 h1:+7p3qQFaH3fOMXAJSrdZwGKcOO/lYdGS0HqGhPqDdTI=
github.com/tidwall/gjson v1.3.2/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/tidwall/gjson v1.3.4 h1:On5waDnyKKk3SWE4EthbjjirAWXp43xx5cKCUZY1eZw=
github.com/tidwall/gjson v1.3.4/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc=
github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191104094858-e8c54fb511f6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191105231009-c1f44814a5cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
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/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5 h1:ymVxjfMaHvXD8RqPRmzHHsB3VvucivSkIAvJFDI5O3c=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
92 changes: 0 additions & 92 deletions tools/bbbsupervisor/redis/redis.go

This file was deleted.

2 changes: 1 addition & 1 deletion tools/bbbsupervisor/supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ import (
"log"
"time"

"github.com/digitalbitbox/bitbox-base/middleware/src/redis"
"github.com/digitalbitbox/bitbox-base/tools/bbbsupervisor/prometheus"
"github.com/digitalbitbox/bitbox-base/tools/bbbsupervisor/redis"
"github.com/digitalbitbox/bitbox-base/tools/bbbsupervisor/watcher"
"github.com/digitalbitbox/bitbox-base/tools/bbbsupervisor/watcher/logwatcher"
"github.com/digitalbitbox/bitbox-base/tools/bbbsupervisor/watcher/prometheuswatcher"
Expand Down
9 changes: 5 additions & 4 deletions tools/bbbsupervisor/supervisor/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ import (
"log"
"os/exec"
"strings"

"github.com/digitalbitbox/bitbox-base/middleware/src/redis"
)

// unsetClearnetIDB unsets (0 - download blocks over Tor) the ibdClearnetRedisKey if set.
// The key can only be set back to 1 (download blocks over clearnet) via RPC.
func (s *Supervisor) unsetClearnetIDB() (err error) {
const ibdClearnetRedisKey string = "bitcoind:ibd-clearnet"
isIBDClearnet, err := s.redis.GetInt(ibdClearnetRedisKey)
isIBDClearnet, err := s.redis.GetInt(redis.BitcoindIBDClearnet)
if err != nil {
return fmt.Errorf("getting redis key %s failed: %v", ibdClearnetRedisKey, err)
return fmt.Errorf("getting redis key %s failed: %s", redis.BitcoindIBDClearnet, err)
}
if isIBDClearnet == 1 {
log.Printf("IDB finished. Setting %s to %d.\n", ibdClearnetRedisKey, 0)
log.Printf("IDB finished. Setting %s to %d.\n", redis.BitcoindIBDClearnet, 0)
err := s.setBBBConfigValue("bitcoin_ibd_clearnet", "false")
if err != nil {
return fmt.Errorf("disabling bitcoin_ibd_clearnet via BBB config script failed: %v", err)
Expand Down
Loading