-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nolash.
Beside comments below, I did not want to comment on every instance:
- to add copyright header to files that are missing it
- to finish all sentences with a dot so that they are nicely shown in godoc.org
reference/doc.go
Outdated
// Copyright 2020 The Swarm Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a blank line.
bmt.go
Outdated
// BMT provides the necessary extension of the hash interface to add the length-prefix of the BMT hash | ||
// | ||
// Any implementation should make it possible to generate a BMT hash using the hash.Hash interface only. However, the limitation will be that the Span of the BMT hash always must be limited to the amount of bytes actually written. | ||
type BMTHash interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the package is called bmt
, could this type be called just Hash
?
bmt.go
Outdated
"hash" | ||
) | ||
|
||
// BMT provides the necessary extension of the hash interface to add the length-prefix of the BMT hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect type name in comment.
856dc17
to
14c63aa
Compare
Thanks @janos amended |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nolash. Looks good. There are still a few sentences in exported identifiers comments that do not end with a dot.
@janos you're right I was a bit quick there. Is this better? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except the usual rant
bmt.go
Outdated
|
||
// Hash provides the necessary extension of the hash interface to add the length-prefix of the BMT hash. | ||
// | ||
// Any implementation should make it possible to generate a BMT hash using the hash.Hash interface only. However, the limitation will be that the Span of the BMT hash always must be limited to the amount of bytes actually written. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe have this comment split into two lines?
reference/doc.go
Outdated
// license that can be found in the LICENSE file. | ||
|
||
// Package bmt is a simple nonconcurrent reference implementation for hashsize segment based | ||
// Binary Merkle tree hash on arbitrary but fixed maximum chunksize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
somewhat ambivalent.
maybe "on a bounded n
number of bytes such that 0 ≤ n ≤ 4096
bytes`?
reference/reference.go
Outdated
return rh.hash(d, rh.maxDataLength) | ||
} | ||
|
||
// data has length maxDataLength = segmentSize * 2^k |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment more go-doc-ishly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also for unexported?
reference/reference.go
Outdated
// section contains two data segments (d) | ||
section = data | ||
} else { | ||
// section contains hashes of left and right BMT subtreea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like your latin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Only one small comment.
} | ||
|
||
// calculates the Keccak256 SHA3 hash of the data | ||
func sha3hash(t *testing.T, data ...[]byte) []byte { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good this function as t.Helper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That means just add t.Helper()
as first line in the function? @janos
This PR is the initial introduction of the BMT component for use in bee. It contains the interface implementation, along with a reference bmt hash generator largely copied from the
bmt
package ofswarm
. The latter does not implement the BMT interface, it is only intended to generate correct hashes using code that is as easy to understand as possible.Part of ethersphere/bee#39