Merge pull request #197 from harmony-one/open_source_cleanup

move client/txgen to cmd/client/txgen
pull/200/head
Leo Chen 6 years ago committed by GitHub
commit a89059ce2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 0
      api/client/client.go
  2. 2
      api/client/service/client.go
  3. 0
      api/client/service/proto/client.pb.go
  4. 0
      api/client/service/proto/client.proto
  5. 2
      api/client/service/server.go
  6. 101
      client/config/config.go
  7. 4
      cmd/client/txgen/main.go
  8. 0
      cmd/client/txgen/txgen/account_txs_generator.go
  9. 8
      cmd/client/wallet/main.go
  10. 4
      go_executable_build.sh
  11. 4
      node/node.go
  12. 2
      test/deploy.sh

@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
proto "github.com/harmony-one/harmony/client/service/proto" proto "github.com/harmony-one/harmony/api/client/service/proto"
"log" "log"
"time" "time"

@ -9,7 +9,7 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
proto "github.com/harmony-one/harmony/client/service/proto" proto "github.com/harmony-one/harmony/api/client/service/proto"
) )
// Server is the Server struct for client service package. // Server is the Server struct for client service package.

@ -1,101 +0,0 @@
package config
import (
"bufio"
"log"
"os"
"strconv"
"strings"
"github.com/harmony-one/harmony/p2p"
)
// Entry is a single config of a node.
type Entry struct {
IP string
Port string
Role string
ShardID string
}
// Config is a struct containing multiple Entry of all nodes.
type Config struct {
config []Entry
}
// NewConfig returns a pointer to a Config.
func NewConfig() *Config {
config := Config{}
return &config
}
// GetValidators returns all the validator peers
func (config *Config) GetValidators() []p2p.Peer {
var peerList []p2p.Peer
for _, entry := range config.config {
if entry.Role != "validator" {
continue
}
peer := p2p.Peer{Port: entry.Port, IP: entry.IP}
peerList = append(peerList, peer)
}
return peerList
}
// GetShardIDToLeaderMap returns all the leader peers and corresponding shard Ids
func (config *Config) GetShardIDToLeaderMap() map[uint32]p2p.Peer {
shardIDLeaderMap := map[uint32]p2p.Peer{}
for _, entry := range config.config {
if entry.Role == "leader" {
val, err := strconv.Atoi(entry.ShardID)
if err == nil {
shardIDLeaderMap[uint32(val)] = p2p.Peer{IP: entry.IP, Port: entry.Port}
} else {
log.Print("[Generator] Error parsing the shard Id ", entry.ShardID)
}
}
}
return shardIDLeaderMap
}
// GetClientPeer returns the client peer.
func (config *Config) GetClientPeer() *p2p.Peer {
for _, entry := range config.config {
if entry.Role != "client" {
continue
}
peer := p2p.Peer{Port: entry.Port, IP: entry.IP}
return &peer
}
return nil
}
// GetClientPort returns the port of the client node in the config
func (config *Config) GetClientPort() string {
for _, entry := range config.config {
if entry.Role == "client" {
return entry.Port
}
}
return ""
}
// ReadConfigFile parses the config file and return a 2d array containing the file data
func (config *Config) ReadConfigFile(filename string) error {
file, err := os.Open(filename)
if err != nil {
log.Fatal("Failed to read config file ", filename)
return err
}
defer file.Close()
fscanner := bufio.NewScanner(file)
result := []Entry{}
for fscanner.Scan() {
p := strings.Split(fscanner.Text(), " ")
entry := Entry{p[0], p[1], p[2], p[3]}
result = append(result, entry)
}
config.config = result
return nil
}

@ -9,9 +9,9 @@ import (
"sync" "sync"
"time" "time"
"github.com/harmony-one/harmony/api/client"
proto_node "github.com/harmony-one/harmony/api/proto/node" proto_node "github.com/harmony-one/harmony/api/proto/node"
"github.com/harmony-one/harmony/client" "github.com/harmony-one/harmony/cmd/client/txgen/txgen"
"github.com/harmony-one/harmony/client/txgen/txgen"
"github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/consensus"
"github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/internal/newnode" "github.com/harmony-one/harmony/internal/newnode"

@ -17,9 +17,9 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
crypto2 "github.com/ethereum/go-ethereum/crypto" crypto2 "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/harmony-one/harmony/api/client"
clientService "github.com/harmony-one/harmony/api/client/service"
proto_node "github.com/harmony-one/harmony/api/proto/node" proto_node "github.com/harmony-one/harmony/api/proto/node"
"github.com/harmony-one/harmony/client"
client2 "github.com/harmony-one/harmony/client/service"
"github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/types"
libs "github.com/harmony-one/harmony/internal/beaconchain/libs" libs "github.com/harmony-one/harmony/internal/beaconchain/libs"
"github.com/harmony-one/harmony/internal/beaconchain/rpc" "github.com/harmony-one/harmony/internal/beaconchain/rpc"
@ -314,7 +314,7 @@ func FetchBalance(address common.Address, walletNode *node.Node) map[uint32]Acco
result := make(map[uint32]AccountState) result := make(map[uint32]AccountState)
for shardID, leader := range *walletNode.Client.Leaders { for shardID, leader := range *walletNode.Client.Leaders {
port, _ := strconv.Atoi(leader.Port) port, _ := strconv.Atoi(leader.Port)
client := client2.NewClient(leader.IP, strconv.Itoa(port+node.ClientServicePortDiff)) client := clientService.NewClient(leader.IP, strconv.Itoa(port+node.ClientServicePortDiff))
response := client.GetBalance(address) response := client.GetBalance(address)
balance := big.NewInt(0) balance := big.NewInt(0)
balance.SetBytes(response.Balance) balance.SetBytes(response.Balance)
@ -328,7 +328,7 @@ func FetchBalance(address common.Address, walletNode *node.Node) map[uint32]Acco
func GetFreeToken(address common.Address, walletNode *node.Node) { func GetFreeToken(address common.Address, walletNode *node.Node) {
for shardID, leader := range *walletNode.Client.Leaders { for shardID, leader := range *walletNode.Client.Leaders {
port, _ := strconv.Atoi(leader.Port) port, _ := strconv.Atoi(leader.Port)
client := client2.NewClient(leader.IP, strconv.Itoa(port+node.ClientServicePortDiff)) client := clientService.NewClient(leader.IP, strconv.Itoa(port+node.ClientServicePortDiff))
response := client.GetFreeToken(address) response := client.GetFreeToken(address)
txID := common.Hash{} txID := common.Hash{}

@ -1,9 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
declare -A SRC declare -A SRC
SRC[benchmark]=benchmark.go SRC[benchmark]=benchmark.go
SRC[txgen]=client/txgen/main.go SRC[txgen]=cmd/client/txgen/main.go
SRC[beacon]=cmd/beaconchain/main.go SRC[beacon]=cmd/beaconchain/main.go
SRC[wallet]=client/wallet/main.go SRC[wallet]=cmd/client/wallet/main.go
BINDIR=bin BINDIR=bin
BUCKET=unique-bucket-bin BUCKET=unique-bucket-bin

@ -18,13 +18,13 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
"github.com/harmony-one/harmony/api/client"
clientService "github.com/harmony-one/harmony/api/client/service"
proto_node "github.com/harmony-one/harmony/api/proto/node" proto_node "github.com/harmony-one/harmony/api/proto/node"
"github.com/harmony-one/harmony/api/services/explorer" "github.com/harmony-one/harmony/api/services/explorer"
"github.com/harmony-one/harmony/api/services/syncing" "github.com/harmony-one/harmony/api/services/syncing"
"github.com/harmony-one/harmony/api/services/syncing/downloader" "github.com/harmony-one/harmony/api/services/syncing/downloader"
downloader_pb "github.com/harmony-one/harmony/api/services/syncing/downloader/proto" downloader_pb "github.com/harmony-one/harmony/api/services/syncing/downloader/proto"
"github.com/harmony-one/harmony/client"
clientService "github.com/harmony-one/harmony/client/service"
bft "github.com/harmony-one/harmony/consensus" bft "github.com/harmony-one/harmony/consensus"
"github.com/harmony-one/harmony/core" "github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/types"

@ -88,7 +88,7 @@ cleanup
pushd $ROOT pushd $ROOT
echo "compiling ..." echo "compiling ..."
go build -o bin/benchmark go build -o bin/benchmark
go build -o bin/txgen client/txgen/main.go go build -o bin/txgen cmd/client/txgen/main.go
go build -o bin/beacon cmd/beaconchain/main.go go build -o bin/beacon cmd/beaconchain/main.go
popd popd

Loading…
Cancel
Save