Commit 0ee2f74d authored by suyanlong's avatar suyanlong

refactor repo package

parent 8c3e3ddb
Pipeline #7999 canceled with stages
...@@ -2,12 +2,11 @@ package repo ...@@ -2,12 +2,11 @@ package repo
import ( import (
"fmt" "fmt"
"github.com/meshplus/bitxhub-kit/fileutil"
"github.com/meshplus/bitxhub-kit/types"
"github.com/spf13/viper"
"path/filepath" "path/filepath"
"strings" "strings"
"time"
"github.com/meshplus/bitxhub-kit/fileutil"
"github.com/spf13/viper"
) )
const ( const (
...@@ -160,39 +159,3 @@ func UnmarshalConfig(repoRoot string) (*Config, error) { ...@@ -160,39 +159,3 @@ func UnmarshalConfig(repoRoot string) (*Config, error) {
return config, nil return config, nil
} }
type Mode struct {
Type string `toml:"type" json:"type"`
Relay Relay `toml:"relay" json:"relay"`
// TODO 连接节点
Peers []string `toml:"peers" json:"peers"`
Connectors []string `toml:"connectors" json:"connectors"`
Providers uint64 `toml:"providers" json:"providers"`
}
// Relay are configs about bitxhub
type Relay struct {
Addrs []string `toml:"addrs" json:"addrs"`
TimeoutLimit time.Duration `mapstructure:"timeout_limit" json:"timeout_limit"`
Quorum uint64 `toml:"quorum" json:"quorum"`
Validators []string `toml:"validators" json:"validators"`
}
type Direct struct {
Peers []string `toml:"peers" json:"peers"`
}
type Union struct {
Addrs []string `toml:"addrs" json:"addrs"`
Connectors []string `toml:"connectors" json:"connectors"`
Providers uint64 `toml:"providers" json:"providers"`
}
// GetValidators gets validator address of bitxhub
func (relay *Relay) GetValidators() []*types.Address {
validators := make([]*types.Address, 0)
for _, v := range relay.Validators {
validators = append(validators, types.NewAddressByStr(v))
}
return validators
}
package repo
import (
"time"
"github.com/meshplus/bitxhub-kit/types"
)
type Mode struct {
Type string `toml:"type" json:"type"`
Relay Relay `toml:"relay" json:"relay"`
// TODO 连接节点
Peers []string `toml:"peers" json:"peers"`
Connectors []string `toml:"connectors" json:"connectors"`
Providers uint64 `toml:"providers" json:"providers"`
}
// Relay are configs about bitxhub
type Relay struct {
Addrs []string `toml:"addrs" json:"addrs"`
TimeoutLimit time.Duration `mapstructure:"timeout_limit" json:"timeout_limit"`
Quorum uint64 `toml:"quorum" json:"quorum"`
Validators []string `toml:"validators" json:"validators"`
}
type Direct struct {
Peers []string `toml:"peers" json:"peers"`
}
type Union struct {
Addrs []string `toml:"addrs" json:"addrs"`
Connectors []string `toml:"connectors" json:"connectors"`
Providers uint64 `toml:"providers" json:"providers"`
}
// GetValidators gets validator address of bitxhub
func (relay *Relay) GetValidators() []*types.Address {
validators := make([]*types.Address, 0)
for _, v := range relay.Validators {
validators = append(validators, types.NewAddressByStr(v))
}
return validators
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment