Updating entries and listing them

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
let entry_input_hash = hash_entry(&entry_input)?;
let path = anchor_path(AgentPubKey::from(agent_info()?.agent_latest_pubkey.clone()));
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:

pub fn update_entry(header_hash: HeaderHash) -> ExternResult<HeaderHash> {
    let agent_info = agent_info()?;

        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
            let entrys = utils::try_get_and_convert::<EntryStruct>(HoloHash::from(a.target.clone()))?;
        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.

1 Like

something else I notice is that if I instead try to delete this entry completely, then my ‘list_entries’ function just fails.

For example, I have 4 entries and I use this function to delete the last one:

pub fn delete_record(header_hash: HeaderHash) -> ExternResult<HeaderHash> {

Now I expect that if I call the ‘list_entries’ function then it returns only the first 3 entries. However, what happens is that I get this error:

19:26:27 [tryorama] e[31merrore[39m: Test error: {
          type: 'error',
          data: {
            type: 'ribosome_error',
            data: 'Wasm error while working with Ribosome: Guest("Could not find entry")'

It might be a totally different issue, but can anyone help me understand why I am not simply getting back the 3 entries that haven’t been deleted??

1 Like