blockchainIDsystem/peer/README.md
peer/README.mdRaw
1# Peer
2
3To run as a normal peer:
4```
5./peer
6```
7
8To run as a p2p server:
9```
10./peer server
11```
12
13Needs the config.json file:
14```json
15{
16 "ip": "127.0.0.1",
17 "port": "3001",
18 "serverip": "127.0.0.1",
19 "serverport": "3000"
20}
21```
22
23
24## Peer REST API
25- GET /
26 - Returns the peer.ID (where peer.ID = hash(peer.IP + ":" + peer.Port))
27
28
29- GET /peers
30 - Returns the peer outcomingPeersList (the peers which the peer have connection)
31
32```json
33{
34 "PeerID": "VOnL-15rFsUiCnRoyGFksKvWKcwNBRz5iarRem0Ilvo=",
35 "peerslist": [
36 {
37 "id": "VOnL-15rFsUiCnRoyGFksKvWKcwNBRz5iarRem0Ilvo=",
38 "ip": "127.0.0.1",
39 "port": "3000",
40 "role": "server",
41 "conn": null
42 },
43 {
44 "id": "Lk9jEP1YcOAzl51yY61GdWADNe35_g5Teh12JeguHhA=",
45 "ip": "127.0.0.1",
46 "port": "3003",
47 "role": "client",
48 "conn": {}
49 },
50 {
51 "id": "xj78wuyN2_thFBsXOUXnwij4L8vualxQ9GnVRK6RS4c=",
52 "ip": "127.0.0.1",
53 "port": "3005",
54 "role": "client",
55 "conn": {}
56 }
57 ],
58 "date": "0001-01-01T00:00:00Z"
59}
60```
61
62- POST /register
63 - Adds the address (pubK of the user) to the blockchain
64
65
66## TODO
67- When a peer connects to the network, sends his last Block, and receives the new Blocks from this last Block --> DONE with REST petitions, maybe is better with tcp conn
68- Delete the peer from the peers list when the connection is closed --> DONE
69- REST:
70 - endpoint to get if the address is in the blockchain (to verify users)
71- parameters Date or LastUpdate on the structs needs to be updated values
72- implement rsa encryption between peers
73- store blockchain in a .data file