1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
use action::ActionWrapper;
use holochain_core_types::{
cas::{
content::{Address, AddressableContent, Content},
storage::ContentAddressableStorage,
},
eav::{EntityAttributeValue, EntityAttributeValueStorage},
error::HolochainError,
hash::HashString,
links_entry::Link,
};
use std::collections::{HashMap, HashSet};
#[derive(Clone, Debug, PartialEq)]
pub struct Network {
}
impl Network {
pub fn publish(&mut self, _content: &AddressableContent) {
}
pub fn publish_meta(&mut self, _meta: &EntityAttributeValue) {
}
pub fn get(&mut self, _address: &Address) -> Option<Content> {
None
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct DhtStore<CAS, EAVS>
where
CAS: ContentAddressableStorage + Sized + Clone + PartialEq,
EAVS: EntityAttributeValueStorage + Sized + Clone + PartialEq,
{
content_storage: CAS,
meta_storage: EAVS,
network: Network,
add_link_actions: HashMap<ActionWrapper, Result<(), HolochainError>>,
}
impl<CAS, EAVS> DhtStore<CAS, EAVS>
where
CAS: ContentAddressableStorage + Sized + Clone + PartialEq,
EAVS: EntityAttributeValueStorage + Sized + Clone + PartialEq,
{
pub fn new(content_storage: CAS, meta_storage: EAVS) -> Self {
let network = Network {};
DhtStore {
content_storage,
meta_storage,
network,
add_link_actions: HashMap::new(),
}
}
pub fn add_link(&mut self, _link: &Link) -> Result<(), HolochainError> {
Err(HolochainError::NotImplemented)
}
pub fn remove_link(&mut self) {
}
pub fn get_links(
&self,
address: HashString,
tag: String,
) -> Result<HashSet<EntityAttributeValue>, HolochainError> {
self.meta_storage
.fetch_eav(Some(address), Some(format!("link:{}", tag)), None)
}
pub fn content_storage(&self) -> CAS {
self.content_storage.clone()
}
pub(crate) fn content_storage_mut(&mut self) -> &mut CAS {
&mut self.content_storage
}
pub fn meta_storage(&self) -> EAVS {
self.meta_storage.clone()
}
pub(crate) fn meta_storage_mut(&mut self) -> &mut EAVS {
&mut self.meta_storage
}
pub(crate) fn network(&self) -> &Network {
&self.network
}
pub(crate) fn network_mut(&mut self) -> &mut Network {
&mut self.network
}
pub fn add_link_actions(&self) -> &HashMap<ActionWrapper, Result<(), HolochainError>> {
&self.add_link_actions
}
pub(crate) fn add_link_actions_mut(
&mut self,
) -> &mut HashMap<ActionWrapper, Result<(), HolochainError>> {
&mut self.add_link_actions
}
}