rubixchain / rubixgoplatform

GNU General Public License v3.0
8 stars 17 forks source link

Adding Peer Details Manually #161

Closed ashi31 closed 2 months ago

ashi31 commented 3 months ago

Command to add the details of a Peer Manually by providing PeerID, DID and DIDType. Updated Swagger to include the API for the same. Adding of Peer details is done when a node is trying to connect the peer node for the first time. This is being done as the PeerID of a node can change. Additionally one node can have multiple peerIDs and multiple nodes can have the same peerID. Using the command addpeerdetails as below will prompt for entering the PeerID, DID and DIDType. If we keep PeerID inside the DID directory , the DID value will change when a node switches peerID.

Example for CLI $ ./rubixgoplatform addpeerdetails -port 20006 Enter PeerID : 12D3KooWQ2as3FNtvL1MKTeo7XAuBZxSv8QqobxX4AmURxyNe5mX Enter DID : bafybmicro2m4kove5vsetej63xq4csobtlzchb2c34lp6dnakzkwtq2mmy Enter DID Type : 4 2024-05-22T16:41:02.681+0530 [INFO] Main: Peer added successfully

Example for API call To trigger the API, we can use below : curl -X POST http://localhost:20006/api/add-peer-details -H 'Content-Type: application/json' -d '{ "peerid": "12D3KooWJUJz2ipK78LAiwhc1QUVDvSMjZNBHt4vSAeVAq6FsneA", "did": "bafybmics43ef7ldgrogzurh7vukormpgscq4um44bss6mfuopsbjorbyaq", "didtype": 0 }' {"status":true,"message":"Peers added successfully","result":null}

Change the port number, PeerID, DID and DID Type to the required values.

harirubix commented 3 months ago

Instead of calling registerdid , please edit test file to call addpeerdetails in right place to make sure tests are working after your changes.