Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[project] Remove txgen, prefer stack based init & map literals #2678

Merged
merged 1 commit into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,6 @@ Harmony server / main node:

```

Wallet:

```bash
./scripts/go_executable_build.sh wallet
```

Tx Generator:

```bash
./scripts/go_executable_build.sh txgen
```

### Harmony docs and guides

https://docs.harmony.one
Expand Down
21 changes: 7 additions & 14 deletions api/proto/discovery/pingpong.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ func (p PingMessageType) String() string {

// NewPingMessage creates a new Ping message based on the p2p.Peer input
func NewPingMessage(peer p2p.Peer, isClient bool) *PingMessageType {
ping := new(PingMessageType)

ping := PingMessageType{}
ping.Version = proto.ProtocolVersion
ping.NodeVer = nodeconfig.GetVersion()
ping.Node.IP = peer.IP
Expand All @@ -48,33 +47,27 @@ func NewPingMessage(peer p2p.Peer, isClient bool) *PingMessageType {
ping.Node.Role = node.ClientRole
}

return ping
return &ping
}

// GetPingMessage deserializes the Ping Message from a list of byte
func GetPingMessage(payload []byte) (*PingMessageType, error) {
ping := new(PingMessageType)

ping := PingMessageType{}
r := bytes.NewBuffer(payload)
decoder := gob.NewDecoder(r)
err := decoder.Decode(ping)

if err != nil {
if err := decoder.Decode(&ping); err != nil {
utils.Logger().Error().Err(err).Msg("[GetPingMessage] Decode")
return nil, fmt.Errorf("Decode Ping Error")
}

return ping, nil
return &ping, nil
}

// ConstructPingMessage contructs ping message from node to leader
func (p PingMessageType) ConstructPingMessage() []byte {
byteBuffer := bytes.NewBuffer([]byte{byte(proto.Node)})
byteBuffer.WriteByte(byte(node.PING))

byteBuffer := bytes.NewBuffer([]byte{byte(proto.Node), byte(node.PING)})
encoder := gob.NewEncoder(byteBuffer)
err := encoder.Encode(p)
if err != nil {
if err := encoder.Encode(p); err != nil {
utils.Logger().Error().Err(err).Msg("[ConstructPingMessage] Encode")
return nil
}
Expand Down
9 changes: 3 additions & 6 deletions api/service/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type NodeConfig struct {
Beacon nodeconfig.GroupID // the beacon group ID
ShardGroupID nodeconfig.GroupID // the group ID of the shard
Client nodeconfig.GroupID // the client group ID of the shard
IsClient bool // whether this node is a client node, such as wallet/txgen
IsClient bool // whether this node is a client node
IsBeacon bool // whether this node is a beacon node or not
ShardID uint32 // shardID of this node
Actions map[nodeconfig.GroupID]nodeconfig.ActionType // actions on the groups
Expand All @@ -26,14 +26,11 @@ type NodeConfig struct {
// key is the shard ID
// value is the corresponding group ID
var (
GroupIDShards map[nodeconfig.ShardID]nodeconfig.GroupID
GroupIDShardClients map[nodeconfig.ShardID]nodeconfig.GroupID
GroupIDShards = map[nodeconfig.ShardID]nodeconfig.GroupID{}
GroupIDShardClients = map[nodeconfig.ShardID]nodeconfig.GroupID{}
)

func init() {
GroupIDShards = make(map[nodeconfig.ShardID]nodeconfig.GroupID)
GroupIDShardClients = make(map[nodeconfig.ShardID]nodeconfig.GroupID)

// init beacon chain group IDs
GroupIDShards[0] = nodeconfig.NewGroupIDByShardID(0)
GroupIDShardClients[0] = nodeconfig.NewClientGroupIDByShardID(0)
Expand Down
3 changes: 0 additions & 3 deletions cmd/client/txgen/README.md

This file was deleted.

Loading