Hi all -
I am trying to update entries in a private source chain.
I create the entry like this, with an anchor and a path:
let entry_input = blah blah
create_entry(&entry_input)?;
let entry_input_hash = hash_entry(&entry_input)?;
let path = anchor_path(AgentPubKey::from(agent_info()?.agent_latest_pubkey.clone()));
path.ensure()?;
create_link(path.hash()?, entry_input_hash.clone(), ())?;
The anchor is specified by agentpubkey to avoid hotspotting.
Next I want to update an entry. I get the headerhash and update it with this function:
#[hdk_extern]
pub fn update_entry(header_hash: HeaderHash) -> ExternResult<HeaderHash> {
let agent_info = agent_info()?;
hdk::prelude::update_entry(header_hash.clone(),EntryStruct{
EntryStructFields: newdata
})
}
I can use the returned header hash to validate that the entry has been made.
The problem is that I am using a general ‘list entries’ function and - after making this update - I am expecting the relevant entry to change, but it does not. The ‘list entries’ function I use is like this:
pub fn list_entries() -> ExternResult<Vec<EntryOutput>> {
let path = anchor_path(AgentPubKey::from(agent_info()?.agent_latest_pubkey.clone()));
let links = get_links(path.hash()?, None)?;
let mut results = vec![];
for a in links
.iter()
{
let entrys = utils::try_get_and_convert::<EntryStruct>(HoloHash::from(a.target.clone()))?;
results.push(EntryStructOutput{
entry_hash:HoloHash::from(a.target.clone()),
entry:entrys
})
}
return Ok(results);
}
This function always returns the same entries, even if I update or delete one of them. Is this expected? Do I also have to do some updating of links or something?
I get that the original entry still exists in the source chain, but I presumed that the update_entry function would also take care of paths and links but possibly not. Any advice here much appreciated.
Thanks - alex.