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

Commit

Permalink
Merge pull request #926 from holochain/headers-package-fix
Browse files Browse the repository at this point in the history
Fix chain headers for validation package
  • Loading branch information
Connoropolous committed Jan 30, 2019
2 parents 3c307ae + cc85ecd commit 11b6949
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated dependencies:
* Rust nightly to `2019-01-24`
* futures to `0.3.0-alpha.12`
- Adjusted so that all chain headers are sent in the validation package, not just those for public entry types
### Added
- All structs/values to all HDK functions must implement `Into<JsonString>` and `TryFrom<JsonString>` (derive `DefaultJson` to do this automatically)
- HDK globals `AGENT_ADDRESS`, `AGENT_ID_STR`, `DNA_NAME` and `DNA_ADDRESS` are now set to real, correct values.
Expand Down
15 changes: 6 additions & 9 deletions core/src/nucleus/actions/build_validation_package.rs
Expand Up @@ -120,13 +120,13 @@ pub fn build_validation_package(entry: &Entry, context: &Arc<Context>) -> Valida
}
ChainHeaders => {
let mut package = ValidationPackage::only_header(entry_header);
package.source_chain_headers = Some(all_public_chain_headers(&context));
package.source_chain_headers = Some(all_chain_headers(&context));
package
}
ChainFull => {
let mut package = ValidationPackage::only_header(entry_header);
package.source_chain_entries = Some(all_public_chain_entries(&context));
package.source_chain_headers = Some(all_public_chain_headers(&context));
package.source_chain_headers = Some(all_chain_headers(&context));
package
}
Custom(string) => {
Expand Down Expand Up @@ -172,13 +172,10 @@ fn all_public_chain_entries(context: &Arc<Context>) -> Vec<Entry> {
.collect::<Vec<_>>()
}

fn all_public_chain_headers(context: &Arc<Context>) -> Vec<ChainHeader> {
fn all_chain_headers(context: &Arc<Context>) -> Vec<ChainHeader> {
let chain = context.state().unwrap().agent().chain();
let top_header = context.state().unwrap().agent().top_chain_header();
chain
.iter(&top_header)
.filter(|ref chain_header| chain_header.entry_type().can_publish())
.collect::<Vec<_>>()
chain.iter(&top_header).collect()
}

/// ValidationPackageFuture resolves to the ValidationPackage or a HolochainError.
Expand Down Expand Up @@ -295,7 +292,7 @@ mod tests {
let expected = ValidationPackage {
chain_header: Some(chain_header),
source_chain_entries: None,
source_chain_headers: Some(all_public_chain_headers(&context)),
source_chain_headers: Some(all_chain_headers(&context)),
custom: None,
};

Expand All @@ -322,7 +319,7 @@ mod tests {
let expected = ValidationPackage {
chain_header: Some(chain_header),
source_chain_entries: Some(all_public_chain_entries(&context)),
source_chain_headers: Some(all_public_chain_headers(&context)),
source_chain_headers: Some(all_chain_headers(&context)),
custom: None,
};

Expand Down
6 changes: 3 additions & 3 deletions core_types/src/validation.rs
Expand Up @@ -29,13 +29,13 @@ impl ValidationPackage {

#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, DefaultJson)]
pub enum ValidationPackageDefinition {
/// sending only the entry
/// send the header for the entry, along with the entry
Entry,
/// sending all (public?) source chain entries
/// sending all public source chain entries
ChainEntries,
/// sending all source chain headers
ChainHeaders,
/// sending the whole chain, entries and headers
/// sending the whole chain: public entries and all headers
ChainFull,
/// sending something custom
Custom(String),
Expand Down

0 comments on commit 11b6949

Please sign in to comment.