From 7713bb6f8c06a0feb326ea629ad80ab44438326b Mon Sep 17 00:00:00 2001 From: Thibaut Horel Date: Wed, 4 May 2016 15:58:24 -0400 Subject: Merkle structs now inherit from os.File, cleaner interface --- merkle.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'merkle.go') diff --git a/merkle.go b/merkle.go index 06e4855..f0a3f2b 100644 --- a/merkle.go +++ b/merkle.go @@ -55,8 +55,8 @@ func Init(m Merkle) { // nodes are stored in BFS order, root node first type BFSMerkle struct { height int64 - file *os.File - size int64 + *os.File + size int64 } func NewBFSMerkle(height int64, fname string) *BFSMerkle { @@ -65,7 +65,7 @@ func NewBFSMerkle(height int64, fname string) *BFSMerkle { panic(err) } size := int64(1)< 0; i-- { proof[i] = make([]byte, hashSize) if mask&id > 0 { // leaf is in the right subtree of current node - m.file.ReadAt(proof[i], (cur-size)*hashSize) // reading the left child - cur -= 1 // moving to the right subtree + 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 - m.file.ReadAt(proof[i], (cur-1)*hashSize) // reading the right child - cur -= size // moving the left subtree + m.ReadAt(proof[i], (cur-1)*hashSize) // reading the right child + cur -= size // moving the left subtree } size = mask mask >>= 1 } proof[0] = make([]byte, hashSize) - m.file.ReadAt(proof[0], cur*hashSize) + m.ReadAt(proof[0], cur*hashSize) return proof } -- cgit v1.2.3-70-g09d2