holochain_types 0.7.0-dev.21

Holochain common types
Documentation
//! Types related to an agents for chain activity
use crate::warrant::WarrantOp;
use holo_hash::ActionHash;
use holo_hash::AgentPubKey;
use holo_hash::HasHash;
use holochain_serialized_bytes::prelude::*;
use holochain_timestamp::Timestamp;
use holochain_zome_types::prelude::*;

mod chain_item;
pub use chain_item::*;

/// Intermediate data structure used during a `must_get_agent_activity` call.
/// Note that this is not the final return value of `must_get_agent_activity`.
#[derive(Debug, Clone, PartialEq, Eq, SerializedBytes, Serialize, Deserialize)]
pub enum MustGetAgentActivityResponse {
    /// The activity was found.
    Activity {
        /// The actions performed by the agent.
        activity: Vec<RegisterAgentActivity>,
        /// Any warrants issued to the agent for this activity.
        warrants: Vec<WarrantOp>,
    },
    /// The requested chain top and filter conditions were successfully met, but there were missing
    /// actions within the filtered range that prevented building a complete chain section.
    IncompleteChain,
    /// While walking the chain in reverse order, the requested until hash was not found.
    ///
    /// This either means that there is data missing for this chain, or the requested hash does not
    /// below to the queried chain.
    UntilHashMissing(ActionHash),
    /// The requested until timestamp range could not be proven complete.
    ///
    /// This includes the case where no returned actions satisfy the timestamp, and the case where
    /// actions satisfy it but there is no deterministic lower-bound witness (an action with
    /// timestamp below the limit) and the returned chain does not reach genesis.
    UntilTimestampIndeterminate(Timestamp),
    /// The requested chain top was not found in the chain.
    ChainTopNotFound(ActionHash),
    /// The `until_hash` filter specifies an action with a sequence number greater than the
    /// `chain_top`'s sequence number.
    ///
    /// This is an impossible filter condition to create a response to because `until_hash` must be
    /// at or before `chain_top` in the chain.
    UntilHashAfterChainHead(ActionHash),
    /// The `until_timestamp` filter specifies a timestamp greater than the `chain_top` action's
    /// timestamp.
    ///
    /// This is an impossible filter condition to create a response to because `until_timestamp`
    /// must be at or before the `chain_top`'s timestamp.
    UntilTimestampGreaterThanChainHead(Timestamp),
}

impl MustGetAgentActivityResponse {
    /// Constructor
    #[cfg(feature = "test_utils")]
    pub fn activity(activity: Vec<RegisterAgentActivity>) -> Self {
        Self::Activity {
            activity,
            warrants: vec![],
        }
    }
}