diff options
| author | Thibaut Horel <thibaut.horel@gmail.com> | 2016-05-04 17:24:19 -0400 |
|---|---|---|
| committer | Thibaut Horel <thibaut.horel@gmail.com> | 2016-05-04 17:24:19 -0400 |
| commit | aedc910c844d79713f5e544a211ceabf4372c687 (patch) | |
| tree | 1a50e59ce8cfffe8742142a4c651396c2391552a | |
| parent | ebeffe49049d06a31e7f9497e3f6d13f0d50d5ce (diff) | |
| download | pos-aedc910c844d79713f5e544a211ceabf4372c687.tar.gz | |
Comments cleanup, remove some more useless code
| -rw-r--r-- | main.go | 13 | ||||
| -rw-r--r-- | merkle.go | 8 |
2 files changed, 6 insertions, 15 deletions
@@ -7,15 +7,6 @@ import ( "runtime/pprof" ) -type Prover struct { - Merkle -} - -func NewProver(height int64, fname string, mtype string) *Prover { - m := NewMerkle(mtype, height, fname) - return &Prover{m} -} - func main() { height := flag.Int64("height", 0, "number of nodes is 2 ** height - 1") fname := flag.String("db", "test.db", "filename for the database") @@ -30,8 +21,8 @@ func main() { pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() - p := NewProver(*height, *fname, *mtype) - p.Build() + m := NewMerkle(*mtype, *height, *fname) + m.Build() /* fmt.Println(root) id := p.Size() / 2 @@ -30,9 +30,9 @@ func NewMerkle(mtype string, height int64, fname string) Merkle { // nodes are stored in BFS order, root node first type BFSMerkle struct { - height int64 + height int64 // root counts as height 1, children of root as height 2, etc. *os.File - size int64 + size int64 // maximum label of node = 2^height -2 } func NewBFSMerkle(height int64, fname string) *BFSMerkle { @@ -187,9 +187,9 @@ func (m *PostMerkle) Proof(id int64) [][]byte { if mask&id > 0 { // leaf is in the right subtree of current node m.ReadAt(proof[i], (cur-size)*hashSize) // reading the left child cur -= 1 // moving to the right subtree - } else { // left is in the left subtree of current node + } else { // leaf is in the left subtree of current node m.ReadAt(proof[i], (cur-1)*hashSize) // reading the right child - cur -= size // moving the left subtree + cur -= size // moving to the left subtree } size = mask mask >>= 1 |
