Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

bmt, file: Extract AsyncHasher to separate package #2097

Merged
merged 3 commits into from
Feb 11, 2020

Conversation

nolash
Copy link
Contributor

@nolash nolash commented Feb 8, 2020

This PR is part of a series of PRs that introduces an interface that allows chaining of components that receive a data stream and generate hashes and intermediate Merkle-Tree chunks. The individual PR steps will be partitioned from #2022 (branch https://github.com/nolash/swarm/tree/filehasher-avenged ) as follows:

  1. Introduce SectionWriter, implement this interface in bmt, make AsyncHasher standalone
  2. Move AsyncHasher to file/hasher (this PR)
  3. Add reference implementation of the Filehasher algorithm
  4. Add implementation of SectionWriter sub-component for hashing intermediate Merkle Tree levels.
  5. Add implementation of SectionWriter component executing the FileHasher algorithm
  6. Add a "splitter" that bridges io.Reader and SectionWriter, and an implementation of SectionWriter component that provides Chunk output.
  7. Add implementation of SectionWriter that provides encryption, along with a test utility SectionWriter implentation of a data cache.
  8. Evaluate and prune bmt.Hasher exports wtr AsyncHasher

This PR does not alter any logic. It merely moves the AsyncHasher object to the file/hasher package, while exporting a few consts and vars in bmt/testutil that are used across the sync and async tests.

@nolash nolash added hashing cleanup code completion, add comments and more labels Feb 8, 2020
@nolash nolash self-assigned this Feb 8, 2020
@nolash nolash requested review from janos and pradovic February 8, 2020 17:35
Copy link
Contributor

@pradovic pradovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice work!

@@ -0,0 +1,13 @@
package testutil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add copyright header to all new files.

t.ReportAllocs()
t.ResetTimer()
for i := 0; i < t.N; i++ {
asyncHash(bmtobj, 0, n, wh, idxs, segments)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this benchmark be unexpectedly optimised by compiler as the function result is not used anywhere?

Copy link
Member

@janos janos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nolash nolash merged commit 11809ce into ethersphere:master Feb 11, 2020
@nolash nolash deleted the extract-asynchasher branch February 11, 2020 11:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cleanup code completion, add comments and more hashing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants