1#![allow(clippy::too_many_arguments)]
2use crate::*;
5use holochain_zome_types::signature::Signature;
6
7#[derive(Default, Debug, serde::Serialize, serde::Deserialize, Clone)]
9pub enum GetRequest {
10 #[default]
12 All,
13 Content,
15 Metadata,
18 Pending,
20}
21
22#[derive(Debug, serde::Serialize, serde::Deserialize, Clone)]
24pub struct GetOptions {
25 pub follow_redirects: bool,
28 pub all_live_actions_with_metadata: bool,
31 pub request_type: GetRequest,
33}
34
35impl From<&actor::GetOptions> for GetOptions {
36 fn from(a: &actor::GetOptions) -> Self {
37 Self {
38 follow_redirects: a.follow_redirects,
39 all_live_actions_with_metadata: a.all_live_actions_with_metadata,
40 request_type: a.request_type.clone(),
41 }
42 }
43}
44
45#[derive(Debug, serde::Serialize, serde::Deserialize)]
47pub struct GetMetaOptions {}
48
49impl From<&actor::GetMetaOptions> for GetMetaOptions {
50 fn from(_a: &actor::GetMetaOptions) -> Self {
51 Self {}
52 }
53}
54
55#[derive(Debug, serde::Serialize, serde::Deserialize)]
57pub struct GetLinksOptions {}
58
59impl From<&actor::GetLinksOptions> for GetLinksOptions {
60 fn from(_a: &actor::GetLinksOptions) -> Self {
61 Self {}
62 }
63}
64
65#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
67pub struct GetActivityOptions {
68 pub include_valid_activity: bool,
70 pub include_rejected_activity: bool,
72 pub include_warrants: bool,
74 pub include_full_records: bool,
76}
77
78impl Default for GetActivityOptions {
79 fn default() -> Self {
80 Self {
81 include_valid_activity: true,
82 include_warrants: true,
83 include_rejected_activity: false,
84 include_full_records: false,
85 }
86 }
87}
88
89impl From<&actor::GetActivityOptions> for GetActivityOptions {
90 fn from(a: &actor::GetActivityOptions) -> Self {
91 Self {
92 include_valid_activity: a.include_valid_activity,
93 include_warrants: a.include_warrants,
94 include_rejected_activity: a.include_rejected_activity,
95 include_full_records: a.include_full_records,
96 }
97 }
98}
99
100#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
102pub enum CountersigningSessionNegotiationMessage {
103 AuthorityResponse(Vec<SignedAction>),
106 EnzymePush(Box<ChainOp>),
109}
110
111pub trait HcP2pHandler: 'static + Send + Sync + std::fmt::Debug {
113 fn handle_call_remote(
115 &self,
116 dna_hash: DnaHash,
117 to_agent: AgentPubKey,
118 zome_call_params_serialized: ExternIO,
119 signature: Signature,
120 ) -> BoxFut<'_, HolochainP2pResult<SerializedBytes>>;
121
122 fn handle_publish(
124 &self,
125 dna_hash: DnaHash,
126 request_validation_receipt: bool,
127 ops: Vec<holochain_types::dht_op::DhtOp>,
128 ) -> BoxFut<'_, HolochainP2pResult<()>>;
129
130 fn handle_get(
132 &self,
133 dna_hash: DnaHash,
134 to_agent: AgentPubKey,
135 dht_hash: holo_hash::AnyDhtHash,
136 options: GetOptions,
137 ) -> BoxFut<'_, HolochainP2pResult<WireOps>>;
138
139 fn handle_get_meta(
141 &self,
142 dna_hash: DnaHash,
143 to_agent: AgentPubKey,
144 dht_hash: holo_hash::AnyDhtHash,
145 options: GetMetaOptions,
146 ) -> BoxFut<'_, HolochainP2pResult<MetadataSet>>;
147
148 fn handle_get_links(
150 &self,
151 dna_hash: DnaHash,
152 to_agent: AgentPubKey,
153 link_key: WireLinkKey,
154 options: GetLinksOptions,
155 ) -> BoxFut<'_, HolochainP2pResult<WireLinkOps>>;
156
157 fn handle_count_links(
159 &self,
160 dna_hash: DnaHash,
161 to_agent: AgentPubKey,
162 query: WireLinkQuery,
163 ) -> BoxFut<'_, HolochainP2pResult<CountLinksResponse>>;
164
165 fn handle_get_agent_activity(
167 &self,
168 dna_hash: DnaHash,
169 to_agent: AgentPubKey,
170 agent: AgentPubKey,
171 query: ChainQueryFilter,
172 options: GetActivityOptions,
173 ) -> BoxFut<'_, HolochainP2pResult<AgentActivityResponse>>;
174
175 fn handle_must_get_agent_activity(
177 &self,
178 dna_hash: DnaHash,
179 to_agent: AgentPubKey,
180 author: AgentPubKey,
181 filter: holochain_zome_types::chain::ChainFilter,
182 ) -> BoxFut<'_, HolochainP2pResult<MustGetAgentActivityResponse>>;
183
184 fn handle_validation_receipts_received(
186 &self,
187 dna_hash: DnaHash,
188 to_agent: AgentPubKey,
189 receipts: ValidationReceiptBundle,
190 ) -> BoxFut<'_, HolochainP2pResult<()>>;
191
192 fn handle_publish_countersign(
194 &self,
195 dna_hash: DnaHash,
196 op: holochain_types::dht_op::ChainOp,
197 ) -> BoxFut<'_, HolochainP2pResult<()>>;
198
199 fn handle_countersigning_session_negotiation(
201 &self,
202 dna_hash: DnaHash,
203 to_agent: AgentPubKey,
204 message: CountersigningSessionNegotiationMessage,
205 ) -> BoxFut<'_, HolochainP2pResult<()>>;
206}
207
208pub type DynHcP2pHandler = Arc<dyn HcP2pHandler>;