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