DHTs Routine
What would DHTs do (Needs reviewing)
Initial Registration:
Shaga-Sunshine Registration Request: When a Shaga-Sunshine comes online, it sends a registration request to the DHT. This request includes the Shaga-Sunshine's public key, IP address, geolocation, and other pertinent information.
DHT Registration Processing: The DHT takes the registration request, hashes the Shaga-Sunshine's public key to determine its location in the DHT, and stores the Shaga-Sunshine's information at that location.
Querying Available Nodes:
Shaga-Moonlight Query Request: When a user on a Shaga-Moonlight wants to view available nodes, the Shaga-Moonlight sends a query request to the DHT.
DHT Query Processing: The DHT receives the query request, retrieves the information of available Shaga-Sunshines, and sends this data back to the Shaga-Moonlight.
Updating Node Availability:
Shaga-Sunshine Update Request: When a Shaga-Sunshine begins or ends a gaming session, it sends an update request to the DHT to change its status to 'busy' or 'available' respectively.
DHT Update Processing: The DHT receives the update request, locates the Shaga-Sunshine's information using the provided public key, updates the Shaga-Sunshine's status, and acknowledges the update to the Shaga-Sunshine.
Error Handling:
DHT Node Failure: In the event of a DHT node failure, the DHT redistributes the stored information among the remaining nodes to maintain data availability and network stability.
Shaga-Sunshine Failure: If a Shaga-Sunshine fails or disconnects unexpectedly, the DHT detects this when it fails to receive a periodic heartbeat signal from the Shaga-Sunshine. The DHT then updates the Shaga-Sunshine's status to 'offline' or removes its information from the table.
Node Deregistration:
Shaga-Sunshine Deregistration Request: When a Shaga-Sunshine is shutting down or going offline for a longer period, it sends a deregistration request to the DHT.
DHT Deregistration Processing: The DHT receives the deregistration request, removes the Shaga-Sunshine's information from the table, and acknowledges the deregistration to the Shaga-Sunshine.
Interacting with the Solana Blockchain:
Transaction Initiation: The Shaga-Moonlight sends a POST request to a Solana RPC node via the Solana Web3 API to initiate a transaction. The request includes the transaction details, such as the source and destination public keys (i.e., borrower's and lender's public keys), the amount of USDC to transfer, and the transaction fee.
Transaction Verification: Upon receiving the transaction receipt, the Shaga-Sunshine sends a GET request to a Solana RPC node via the Solana Web3 API to verify the transaction. The request includes the transaction signature.