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
Description
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()
}
}