forked from yangmiok/thorchain-tss
-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
37 lines (31 loc) · 737 Bytes
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package p2p
import (
"strings"
maddr "github.com/multiformats/go-multiaddr"
)
// A new type we need for writing a custom flag parser
type addrList []maddr.Multiaddr
// Config is configuration for P2P
type Config struct {
RendezvousString string
Port int
BootstrapPeers addrList
ExternalIP string
}
// String implement fmt.Stringer
func (al *addrList) String() string {
addresses := make([]string, len(*al))
for i, addr := range *al {
addresses[i] = addr.String()
}
return strings.Join(addresses, ",")
}
// Set add the given value to addList
func (al *addrList) Set(value string) error {
addr, err := maddr.NewMultiaddr(value)
if err != nil {
return err
}
*al = append(*al, addr)
return nil
}