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