Skip to content

Commit

Permalink
Fix balance & dbType at startup (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
altafan authored May 31, 2023
1 parent e90694a commit 09b4bb1
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 56 deletions.
46 changes: 30 additions & 16 deletions cmd/oceand/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,17 @@ func main() {
ExtraIPs: tlsExtraIPs,
ExtraDomains: tlsExtraDomains,
}
repoManagerConfig := dbConfigFromType()
appCfg := &appconfig.AppConfig{
Version: version,
Commit: commit,
Date: date,
RootPath: rootPath,
Network: network,
UtxoExpiryDuration: utxoExpiryDuration * time.Second,
RepoManagerType: dbType,
BlockchainScannerType: bcScannerType,
RepoManagerConfig: postgresdb.DbConfig{
DbUser: dbUser,
DbPassword: dbPassword,
DbHost: dbHost,
DbPort: dbPort,
DbName: dbName,
MigrationSourceURL: migrationSourceURL,
},
Version: version,
Commit: commit,
Date: date,
RootPath: rootPath,
Network: network,
UtxoExpiryDuration: utxoExpiryDuration * time.Second,
RepoManagerType: dbType,
BlockchainScannerType: bcScannerType,
RepoManagerConfig: repoManagerConfig,
BlockchainScannerConfig: bcScannerConfig,
}

Expand All @@ -113,3 +107,23 @@ func main() {
signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT)
<-sigChan
}

func dbConfigFromType() interface{} {
switch dbType {
case "postgres":
return postgresdb.DbConfig{
DbUser: dbUser,
DbPassword: dbPassword,
DbHost: dbHost,
DbPort: dbPort,
DbName: dbName,
MigrationSourceURL: migrationSourceURL,
}
case "badger":
return filepath.Join(datadir, "db")
case "inmemory":
fallthrough
default:
return nil
}
}
28 changes: 14 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ require (
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.1.3
github.com/spf13/viper v1.12.0
github.com/stretchr/testify v1.8.0
github.com/stretchr/testify v1.8.1
github.com/timshannon/badgerhold/v4 v4.0.2
github.com/vulpemventures/go-bip39 v1.0.2
github.com/vulpemventures/go-elements v0.4.5
github.com/vulpemventures/neutrino-elements v0.1.3
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90
golang.org/x/net v0.0.0-20220722155237-a158d28d115b
google.golang.org/grpc v1.46.2
google.golang.org/protobuf v1.28.0
golang.org/x/crypto v0.1.0
golang.org/x/net v0.7.0
google.golang.org/grpc v1.53.0
google.golang.org/protobuf v1.29.1
)

require (
Expand All @@ -39,15 +39,15 @@ require (
github.com/btcsuite/btcd/btcutil/psbt v1.1.4 // indirect
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v0.0.0-20210429001901-424d2337a529 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
Expand All @@ -64,7 +64,7 @@ require (
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.11.0 // indirect
github.com/jackc/puddle v1.2.1 // indirect
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 // indirect
github.com/kkdai/bstream v0.0.0-20181106074824-b3251f7901ec // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
Expand All @@ -76,19 +76,19 @@ require (
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.4.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
github.com/vulpemventures/fastsha256 v0.0.0-20160815193821-637e65642941 // indirect
github.com/vulpemventures/go-secp256k1-zkp v1.1.5 // indirect
go.opencensus.io v0.23.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/text v0.3.8 // indirect
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 09b4bb1

Please sign in to comment.