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

impossible states: EntryWithHeader to ChainItem #946

Open
@thedavidmeister

Description

@thedavidmeister

in the spirit of impossible states

EntryWithHeader is any entry any header

impl EntryWithHeader {
    pub fn new(entry: Entry, header: ChainHeader) -> EntryWithHeader {
        EntryWithHeader { entry, header }
    }
}

we ?always? want a specific header/entry combo (the header in a chain and the entry referenced and hashed by the header)

name suggestions:

  • ChainItem
  • ChainLink
  • ChainPair
  • ChainJoint

a ChainFoo::new() should fail if the ChainHeader.entry_address() does not match Entry.address()

ideally a seq of ChainFoo structs could be validated (individual integrity and valid ordering/references)

a ChainFoo uses a simple tuple structure (for easy destructuring) and is immutable:

pub struct ChainFoo(ChainHeader, Entry);

impl ChainFoo {

  pub fn new(header: ChainHeader, entry: Entry) -> Result<ChainFoo, HolochainError> {
    if header.entry().address() = entry.address() {
      Ok(ChainFoo(header, entry))
    }
    else {
      Err(HolochainError::InternalError("Header/Entry mismatch"))
    }
  }

  pub fn header(&self) -> ChainHeader {
    self.0.clone()
  }

  pub fn entry(&self) -> Entry {
    self.1.clone()
  }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    impossible stateshttps://hackmd.io/QPgBfOk4TwOMrZnCCE46ZA?both#Make-invalid-states-impossible-MISI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions