get leaders.

pull/69/head
Richard Liu 6 years ago
parent 01f2769ac9
commit 6eadebfbb2
  1. 24
      client/utils.go
  2. 28
      client/wallet/main.go

@ -1,6 +1,13 @@
package client
import "github.com/simple-rules/harmony-benchmark/crypto/pki"
import (
"bytes"
"io"
"log"
"net/http"
"github.com/simple-rules/harmony-benchmark/crypto/pki"
)
var AddressToIntPriKeyMap map[[20]byte]int // For convenience, we use int as the secret seed for generating private key
@ -14,3 +21,18 @@ func LookUpIntPriKey(address [20]byte) (int, bool) {
value, ok := AddressToIntPriKeyMap[address]
return value, ok
}
func DownloadUrlAsString(url string) (string, error) {
response, err := http.Get(url)
buf := bytes.NewBufferString("")
if err != nil {
log.Fatal(err)
} else {
defer response.Body.Close()
_, err := io.Copy(buf, response.Body)
if err != nil {
log.Fatal(err)
}
}
return buf.String(), err
}

@ -6,6 +6,14 @@ import (
"errors"
"flag"
"fmt"
"strings"
"io"
"io/ioutil"
math_rand "math/rand"
"os"
"strconv"
"time"
"github.com/dedis/kyber"
"github.com/simple-rules/harmony-benchmark/blockchain"
@ -17,12 +25,6 @@ import (
"github.com/simple-rules/harmony-benchmark/p2p"
proto_node "github.com/simple-rules/harmony-benchmark/proto/node"
"github.com/simple-rules/harmony-benchmark/utils"
"io"
"io/ioutil"
math_rand "math/rand"
"os"
"strconv"
"time"
)
func main() {
@ -218,6 +220,20 @@ func main() {
}
}
func getLeaders() []p2p.Peer {
str, _ := client.DownloadUrlAsString("https://s3-us-west-2.amazonaws.com/unique-bucket-bin/leaders.txt")
lines := strings.Split(str, "\n")
var leaders []p2p.Peer
for _, line := range lines {
if line == "" {
continue
}
parts := strings.Split(line, " ")
leaders = append(leaders, p2p.Peer{Ip: parts[0], Port: parts[1]})
}
return leaders
}
func CreateWalletServerNode() *node.Node {
configr := client_config.NewConfig()
configr.ReadConfigFile("local_config_shards.txt")

Loading…
Cancel
Save