Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncHasher ¶
type AsyncHasher struct { *bmt.Hasher // extends the Hasher // contains filtered or unexported fields }
AsyncHasher extends BMT Hasher with an asynchronous segment.GetSection() writer interface AsyncHasher cannot be used as with a hash.Hash interface: It must be used with the right indexes and length and the right number of sections It is unsafe and does not check indexes and section data lengths
behaviour is undefined if * non-final sections are shorter or longer than secsize * if final section does not match length * write a section with index that is higher than length/secsize * set length in Sum call when length/secsize < maxsec
- if Sum() is not called on a Hasher that is fully written a process will block, can be terminated with Reset
- it will not leak processes if not all sections are written but it blocks and keeps the resource which can be released calling Reset()
func NewAsyncHasher ¶
func NewAsyncHasher(ctx context.Context, h *bmt.Hasher, double bool, errFunc func(error)) *AsyncHasher
NewAsyncWriter extends Hasher with an interface for concurrent segment.GetSection() writes TODO: Instead of explicitly setting double size of segment should be dynamic and chunked internally. If not, we have to keep different bmt hashers generation functions for different purposes in the same instance, or cope with added complexity of bmt hasher generation functions having to receive parameters
func (*AsyncHasher) Branches ¶
func (sw *AsyncHasher) Branches() int
Branches implements file.SectionWriter
func (*AsyncHasher) SectionSize ¶
func (sw *AsyncHasher) SectionSize() int
SectionSize implements file.SectionWriter
func (*AsyncHasher) SumIndexed ¶
func (sw *AsyncHasher) SumIndexed(b []byte, length int) (s []byte)
Sum can be called any time once the length and the span is known potentially even before all segments have been written in such cases Sum will block until all segments are present and the hash for the length can be calculated.
b: digest is appended to b length: known length of the input (unsafe; undefined if out of range) meta: metadata to hash together with BMT root for the final digest
e.g., span for protection against existential forgery
func (*AsyncHasher) WriteIndexed ¶
func (sw *AsyncHasher) WriteIndexed(i int, section []byte)
WriteSection writes the i-th section of the BMT base this function can and is meant to be called concurrently it sets max segment threadsafely