Skip to content

Commit

Permalink
Provide golem-messages version in Hello
Browse files Browse the repository at this point in the history
  • Loading branch information
Krigpl committed Jan 17, 2018
1 parent 6ec01c7 commit fc08c5c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 40 deletions.
23 changes: 12 additions & 11 deletions bootstrap/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,18 @@ const (

type MessageHello struct {
BaseMessage
Port uint64 `msg_slot:"port"`
NodeName string `msg_slot:"node_name"`
ClientKeyId string `msg_slot:"client_key_id"`
NodeInfo *Node `msg_slot:"node_info"`
RandVal float64 `msg_slot:"rand_val"`
Metadata interface{} `msg_slot:"metadata"`
SolveChallange bool `msg_slot:"solve_challenge"`
Challange interface{} `msg_slot:"challenge"`
Difficulty uint64 `msg_slot:"difficulty"`
ProtoId uint64 `msg_slot:"proto_id"`
ClientVer string `msg_slot:"client_ver"`
Port uint64 `msg_slot:"port"`
NodeName string `msg_slot:"node_name"`
ClientKeyId string `msg_slot:"client_key_id"`
NodeInfo *Node `msg_slot:"node_info"`
RandVal float64 `msg_slot:"rand_val"`
Metadata interface{} `msg_slot:"metadata"`
SolveChallange bool `msg_slot:"solve_challenge"`
Challange interface{} `msg_slot:"challenge"`
Difficulty uint64 `msg_slot:"difficulty"`
ProtoId uint64 `msg_slot:"proto_id"`
GolemMessagesVersion string `msg_slot:"golem_messages_version"`
ClientVer string `msg_slot:"client_ver"`
}

func (self *MessageHello) GetType() uint16 {
Expand Down
34 changes: 18 additions & 16 deletions bootstrap/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ import (
)

type Config struct {
Name string
Id string
Port uint64
PrvAddr string
PubAddr string
PrvAddresses []interface{}
NatType string
PeerNum int
ProtocolId uint64
Name string
Id string
Port uint64
PrvAddr string
PubAddr string
PrvAddresses []interface{}
NatType string
PeerNum int
ProtocolId uint64
GolemMessagesVersion string
}

type Service struct {
Expand Down Expand Up @@ -80,12 +81,13 @@ func (s *Service) genHello() *MessageHello {
PrvAddresses: s.config.PrvAddresses,
NatType: s.config.NatType,
},
RandVal: rand.Float64(),
Metadata: make(map[string]interface{}),
SolveChallange: false,
Challange: nil,
Difficulty: 0,
ProtoId: s.config.ProtocolId,
ClientVer: "0.9.0",
RandVal: rand.Float64(),
Metadata: make(map[string]interface{}),
SolveChallange: false,
Challange: nil,
Difficulty: 0,
ProtoId: s.config.ProtocolId,
ClientVer: "0.9.0",
GolemMessagesVersion: s.config.GolemMessagesVersion,
}
}
30 changes: 17 additions & 13 deletions service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,24 @@ import (
)

const (
PORT = 40102
PEER_NUM = 100
NAME = "Go Bootstrap"
PROTO_ID uint64 = 19
PORT = 40102
PEER_NUM = 100
NAME = "Go Bootstrap"
PROTO_ID uint64 = 19
GOLEM_MESSAGES_VERSION = "1.4.1"
)

func main() {
var port uint64
var peerNum int
var name string
var protocolId uint64
var golemMessagesVersion string
flag.Uint64Var(&port, "port", PORT, "Port to listen to")
flag.IntVar(&peerNum, "peer-num", PEER_NUM, "Number of peers to send")
flag.StringVar(&name, "name", NAME, "Name of the node")
flag.Uint64Var(&protocolId, "protocol-id", PROTO_ID, "Version of the P2P procotol")
flag.StringVar(&golemMessagesVersion, "golem-messages", GOLEM_MESSAGES_VERSION, "Version of the golem-messages library")
flag.Parse()

var err error
Expand Down Expand Up @@ -61,15 +64,16 @@ func main() {
pubKeyHex := hex.EncodeToString(privKey.PublicKey.X) + hex.EncodeToString(privKey.PublicKey.Y)

config := &bootstrap.Config{
Name: name,
Id: pubKeyHex,
Port: port,
PrvAddr: prvAddresses[0].(string),
PubAddr: host.IP(),
PrvAddresses: prvAddresses,
NatType: nat.String(),
PeerNum: PEER_NUM,
ProtocolId: protocolId,
Name: name,
Id: pubKeyHex,
Port: port,
PrvAddr: prvAddresses[0].(string),
PubAddr: host.IP(),
PrvAddresses: prvAddresses,
NatType: nat.String(),
PeerNum: PEER_NUM,
ProtocolId: protocolId,
GolemMessagesVersion: golemMessagesVersion,
}

fmt.Printf("Config: %+v\n", config)
Expand Down

0 comments on commit fc08c5c

Please sign in to comment.