referrerpolicy=no-referrer-when-downgrade

HopApiServer

Trait HopApiServer 

Source
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§

Source

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 bytes
  • recipients: List of SCALE-encoded MultiSigner (ed25519, sr25519, or ecdsa)
  • signature: SCALE-encoded MultiSignature over the submit signing payload (blake2_256(HOP_SUBMIT_CONTEXT || blake2_256(data) || submit_timestamp.to_le_bytes())).
  • signer: SCALE-encoded MultiSigner of the account signing the submission
  • submit_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

Source

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-encoded MultiSignature over the hash
§Returns

The data if the signature matches a recipient that hasn’t yet acked

Source

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-encoded MultiSignature over the hash
Source

fn pool_status(&self) -> RpcResult<PoolStatus>

Get data pool status

§Returns

Pool statistics including entry count and size

Provided Methods§

Source

fn into_rpc(self) -> RpcModule<Self>
where BlockHash: Send + Sync + 'static,

Collects all the methods and subscriptions defined in the trait and adds them into a single RpcModule.

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.

Implementors§

Source§

impl<C, Block> HopApiServer<<Block as Block>::Hash> for HopRpcServer<C, Block>
where Block: BlockT, C: HeaderBackend<Block> + CallApiAt<Block> + Send + Sync + 'static,