diff --git a/importer/splitting.go b/importer/splitting.go index 1832743d8..001408e82 100644 --- a/importer/splitting.go +++ b/importer/splitting.go @@ -34,12 +34,13 @@ func SplitterBySize(n int) BlockSplitter { } // TODO: this should take a reader, not a byte array. what if we're splitting a 3TB file? +//Rabin Fingerprinting for file chunking func Rabin(b []byte) [][]byte { var out [][]byte windowsize := uint64(48) - chunk_max := 1024 * 16 - min_blk_size := 2048 - blk_beg_i := 0 + chunkMax := 1024 * 16 + minBlkSize := 2048 + blkBegI := 0 prime := uint64(61) var poly uint64 @@ -63,21 +64,21 @@ func Rabin(b []byte) [][]byte { poly = (poly * prime) + cur curchecksum -= (uint64(b[i-1]) * prime) - if i-blk_beg_i >= chunk_max { + if i-blkgBegI >= chunkMax { // push block - out = append(out, b[blk_beg_i:i]) - blk_beg_i = i + out = append(out, b[blkgBegI:i]) + blkgBegI = i } // first 13 bits of polynomial are 0 - if poly%8192 == 0 && i-blk_beg_i >= min_blk_size { + if poly%8192 == 0 && i-blkgBegI >= minBlkSize { // push block - out = append(out, b[blk_beg_i:i]) - blk_beg_i = i + out = append(out, b[blkgBegI:i]) + blkgBegI = i } } - if i > blk_beg_i { - out = append(out, b[blk_beg_i:]) + if i > blkgBegI { + out = append(out, b[blkgBegI:]) } return out } diff --git a/merkledag/dagreader.go b/merkledag/dagreader.go index 0aa0d2606..967ec63a4 100644 --- a/merkledag/dagreader.go +++ b/merkledag/dagreader.go @@ -9,7 +9,7 @@ import ( u "github.com/jbenet/go-ipfs/util" ) -var ErrIsDir = errors.New("this dag node is a directory.") +var ErrIsDir = errors.New("this dag node is a directory") // DagReader provides a way to easily read the data contained in a dag. type DagReader struct { diff --git a/peer/peer.go b/peer/peer.go index 1d270450d..870170c4b 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -16,7 +16,7 @@ import ( // ID is a byte slice representing the identity of a peer. type ID mh.Multihash -// Utililty function for comparing two peer ID's +// Equal is utililty function for comparing two peer ID's func (id ID) Equal(other ID) bool { return bytes.Equal(id, other) }