Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
paularchard committed Dec 20, 2018
1 parent 8091362 commit e6ee1a4
Showing 1 changed file with 1 addition and 145 deletions.
146 changes: 1 addition & 145 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,151 +600,7 @@ Waiting....
```
#### Adding or Removing A Peer

Please note that RAFT nodes automatically add themselves to a RAFT swarm on
start up.

The node will first attempt to determine if it is a member of the swarm described
in the bootstrap file, and if it finds that it is not, it will automatically send
the add_peer request to the leader.

If the RAFT node has peer_validation_enabled set to true, a valid signed_key for the
node must be set in the configuration file:

"peer_validation_enabled" : false
"signed_key": "LjMrLq8pw3 <...> +QbThXaQ="
the signed key can be obtaied from a Bluzelle representative.

```text
Nodes are added to, or removed from, the network with the add_peer and
remove_peer commands, sent to a leader via WebSocket protocol with the
following JSON objects:
Adding a peer:
{
"bzn-api":"raft",
"cmd":"add_peer",
"data":{
"peer":{
"host":"<HOST-URL>",
"http_port":<HTTPPORT>,
"name":"<NODE-NAME>",
"port":<PORT>,
"uuid":"<UUID>",
"signature" : "<signature>"
}
}
}
The "name" object, <NODE-NAME>, can be a human readable name for the node, "Fluffy" for example.
The "uuid" object must be a universally unique identifer that uniquely identifies the node within the swarm, or any
other swarm. This value can be generated online at a site like: https://www.uuidgenerator.net/
The "signature" object is a signature string associated with your node's UUID provided by a Bluzelle representative.
Remove an existing peer:
{
"bzn-api":"raft",
"cmd":"remove_peer",
"data":{
"uuid":"<UUID>"
}
}
Given a swarm of nodes, a new node can be added via the command line with a
WebSocket client such as wscat (https://www.npmjs.com/package/wscat).
If the swarm has security enabled, before a new node can participate in a swarm
it must be validated by the leader against a cryptographic signature. You can
obtain this signature by providing the nodes' UUID to a Bluzelle representative
who will cryptographically sign the UUID and send you a signature file whose
contents must be included in the add_peer command to be sent to the swarm leader.
Start the node that you want to add to the swarm, remember that the local peers
list must include the information for the local node for your node to be able
to start. When your node does start, it will not be able to participate in the
swarm until you add it to the swarm.
Create your add_peer JSON object, and use wscat to send it to the swarm leader,
note that the signature object is only required for swarms whose nodes have set
the peer_validation_enabled object to true in thier config files:
$ wscat -c http://<leader-address>:<port>
connected (press CTRL+C to quit)
>{"bzn-api":"raft","cmd":"add_peer","data":{"peer":{"host":"104.25.178.61","http_port":84,"name":"peer3","port":49154,"uuid":"7dda1fcb-d494-4fc1-8645-a14056d13afd","signature":"Dprtbr<...>4vk="}}}
>
disconnected
$
the leader will validate the new node, and if successful, add the new node
to the swarm.
To remove the node, create a remove_peer JSON object, and use wscat to send it
to the swarm leader:
$ wscat -c http://<leader-address>:<port>
connected (press CTRL+C to quit)
>{"bzn-api" : "raft", "cmd" : "remove_peer", "data" : { "uuid" : "7dda1fcb-d494-4fc1-8645-a14056d13afd" }}
>
disconnected
$
and the node will be removed from the peer list.
```

#### Get the List of Peers from the Leader

The active peers in the swarm can be obtained by sending a "get_peers"
WebSocket command to the leader. To perform this command create a JSON
command object and send it via wscat:

$ wscat -c http://<leader_address>:port
connected (press CTRL+C to quit)
>{"bzn-api" : "raft", "cmd" : "get_peers"}
>

and the response will look like:

{
"message" :
[
{
"host" : "127.0.0.1",
"http_port" : 9082,
"name" : "peer0",
"port" : 49152,
"uuid" : "2e34a07f-fd6d-4575-927e-f83a9edd1866"
},
{
"host" : "127.0.0.1",
"http_port" : 9083,
"name" : "peer1",
"port" : 49153,
"uuid" : "a05809a3-0b77-4881-8fa7-b0e0e2ee9107"
}
]
}

If you send the request to a follower, the response will be:

{
"error" : "ERROR_GET_PEERS_MUST_BE_SENT_TO_LEADER",
"message" :
{
"leader" :
{
"host" : "127.0.0.1",
"http_port" : 9082,
"name" : "peer0",
"port" : 49152,
"uuid" : "2e34a07f-fd6d-4575-927e-f83a9edd1866"
}
}
}

and you can resend the request to the leader.

Dynamically adding and removing peers is not supported in this release. This functionality will be available in a subsequent version of swarmDB.

#### Help & Options

Expand Down

0 comments on commit e6ee1a4

Please sign in to comment.