bitswap_unstable_get

Parameters:

  • cid: CID of the data chunk requested serialized in a string format.
    Only CIDv1 version in base32 multibase encoding (string starting from b...) is supported.
    Only sha2-256, blake2b-256 & keccak-256 hash functions are supported.
    Example: bafk2bzacec5lindttapqst35gv4767ig2vxmcaeherlaubtqhufg4tqqmeen4.

Return value: String containing the requested data chunk, hexadecimal-encoded. Always starts with 0x....
Because Bitswap chunks are limited by 2 MiB at the transport layer, the maximum returned string size is 4 MiB + 2 B.

Errors: If the data chunk retrieval fails, JSON-RPC call fails. The error code indicates a possible retry strategy.

Error categories

CodeCategoryMeaning
-32602InvalidParamsInvalid/unsupported CID was passed
-32810FailPermanent failure for this request, e.g. data not found
-32811FailRetryTransient failure, can retry immediately
-32812FailRetryBackoffTransient failure, can retry with a delay

InvalidParams is a standard JSON-RPC error indicating invalid data passed to the method. The client must not call the method with the same argument again.

For error category Fail retrying doesn't make sense unless the data has been added to the network after the failure.

Error category FailRetry can be retried immediately. For example, request timeout falls into this category. Even though the client can retry immediately, the implementations are encouraged to rate-limit the retry attempts and limit the total number of retries.

Error category FailRetryBackoff can be retried after a delay. For example, such error can be generated if no peers are currently connected to the light client. Recommended delay before retrying is 1-5 seconds.

Only code is stable for programmatic dispatch. message is a human-readable diagnostic string for logs and developer-facing tooling, is implementation-specific, and must not be relied upon in business logic.

Example JSON-RPC success response

{ "jsonrpc": "2.0", "id": 1, "result": "0x4869" }

Example JSON-RPC error response

{ "jsonrpc": "2.0", "id": 1, "error": { "code": -32812, "message": "No Bitswap peers connected" } }