fix golint for client utils

pull/127/head
Minh Doan 6 years ago committed by Minh Doan
parent 2f0a5b23e5
commit dfc6721122
  1. 7
      client/utils.go
  2. 2
      client/wallet/main.go
  3. 2
      client/wallet_v2/main.go

@ -10,9 +10,12 @@ import (
"github.com/harmony-one/harmony/crypto/pki" "github.com/harmony-one/harmony/crypto/pki"
) )
// AddressToIntPriKeyMap is the map from address to private key.
var AddressToIntPriKeyMap map[[20]byte]int // For convenience, we use int as the secret seed for generating private key var AddressToIntPriKeyMap map[[20]byte]int // For convenience, we use int as the secret seed for generating private key
// AddressToIntPriKeyMapLock is the lock of AddressToIntPriKeyMap.
var AddressToIntPriKeyMapLock sync.Mutex var AddressToIntPriKeyMapLock sync.Mutex
// InitLookUpIntPriKeyMap inits AddressToIntPriKeyMap.
func InitLookUpIntPriKeyMap() { func InitLookUpIntPriKeyMap() {
if AddressToIntPriKeyMap == nil { if AddressToIntPriKeyMap == nil {
AddressToIntPriKeyMapLock.Lock() AddressToIntPriKeyMapLock.Lock()
@ -24,12 +27,14 @@ func InitLookUpIntPriKeyMap() {
} }
} }
// LookUpIntPriKey looks up private key by address.
func LookUpIntPriKey(address [20]byte) (int, bool) { func LookUpIntPriKey(address [20]byte) (int, bool) {
value, ok := AddressToIntPriKeyMap[address] value, ok := AddressToIntPriKeyMap[address]
return value, ok return value, ok
} }
func DownloadUrlAsString(url string) (string, error) { // DownloadURLAsString downloads url as string.
func DownloadURLAsString(url string) (string, error) {
response, err := http.Get(url) response, err := http.Get(url)
buf := bytes.NewBufferString("") buf := bytes.NewBufferString("")
if err != nil { if err != nil {

@ -223,7 +223,7 @@ func main() {
func getShardIDToLeaderMap() map[uint32]p2p.Peer { func getShardIDToLeaderMap() map[uint32]p2p.Peer {
// TODO(ricl): Later use data.harmony.one for API. // TODO(ricl): Later use data.harmony.one for API.
str, _ := client.DownloadUrlAsString("https://s3-us-west-2.amazonaws.com/unique-bucket-bin/leaders.txt") str, _ := client.DownloadURLAsString("https://s3-us-west-2.amazonaws.com/unique-bucket-bin/leaders.txt")
lines := strings.Split(str, "\n") lines := strings.Split(str, "\n")
shardIDLeaderMap := map[uint32]p2p.Peer{} shardIDLeaderMap := map[uint32]p2p.Peer{}
log.Print(lines) log.Print(lines)

@ -223,7 +223,7 @@ func main() {
func getShardIDToLeaderMap() map[uint32]p2p.Peer { func getShardIDToLeaderMap() map[uint32]p2p.Peer {
// TODO(ricl): Later use data.harmony.one for API. // TODO(ricl): Later use data.harmony.one for API.
str, _ := client.DownloadUrlAsString("https://s3-us-west-2.amazonaws.com/unique-bucket-bin/leaders.txt") str, _ := client.DownloadURLAsString("https://s3-us-west-2.amazonaws.com/unique-bucket-bin/leaders.txt")
lines := strings.Split(str, "\n") lines := strings.Split(str, "\n")
shardIDLeaderMap := map[uint32]p2p.Peer{} shardIDLeaderMap := map[uint32]p2p.Peer{}
log.Print(lines) log.Print(lines)

Loading…
Cancel
Save