supernode.go 842 Bytes
Newer Older
1 2 3 4 5 6
package config

import "github.com/jbenet/go-ipfs/util/ipfsaddr"

// TODO replace with final servers before merge

7
// TODO rename
8
type SupernodeClientConfig struct {
9 10 11 12
	Servers []string
}

var DefaultGCRServers = []string{
13 14
	"/ip4/107.170.212.195/tcp/4001/ipfs/QmVy5xh7sYKyQxHG4ZatHj9cCu1H5PR1LySKeTfLdJxp1b",
	"/ip4/107.170.215.87/tcp/4001/ipfs/QmZDYP9GBjkAmZrS5usSzPnLf41haq6jJhJDmWgnSM4zvW",
15 16
}

17
func initSNRConfig() (*SupernodeClientConfig, error) {
18
	// TODO perform validation
19
	return &SupernodeClientConfig{
20 21 22 23
		Servers: DefaultGCRServers,
	}, nil
}

24
func (gcr *SupernodeClientConfig) ServerIPFSAddrs() ([]ipfsaddr.IPFSAddr, error) {
25 26 27 28 29 30 31 32 33 34
	var addrs []ipfsaddr.IPFSAddr
	for _, server := range gcr.Servers {
		addr, err := ipfsaddr.ParseString(server)
		if err != nil {
			return nil, err
		}
		addrs = append(addrs, addr)
	}
	return addrs, nil
}