Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Remove Link #780

Merged
merged 180 commits into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from 117 commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
bce8cc1
Removelink definition
StaticallyTypedAnxiety Dec 18, 2018
2508f7f
changed signature
StaticallyTypedAnxiety Dec 18, 2018
f2a6043
Implemented remove_eav
StaticallyTypedAnxiety Dec 18, 2018
6870c86
Merge branch 'develop' into remove_link
StaticallyTypedAnxiety Dec 18, 2018
a3d3b29
Implemented dht_reducer for remove_link
StaticallyTypedAnxiety Dec 19, 2018
1a3036a
Added RemoveLink Future
StaticallyTypedAnxiety Dec 19, 2018
cf910ba
Cargo fmt
StaticallyTypedAnxiety Dec 19, 2018
79ac2b3
Merge branch 'develop' into remove_link
StaticallyTypedAnxiety Dec 19, 2018
dfe7677
Merge branch 'develop' into remove_link
StaticallyTypedAnxiety Jan 22, 2019
410289b
Merge conflicts resolved
StaticallyTypedAnxiety Jan 25, 2019
d9ef1ec
cargo fmt
StaticallyTypedAnxiety Jan 25, 2019
206e8ce
Added remove_link reducer
StaticallyTypedAnxiety Jan 28, 2019
01a003b
Merge branch 'develop' into remove_link
StaticallyTypedAnxiety Jan 28, 2019
4d91581
Imeplemted remove_link test
StaticallyTypedAnxiety Jan 28, 2019
665578b
Add removelink in waiter
StaticallyTypedAnxiety Jan 28, 2019
87f591f
remove_link workflow added
StaticallyTypedAnxiety Jan 28, 2019
38aa709
cargo fmt
StaticallyTypedAnxiety Jan 28, 2019
0903287
Added prefix ability to index query
StaticallyTypedAnxiety Jan 29, 2019
1530121
Implemented allowed values
StaticallyTypedAnxiety Jan 30, 2019
ec91526
Merge branch 'develop' into remove_link
StaticallyTypedAnxiety Jan 30, 2019
00489f0
remove pritnlns
StaticallyTypedAnxiety Jan 30, 2019
f24cf5a
index_query added on get_links
StaticallyTypedAnxiety Jan 30, 2019
e258a2c
changes to workflow and ribosome funciton for remove_link
StaticallyTypedAnxiety Jan 31, 2019
86ba14f
Made some changes to zomeapifunctions
StaticallyTypedAnxiety Feb 1, 2019
9e31bc7
restrucutered zome ordering
StaticallyTypedAnxiety Feb 1, 2019
6470cac
Implemented app-spec tests and hdk
StaticallyTypedAnxiety Feb 1, 2019
0b334f3
cargo fmt
StaticallyTypedAnxiety Feb 1, 2019
d90dffc
Removed unused imports
StaticallyTypedAnxiety Feb 1, 2019
881ec74
Changes to nodejs_waiter
StaticallyTypedAnxiety Feb 1, 2019
5205a98
updated dht_reducer
StaticallyTypedAnxiety Feb 1, 2019
f94dd80
eav changes
StaticallyTypedAnxiety Feb 1, 2019
b881cd1
fiuxed app-spec tests
StaticallyTypedAnxiety Feb 1, 2019
99785e9
Change around zome code
StaticallyTypedAnxiety Feb 2, 2019
1839268
Change to zome
StaticallyTypedAnxiety Feb 2, 2019
d0130d3
Update app_spec/test/test.js
Feb 4, 2019
9fd38e9
Merge branch 'develop' into remove_link
StaticallyTypedAnxiety Feb 4, 2019
c0efbfa
Merge branch 'remove_link' of https://github.com/holochain/holochain-…
StaticallyTypedAnxiety Feb 4, 2019
be3e4f6
Updated test.js
StaticallyTypedAnxiety Feb 4, 2019
4afecd9
added tests to hdk
StaticallyTypedAnxiety Feb 5, 2019
5448d0b
cargo fmt
StaticallyTypedAnxiety Feb 5, 2019
6e94040
Commit merge
StaticallyTypedAnxiety Feb 5, 2019
27fb579
merge commit
StaticallyTypedAnxiety Feb 5, 2019
bed52fa
App-spec added to capabilities
StaticallyTypedAnxiety Feb 5, 2019
7936612
from merge
StaticallyTypedAnxiety Feb 5, 2019
e22ffcd
from merge
StaticallyTypedAnxiety Feb 5, 2019
1b06232
changed entry
StaticallyTypedAnxiety Feb 5, 2019
99897bd
Merge branch 'develop' into remove_link
StaticallyTypedAnxiety Feb 5, 2019
b485182
app_spec tests
StaticallyTypedAnxiety Feb 5, 2019
9d980e1
Merge branch 'remove_link' of https://github.com/holochain/holochain-…
StaticallyTypedAnxiety Feb 5, 2019
ea82a79
changes to app_spec
StaticallyTypedAnxiety Feb 5, 2019
f1d9585
Update remove_link
StaticallyTypedAnxiety Feb 5, 2019
c2413cb
update remove_link
StaticallyTypedAnxiety Feb 5, 2019
2cf41bd
validation changes
StaticallyTypedAnxiety Feb 5, 2019
9146952
cargo fmt
StaticallyTypedAnxiety Feb 5, 2019
14fff01
cargo fmt
StaticallyTypedAnxiety Feb 5, 2019
90612c8
updated remove_link
StaticallyTypedAnxiety Feb 5, 2019
0845fc5
Update remove_link
StaticallyTypedAnxiety Feb 5, 2019
4fffcc4
changes to zome
StaticallyTypedAnxiety Feb 5, 2019
721df5d
Update blog.rs
StaticallyTypedAnxiety Feb 5, 2019
3fd9b9f
Update remove_link.rs
StaticallyTypedAnxiety Feb 5, 2019
5c60d76
validate link_remove
StaticallyTypedAnxiety Feb 5, 2019
1091753
Updated document comments
StaticallyTypedAnxiety Feb 6, 2019
488b436
updated
StaticallyTypedAnxiety Feb 6, 2019
fe6e94d
Update validation_package.rs
StaticallyTypedAnxiety Feb 6, 2019
97e01b6
Update validation_package.rs
StaticallyTypedAnxiety Feb 6, 2019
082c9b2
App-spec debug
StaticallyTypedAnxiety Feb 7, 2019
87a40cc
Update author_entry.rs
StaticallyTypedAnxiety Feb 7, 2019
026607d
Update author_entry.rs
StaticallyTypedAnxiety Feb 7, 2019
1a31f8f
Update test.js
StaticallyTypedAnxiety Feb 7, 2019
63fa43f
Update test.js
StaticallyTypedAnxiety Feb 7, 2019
561133d
Update test.js
StaticallyTypedAnxiety Feb 7, 2019
2a9048f
Update test.js
StaticallyTypedAnxiety Feb 7, 2019
b283809
clean up changes
StaticallyTypedAnxiety Feb 7, 2019
213d143
Remove fluff
StaticallyTypedAnxiety Feb 7, 2019
f03fb13
Better error handling on fold
StaticallyTypedAnxiety Feb 7, 2019
ccd4f46
fixed merge
StaticallyTypedAnxiety Feb 7, 2019
725a00e
Update remove_link.rs
StaticallyTypedAnxiety Feb 7, 2019
44d19b6
used is_empty better
StaticallyTypedAnxiety Feb 7, 2019
6ff187f
Fixed extra brace
StaticallyTypedAnxiety Feb 7, 2019
2215748
Cargo fmt
StaticallyTypedAnxiety Feb 7, 2019
de88314
Delete tmp-test_add_instance-container-config.toml
StaticallyTypedAnxiety Feb 7, 2019
b43b89d
Delete tmp-test_install_dna_from_file-container-config.toml
StaticallyTypedAnxiety Feb 7, 2019
ca09aa9
Delete tmp-test_remove_instance-container-config.toml
StaticallyTypedAnxiety Feb 7, 2019
b93f4ff
Delete tmp-test_uninstall_dna-container-config.toml
StaticallyTypedAnxiety Feb 7, 2019
180c25b
Removed node modules
StaticallyTypedAnxiety Feb 7, 2019
74f4c96
Removed contianer reminants
StaticallyTypedAnxiety Feb 7, 2019
38115a4
Update Cargo.toml
StaticallyTypedAnxiety Feb 7, 2019
e3f2e0d
clean up
StaticallyTypedAnxiety Feb 7, 2019
8726162
Update eav.rs
StaticallyTypedAnxiety Feb 7, 2019
eaf9967
Update macros.rs
StaticallyTypedAnxiety Feb 7, 2019
dc429d8
Update context.rs
StaticallyTypedAnxiety Feb 7, 2019
5334884
Update core_types/src/eav.rs
sphinxc0re Feb 7, 2019
e4ab912
Update macros.rs
StaticallyTypedAnxiety Feb 7, 2019
ef3160f
Merge branch 'remove_link' of https://github.com/holochain/holochain-…
StaticallyTypedAnxiety Feb 7, 2019
6013f96
Merge branch 'develop' into remove_link
StaticallyTypedAnxiety Feb 7, 2019
24c510c
Merge branch 'develop' into remove_link
StaticallyTypedAnxiety Feb 7, 2019
a1e9bca
Merge branch 'develop' into remove_link
StaticallyTypedAnxiety Feb 8, 2019
a804279
using author entry instead of direct remove_link workflow
StaticallyTypedAnxiety Feb 8, 2019
21c3fb6
Merge branch 'remove_link' of https://github.com/holochain/holochain-…
StaticallyTypedAnxiety Feb 8, 2019
c955ce4
cargo fmt
StaticallyTypedAnxiety Feb 8, 2019
d4f1f15
app_spec debug
StaticallyTypedAnxiety Feb 8, 2019
1f6b7e2
unute logs for test
StaticallyTypedAnxiety Feb 8, 2019
a260cfb
updated
StaticallyTypedAnxiety Feb 8, 2019
fdce4a5
Multinode_app_spec test
StaticallyTypedAnxiety Feb 8, 2019
724586e
changes to linkAdd
StaticallyTypedAnxiety Feb 8, 2019
48d2cfe
uupdated LinkActionKind
StaticallyTypedAnxiety Feb 8, 2019
2cab38f
updated Link_add
StaticallyTypedAnxiety Feb 8, 2019
6f4f6bb
link_data changes
StaticallyTypedAnxiety Feb 8, 2019
7d801ec
cargo fmt
StaticallyTypedAnxiety Feb 8, 2019
38643fe
Update waiter.rs
StaticallyTypedAnxiety Feb 8, 2019
31ce29d
Update waiter.rs
StaticallyTypedAnxiety Feb 8, 2019
d28e796
Fixed merge conflict
StaticallyTypedAnxiety Feb 8, 2019
afc1dea
Update shell.nix
StaticallyTypedAnxiety Feb 8, 2019
4af6f2b
Merge branch 'develop' into remove_link
StaticallyTypedAnxiety Feb 8, 2019
c7420b0
Merge branch 'develop' into remove_link
StaticallyTypedAnxiety Feb 11, 2019
aefdbc8
Fixed app_spec merge conflicts
StaticallyTypedAnxiety Feb 11, 2019
d91654d
Update lib.rs
StaticallyTypedAnxiety Feb 11, 2019
81230e3
Update core/src/dht/dht_reducers.rs
zippy Feb 11, 2019
5b99a8f
Update core/src/workflows/remove_link.rs
Feb 11, 2019
2ec9b6f
Update core/src/network/handler/store.rs
Feb 11, 2019
272c0c5
Update app_spec/test/test.js
Feb 11, 2019
83585ab
Added test for eavi prefixes
StaticallyTypedAnxiety Feb 11, 2019
707f17a
workflow_link_tests
StaticallyTypedAnxiety Feb 11, 2019
7e5817b
cargo fmt
StaticallyTypedAnxiety Feb 11, 2019
98a5c15
Merge branch 'remove_link' of https://github.com/holochain/holochain-…
StaticallyTypedAnxiety Feb 11, 2019
97a9640
removed println
StaticallyTypedAnxiety Feb 11, 2019
a88bffe
New app_spec test
StaticallyTypedAnxiety Feb 11, 2019
c32000a
app_spec_for_debug
StaticallyTypedAnxiety Feb 11, 2019
c143b1e
cargo fmt
StaticallyTypedAnxiety Feb 11, 2019
9aaeb35
Update storage.rs
StaticallyTypedAnxiety Feb 11, 2019
f994df9
Update test.js
StaticallyTypedAnxiety Feb 11, 2019
1fe629c
Update test.js
StaticallyTypedAnxiety Feb 11, 2019
eb1eb64
Update app_spec/zomes/blog/code/src/lib.rs
maackle Feb 11, 2019
2619d56
Update app_spec/zomes/blog/code/src/blog.rs
maackle Feb 11, 2019
5265de4
app spec delete
StaticallyTypedAnxiety Feb 11, 2019
f7bba1d
Merge branch 'remove_link' of https://github.com/holochain/holochain-…
StaticallyTypedAnxiety Feb 11, 2019
f4d69a9
Update test.js
StaticallyTypedAnxiety Feb 11, 2019
1b18319
Update test.js
StaticallyTypedAnxiety Feb 11, 2019
ba8078b
Update test.js
StaticallyTypedAnxiety Feb 11, 2019
9aa1f1d
Update test.js
StaticallyTypedAnxiety Feb 11, 2019
419e2b9
app_spec changes
StaticallyTypedAnxiety Feb 12, 2019
9bc3596
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
b8cbec9
Update lib.rs
StaticallyTypedAnxiety Feb 12, 2019
9c3fa4d
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
5c85440
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
447d98e
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
6cc5a43
app_spec debug
StaticallyTypedAnxiety Feb 12, 2019
496346e
app_spec debug
StaticallyTypedAnxiety Feb 12, 2019
0d16587
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
494d2bd
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
c734ce9
app_spec debug
StaticallyTypedAnxiety Feb 12, 2019
e139454
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
e8b45aa
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
7809916
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
f8de250
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
27fcd00
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
b24270b
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
3706b46
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
bba7175
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
43e7930
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
208b4f9
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
c923244
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
c3c7bba
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
e39fef6
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
caba2b0
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
89183c7
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
d3195e9
Update test.js
StaticallyTypedAnxiety Feb 12, 2019
eb266c0
updated to test
StaticallyTypedAnxiety Feb 12, 2019
7dd5a66
implemented app_spec test
StaticallyTypedAnxiety Feb 12, 2019
a720527
removed invalid syntax
StaticallyTypedAnxiety Feb 12, 2019
2df9447
changed from unwrap_or to unwrap_or_default
StaticallyTypedAnxiety Feb 12, 2019
0064d07
Update eav.rs
StaticallyTypedAnxiety Feb 12, 2019
a7ae19a
Merge branch 'develop' into remove_link
zippy Feb 12, 2019
4f4fe72
changed to use if let
StaticallyTypedAnxiety Feb 12, 2019
84f241b
Merge branch 'remove_link' of https://github.com/holochain/holochain-…
StaticallyTypedAnxiety Feb 12, 2019
efc4de1
Update app_spec/test/test.js
Feb 12, 2019
c089f53
removed trailing spaces
StaticallyTypedAnxiety Feb 12, 2019
c5a7bc3
removed trailing spaces
StaticallyTypedAnxiety Feb 12, 2019
bcae33e
Revert "removed trailing spaces"
StaticallyTypedAnxiety Feb 12, 2019
99be951
Revert "removed trailing spaces"
StaticallyTypedAnxiety Feb 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 38 additions & 21 deletions app_spec/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,44 @@ scenario1.runTape('create_post', async (t, { alice }) => {
t.equal(result.Ok, "QmY6MfiuhHnQ1kg7RwNZJNUQhwDxTFL45AAPnpJMNPEoxk")
})

scenario2.runTape('delete_post', async (t, { alice, bob }) => {

scenario1.runTape('delete_post', async (t, { alice }) => {
t.plan(3)

const content = "Hello Holo world 321"
const in_reply_to = null
const params = { content, in_reply_to }
const createResult = alice.call("blog", "create_post", params)

t.ok(createResult.Ok)

const deletionParams = { post_address: createResult.Ok }
const deletionResult = alice.call("blog", "delete_post", deletionParams)

t.equals(deletionResult.Ok, null)

const paramsGet = { post_address: createResult.Ok }
const result = alice.call("blog", "get_post", paramsGet)

t.equals(result.Ok, null)
})
await alice.callSync("blog", "create_post",
{ "content": "Posty", "in_reply_to": "" }
)
const result_create_post = alice.call("blog", "my_posts", {})
StaticallyTypedAnxiety marked this conversation as resolved.
Show resolved Hide resolved
t.equal(result_create_post.Ok.addresses.length, 1)
await alice.callSync("blog", "delete_post",
{ "content": "Posty"}
)
const result_delete_post = alice.call("blog", "my_posts", {})
t.equal(result_delete_post.Ok.addresses.length, 0)

const result_delete_post_bob = bob.call("blog", "my_posts", {})
t.equal(result_delete_post_bob.Ok.addresses.length, 0)

})

scenario1.runTape('delete_entry_post', async (t, { alice }) => {
t.plan(3)

const content = "Hello Holo world 321"
const in_reply_to = null
const params = { content, in_reply_to }
const createResult = alice.call("blog", "create_post", params)

t.ok(createResult.Ok)

const deletionParams = { post_address: createResult.Ok }
const deletionResult = alice.call("blog", "delete_entry_post", deletionParams)

t.equals(deletionResult.Ok, null)

const paramsGet = { post_address: createResult.Ok }
const result = alice.call("blog", "get_post", paramsGet)

t.equals(result.Ok, null)
})

scenario1.runTape('update_post', async (t, { alice }) => {
t.plan(4)
Expand All @@ -123,7 +140,7 @@ scenario1.runTape('update_post', async (t, { alice }) => {
t.deepEqual(JSON.parse(updatedPost.Ok.App[1]), { content: "Hello Holo", date_created: "now" })
})

scenario1.runTape('create_post with bad reply to', async (t, { alice }) => {
scenario1.runTape('create_post with bad reply to', async (t, { alice }) => {
t.plan(5)

const content = "Holo world"
Expand Down
9 changes: 8 additions & 1 deletion app_spec/zomes/blog/code/src/blog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ pub fn handle_create_post(content: String, in_reply_to: Option<Address>) -> Zome
Ok(address)
}

pub fn handle_delete_post(content:String) -> ZomeApiResult<Address>
{
let address = hdk::entry_address(&post_entry(content))?;
hdk::remove_link(&AGENT_ADDRESS,&address.clone(),"authored_posts")?;
Ok(address)
}

pub fn handle_posts_by_agent(agent: Address) -> ZomeApiResult<GetLinksResult> {
hdk::get_links(&agent, "authored_posts")
}
Expand Down Expand Up @@ -137,7 +144,7 @@ pub fn handle_get_post(post_address: Address) -> ZomeApiResult<Option<Entry>> {
hdk::get_entry(&post_address)
}

pub fn handle_delete_post(post_address: Address) -> ZomeApiResult<()> {
pub fn handle_entry_delete_post(post_address: Address) -> ZomeApiResult<()> {
StaticallyTypedAnxiety marked this conversation as resolved.
Show resolved Hide resolved
hdk::get_entry(&post_address)?;

hdk::remove_entry(&post_address)?;
Expand Down
8 changes: 7 additions & 1 deletion app_spec/zomes/blog/code/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ define_zome! {
}

delete_post: {
inputs: |content: String|,
outputs: |result: ZomeApiResult<Address>|,
handler: blog::handle_delete_post
}

delete_entry_post: {
inputs: |post_address: Address|,
outputs: |result: ZomeApiResult<()>|,
handler: blog::handle_delete_post
handler: blog::handle_entry_delete_post
StaticallyTypedAnxiety marked this conversation as resolved.
Show resolved Hide resolved
}

update_post: {
Expand Down
58 changes: 40 additions & 18 deletions cas_implementations/src/eav/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,44 @@ impl EntityAttributeValueStorage for EavFileStorage {
index_query: IndexQuery,
) -> Result<BTreeSet<EntityAttributeValueIndex>, HolochainError> {
let _guard = self.lock.read()?;
let entity_set = self.read_from_dir::<Entity>(ENTITY_DIR.to_string(), entity.clone())?;
let attribute_set = self
.read_from_dir::<Attribute>(ATTRIBUTE_DIR.to_string(), attribute)?
.clone();
let value_set = self.read_from_dir::<Value>(VALUE_DIR.to_string(), value)?;

let attribute_value_inter: BTreeSet<String> = value_set
.intersection(&attribute_set.clone())
.cloned()
.collect();
let entity_attribute_value_inter: BTreeSet<String> = attribute_value_inter
.intersection(&entity_set)
.cloned()
.collect();

let (eav, error): (BTreeSet<_>, BTreeSet<_>) = entity_attribute_value_inter
let prefixes = if !index_query.prefixes().is_empty() {
index_query.prefixes().clone()
} else {
vec![""]
};
let union_set: BTreeSet<String> = BTreeSet::new();
let entity_attribute_value_union = prefixes.iter().fold(
Ok(union_set.clone()),
|set: Result<BTreeSet<String>, HolochainError>, prefix: &&str| {
let entity_set =
self.read_from_dir::<Entity>(ENTITY_DIR.to_string(), entity.clone())?;
let attribute_with_prefix = attribute
.clone()
.map(|attri| prefix.to_string() + &attri.clone());
let attribute_set = self
.read_from_dir::<Attribute>(ATTRIBUTE_DIR.to_string(), attribute_with_prefix)
.clone()?;
let value_set =
self.read_from_dir::<Value>(VALUE_DIR.to_string(), value.clone())?;

let attribute_value_inter: BTreeSet<String> = value_set
.intersection(&attribute_set.clone())
.cloned()
.collect();
let entity_attribute_value_inter: BTreeSet<String> = attribute_value_inter
.intersection(&entity_set)
.cloned()
.collect();
let to_union = set?;
Ok(to_union
.union(&entity_attribute_value_inter)
.cloned()
.collect())
},
);

let (eav, error): (BTreeSet<_>, BTreeSet<_>) = entity_attribute_value_union?
.clone()
.into_iter()
.map(|content| EntityAttributeValueIndex::try_from_content(&JsonString::from(content)))
.partition(|c| c.is_ok());
Expand All @@ -232,7 +254,7 @@ impl EntityAttributeValueStorage for EavFileStorage {
.start()
.map(|start| start <= e.index())
.unwrap_or_else(|| {
let latest = get_latest(e.clone(), map.clone())
let latest = get_latest(e.clone(), map.clone(), index_query.clone())
.unwrap_or(EntityAttributeValueIndex::default());
latest.index() == e.index()
})
Expand All @@ -242,7 +264,7 @@ impl EntityAttributeValueStorage for EavFileStorage {
.end()
.map(|end| end >= e.index())
.unwrap_or_else(|| {
let latest = get_latest(e.clone(), map.clone())
let latest = get_latest(e.clone(), map.clone(), index_query.clone())
.unwrap_or(EntityAttributeValueIndex::default());
latest.index() == e.index()
})
Expand Down
10 changes: 7 additions & 3 deletions cas_implementations/src/eav/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,19 @@ impl EntityAttributeValueStorage for EavMemoryStorage {
.into_iter()
.filter(|e| EntityAttributeValueIndex::filter_on_eav(&e.entity(), entity.as_ref()))
.filter(|e| {
EntityAttributeValueIndex::filter_on_eav(&e.attribute(), attribute.as_ref())
EntityAttributeValueIndex::filter_on_eav_with_prefix(
&e.attribute(),
attribute.as_ref(),
&index_query,
)
})
.filter(|e| EntityAttributeValueIndex::filter_on_eav(&e.value(), value.as_ref()))
.filter(|e| {
index_query
.start()
.map(|start| start <= e.index())
.unwrap_or_else(|| {
let latest = get_latest(e.clone(), map.clone())
let latest = get_latest(e.clone(), map.clone(), index_query.clone())
.unwrap_or(EntityAttributeValueIndex::default());
latest.index() == e.index()
})
Expand All @@ -75,7 +79,7 @@ impl EntityAttributeValueStorage for EavMemoryStorage {
.end()
.map(|end| end >= e.index())
.unwrap_or_else(|| {
let latest = get_latest(e.clone(), map.clone())
let latest = get_latest(e.clone(), map.clone(), index_query.clone())
.unwrap_or(EntityAttributeValueIndex::default());
latest.index() == e.index()
})
Expand Down
Empty file modified conductor/src/main.rs
100755 → 100644
Empty file.
Empty file modified conductor_api/src/lib.rs
100755 → 100644
Empty file.
3 changes: 3 additions & 0 deletions core/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ pub enum Action {
/// Does not validate, assumes link is valid.
AddLink(Link),

//Removes a link for the local DHT
RemoveLink(Link),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last I heard about removing links (a few weeks ago), I thought it had to reference the hash of a previously issued AddLink. If so, shouldn't that be part of the action?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per heartbeat, we decided we don't need this for closed alpha and can go forward with this implementation


// ----------------
// Network actions:
// ----------------
Expand Down
1 change: 1 addition & 0 deletions core/src/dht/actions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod add_link;
pub mod hold;
pub mod remove_entry;
pub mod remove_link;
59 changes: 59 additions & 0 deletions core/src/dht/actions/remove_link.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
extern crate futures;
extern crate serde_json;
use crate::{
action::{Action, ActionWrapper},
context::Context,
instance::dispatch_action,
};
use futures::{
future::Future,
task::{LocalWaker, Poll},
};
use holochain_core_types::{error::HolochainError, link::Link};
use std::{pin::Pin, sync::Arc};

/// RemoveLink Action Creator
/// This action creator dispatches an RemoveLink action which is consumed by the DHT reducer.
/// Note that this function does not include any validation checks for the link.
/// The DHT reducer does make sure that it only removes links to a base that it has in its
/// local storage and will return an error that the RemoveLinkFuture resolves to
/// if that is not the case.
///
/// Returns a future that resolves to an Ok(()) or an Err(HolochainError).
pub fn remove_link(link: &Link, context: &Arc<Context>) -> RemoveLinkFuture {
let action_wrapper = ActionWrapper::new(Action::RemoveLink(link.clone()));
dispatch_action(context.action_channel(), action_wrapper.clone());

RemoveLinkFuture {
context: context.clone(),
action: action_wrapper,
}
}

pub struct RemoveLinkFuture {
context: Arc<Context>,
action: ActionWrapper,
}

impl Unpin for RemoveLinkFuture {}

impl Future for RemoveLinkFuture {
type Output = Result<(), HolochainError>;

fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Self::Output> {
//
// TODO: connect the waker to state updates for performance reasons
// See: https://github.com/holochain/holochain-rust/issues/314
//
lw.wake();
if let Some(state) = self.context.state() {
match state.dht().actions().get(&self.action) {
Some(Ok(_)) => Poll::Ready(Ok(())),
Some(Err(e)) => Poll::Ready(Err(e.clone())),
None => Poll::Pending,
}
} else {
Poll::Pending
}
}
}
Loading