Expand description
This module is responsible for creating a socket connection to the relayer server. It is used to send requests to the relayer server and processing the responses. It also intercepts the logs, errors and return values.
The socket connection is created using the UnixListener
.
- Creates a socket connection using the
UnixListener
. - Each request payload is stringified by the client and added as a new line to the socket.
- The server reads the requests from the socket and processes them.
- The server sends the responses back to the client in the same format. By writing a new line in the socket
- When the client sends the socket shutdown signal, the server closes the socket connection.
Example:
- Create a new socket connection using
/tmp/socket.sock
- Client sends request (writes in
/tmp/socket.sock
):
{
"request_id": "123",
"relayer_id": "relayer1",
"method": "sendTransaction",
"payload": {
"to": "0x1234567890123456789012345678901234567890",
"value": "1000000000000000000"
}
}
- Server process the requests, calls the relayer API and sends back the response (writes in
/tmp/socket.sock
):
{
"request_id": "123",
"result": {
"id": "123",
"status": "success"
}
}
- Client reads the response (reads from
/tmp/socket.sock
):
{
"request_id": "123",
"result": {
"id": "123",
"status": "success"
}
}
- Once the client finishes the execution, it sends a shutdown signal to the server.
- The server closes the socket connection.