You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To transfer files using Libp2p we need an API, as the library only allows us to open a communication channel between peers, but not to transfer files.
Here we need a balance between API readability and compactness, as this will affect the amount of data transferred and speed. Since we need an API for relatively simple file transfer operations, we need a simple API.
Therefore, I propose the most efficient API possible: 1:125:10000:path/to/file
This is an example of a getFile request.
In this example, the parameters are separated by a colon. Here's what the parameters mean:
1 - request type (getFile)
125 - start byte
10000 - size of the requested data
path/to/file - path to file
Since we already have a connection to the peer we are sending this request to, if some error occurs or the file is unavailable, the connection is simply closed. The peer that makes the request will know about it. Or, if all is well, the file size of 8 bytes is received first, and then the content itself.
This type of request is easy to parse and use. In addition, by changing the first digit (request type) and the number of parameters separated by a colon, it is possible to flexibly add new types of requests.
Today I am using 6 of these requests which fully provide file transfer functionality related to Samba, torrents and simple file transfer.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
To transfer files using Libp2p we need an API, as the library only allows us to open a communication channel between peers, but not to transfer files.
Here we need a balance between API readability and compactness, as this will affect the amount of data transferred and speed. Since we need an API for relatively simple file transfer operations, we need a simple API.
Therefore, I propose the most efficient API possible:
1:125:10000:path/to/file
This is an example of a getFile request.
In this example, the parameters are separated by a colon. Here's what the parameters mean:
1 - request type (getFile)
125 - start byte
10000 - size of the requested data
path/to/file - path to file
Since we already have a connection to the peer we are sending this request to, if some error occurs or the file is unavailable, the connection is simply closed. The peer that makes the request will know about it. Or, if all is well, the file size of 8 bytes is received first, and then the content itself.
This type of request is easy to parse and use. In addition, by changing the first digit (request type) and the number of parameters separated by a colon, it is possible to flexibly add new types of requests.
Today I am using 6 of these requests which fully provide file transfer functionality related to Samba, torrents and simple file transfer.
What suggestions are there? Questions?
Beta Was this translation helpful? Give feedback.
All reactions