2014-12-15 14:00:09 +02:00
|
|
|
package eth
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
2015-03-16 12:27:38 +02:00
|
|
|
"github.com/ethereum/go-ethereum/common"
|
2014-12-15 14:00:09 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func WritePeers(path string, addresses []string) {
|
|
|
|
if len(addresses) > 0 {
|
|
|
|
data, _ := json.MarshalIndent(addresses, "", " ")
|
2015-03-16 12:27:38 +02:00
|
|
|
common.WriteFile(path, data)
|
2014-12-15 14:00:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ReadPeers(path string) (ips []string, err error) {
|
|
|
|
var data string
|
2015-03-16 12:27:38 +02:00
|
|
|
data, err = common.ReadAllFile(path)
|
2014-12-15 14:00:09 +02:00
|
|
|
if err != nil {
|
|
|
|
json.Unmarshal([]byte(data), &ips)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|