pub trait HopApiServer<BlockHash>:
Sized
+ Send
+ Sync
+ 'static {
// Required methods
fn submit(
&self,
data: Bytes,
recipients: Vec<Bytes>,
signature: Bytes,
signer: Bytes,
submit_timestamp: u64,
) -> RpcResult<SubmitResult>;
fn claim(&self, raw_hash: Bytes, signature: Bytes) -> RpcResult<Bytes>;
fn ack(&self, raw_hash: Bytes, signature: Bytes) -> RpcResult<()>;
fn pool_status(&self) -> RpcResult<PoolStatus>;
// Provided method
fn into_rpc(self) -> RpcModule<Self>
where BlockHash: Send + Sync + 'static { ... }
}Expand description
Server trait implementation for the HopApi RPC API.
Required Methods§
Sourcefn submit(
&self,
data: Bytes,
recipients: Vec<Bytes>,
signature: Bytes,
signer: Bytes,
submit_timestamp: u64,
) -> RpcResult<SubmitResult>
fn submit( &self, data: Bytes, recipients: Vec<Bytes>, signature: Bytes, signer: Bytes, submit_timestamp: u64, ) -> RpcResult<SubmitResult>
Submit data to the data pool.
§Arguments
data: The data to store, in bytesrecipients: List of SCALE-encodedMultiSigner(ed25519, sr25519, or ecdsa)signature: SCALE-encodedMultiSignatureover the submit signing payload (blake2_256(HOP_SUBMIT_CONTEXT || blake2_256(data) || submit_timestamp.to_le_bytes())).signer: SCALE-encodedMultiSignerof the account signing the submissionsubmit_timestamp: Wall-clock timestamp (ms since unix epoch) bound into the signed payload. The runtime rejects promotions whose timestamp is too far from on-chain time.
data.len() must not exceed HopRuntimeApi::max_promotion_size(), and
the signer must be authorized by the runtime (checked via
HopRuntimeApi::can_account_promote).
§Returns
The current pool status
Sourcefn claim(&self, raw_hash: Bytes, signature: Bytes) -> RpcResult<Bytes>
fn claim(&self, raw_hash: Bytes, signature: Bytes) -> RpcResult<Bytes>
Claim data from the data pool by hash (read-only download).
This does NOT mark the recipient as claimed. After receiving the data,
call hop_ack with the same arguments to confirm receipt.
The blob may be deleted concurrently by another recipient’s ack once all
recipients have acknowledged; callers must be prepared for NotFound
and should not assume availability between successive calls.
Requires a SCALE-encoded MultiSignature over the hash using the ephemeral
private key corresponding to one of the recipient public keys.
§Arguments
hash: The hash of the data, in bytes (32 bytes)signature: SCALE-encodedMultiSignatureover the hash
§Returns
The data if the signature matches a recipient that hasn’t yet acked
Sourcefn ack(&self, raw_hash: Bytes, signature: Bytes) -> RpcResult<()>
fn ack(&self, raw_hash: Bytes, signature: Bytes) -> RpcResult<()>
Acknowledge receipt of claimed data.
Marks the recipient as claimed and triggers cleanup when all recipients
have acknowledged. Idempotent: acking twice succeeds silently, but if the
entry has already been deleted (either because all recipients have
acknowledged or because it expired) the call returns NotFound — callers
should treat NotFound as a benign terminal state rather than an error.
§Arguments
raw_hash: The hash of the data, in bytes (32 bytes)signature: SCALE-encodedMultiSignatureover the hash
Sourcefn pool_status(&self) -> RpcResult<PoolStatus>
fn pool_status(&self) -> RpcResult<PoolStatus>
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.