You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.7 KiB

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