Skip to content

Commit

Permalink
Merge pull request #15 from TRON-US/service-domains
Browse files Browse the repository at this point in the history
BTFS-1011: Add Services for external services config
  • Loading branch information
taiyangc authored Nov 15, 2019
2 parents 2093f51 + b09bb19 commit 92647e8
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
9 changes: 5 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ type Config struct {
Swarm SwarmConfig
Pubsub PubsubConfig

Provider Provider
Reprovider Reprovider
StatusServerDomain string
Experimental Experiments
Services Services // External service domains and info

Provider Provider
Reprovider Reprovider
Experimental Experiments
}

const (
Expand Down
14 changes: 13 additions & 1 deletion init.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func Init(out io.Writer, nBitsForKeypair int, keyType string, importKey string,
},
APICommands: []string{},
},
StatusServerDomain: "https://db.btfs.io",
Services: DefaultServicesConfig(),
Reprovider: Reprovider{
Interval: "12h",
Strategy: "all",
Expand Down Expand Up @@ -165,6 +165,18 @@ func DefaultDatastoreConfig() Datastore {
}
}

// DefaultServicesConfig returns the default set of configs for external services.
func DefaultServicesConfig() Services {
return Services{
StatusServerDomain: "https://db.btfs.io", // TODO: future -> status.btfs.io
HubDomain: "https://hub.btfs.io",
EscrowDomain: "https://escrow.btfs.io",
GuardDomain: "https://guard.btfs.io",
EscrowPubKeys: []string{}, // TODO: TBD
GuardPubKeys: []string{}, // TODO: TBD
}
}

// identityConfig initializes a new identity.
func identityConfig(out io.Writer, nbits int, keyType string, importKey string) (Identity, error) {
// TODO guard higher up
Expand Down
16 changes: 16 additions & 0 deletions migrations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package config

import (
"reflect"
)

// MigrateConfig migrates config options to the latest known version
// It may correct incompatible configs as well
func MigrateConfig(cfg *Config) bool {
emptyServices := Services{}
if reflect.DeepEqual(cfg.Services, emptyServices) {
cfg.Services = DefaultServicesConfig()
return true
}
return false
}
11 changes: 11 additions & 0 deletions services.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package config

type Services struct {
StatusServerDomain string
HubDomain string
EscrowDomain string
GuardDomain string

EscrowPubKeys []string
GuardPubKeys []string
}

0 comments on commit 92647e8

Please sign in to comment.