p2p/simulations: add node properties support and utility functions (#20060)

This commit is contained in:
Ross
2019-10-17 10:07:09 +02:00
committed by Felix Lange
parent 7300365956
commit d5b79e752e
3 changed files with 392 additions and 8 deletions

View File

@ -101,6 +101,11 @@ type NodeConfig struct {
// services registered by calling the RegisterService function)
Services []string
// Properties are the names of the properties this node should hold
// within running services (e.g. "bootnode", "lightnode" or any custom values)
// These values need to be checked and acted upon by node Services
Properties []string
// Enode
node *enode.Node
@ -120,6 +125,7 @@ type nodeConfigJSON struct {
PrivateKey string `json:"private_key"`
Name string `json:"name"`
Services []string `json:"services"`
Properties []string `json:"properties"`
EnableMsgEvents bool `json:"enable_msg_events"`
Port uint16 `json:"port"`
}
@ -131,6 +137,7 @@ func (n *NodeConfig) MarshalJSON() ([]byte, error) {
ID: n.ID.String(),
Name: n.Name,
Services: n.Services,
Properties: n.Properties,
Port: n.Port,
EnableMsgEvents: n.EnableMsgEvents,
}
@ -168,6 +175,7 @@ func (n *NodeConfig) UnmarshalJSON(data []byte) error {
n.Name = confJSON.Name
n.Services = confJSON.Services
n.Properties = confJSON.Properties
n.Port = confJSON.Port
n.EnableMsgEvents = confJSON.EnableMsgEvents