Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
sidecar
Commits
0ee2f74d
Commit
0ee2f74d
authored
Sep 16, 2021
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor repo package
parent
8c3e3ddb
Pipeline
#7999
canceled with stages
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
40 deletions
+46
-40
config.go
internal/repo/config.go
+3
-40
mode.go
internal/repo/mode.go
+43
-0
No files found.
internal/repo/config.go
View file @
0ee2f74d
...
...
@@ -2,12 +2,11 @@ package repo
import
(
"fmt"
"github.com/meshplus/bitxhub-kit/fileutil"
"github.com/meshplus/bitxhub-kit/types"
"github.com/spf13/viper"
"path/filepath"
"strings"
"time"
"github.com/meshplus/bitxhub-kit/fileutil"
"github.com/spf13/viper"
)
const
(
...
...
@@ -160,39 +159,3 @@ func UnmarshalConfig(repoRoot string) (*Config, error) {
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
}
internal/repo/mode.go
0 → 100644
View file @
0ee2f74d
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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment