Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
02deb3cc
Commit
02deb3cc
authored
Sep 11, 2014
by
Siraj Ravel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
last golint
parent
61586864
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
13 deletions
+14
-13
importer/splitting.go
importer/splitting.go
+12
-11
merkledag/dagreader.go
merkledag/dagreader.go
+1
-1
peer/peer.go
peer/peer.go
+1
-1
No files found.
importer/splitting.go
View file @
02deb3cc
...
@@ -34,12 +34,13 @@ func SplitterBySize(n int) BlockSplitter {
...
@@ -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?
// 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
{
func
Rabin
(
b
[]
byte
)
[][]
byte
{
var
out
[][]
byte
var
out
[][]
byte
windowsize
:=
uint64
(
48
)
windowsize
:=
uint64
(
48
)
chunk
_m
ax
:=
1024
*
16
chunk
M
ax
:=
1024
*
16
min
_blk_s
ize
:=
2048
min
BlkS
ize
:=
2048
blk
_beg_i
:=
0
blk
BegI
:=
0
prime
:=
uint64
(
61
)
prime
:=
uint64
(
61
)
var
poly
uint64
var
poly
uint64
...
@@ -63,21 +64,21 @@ func Rabin(b []byte) [][]byte {
...
@@ -63,21 +64,21 @@ func Rabin(b []byte) [][]byte {
poly
=
(
poly
*
prime
)
+
cur
poly
=
(
poly
*
prime
)
+
cur
curchecksum
-=
(
uint64
(
b
[
i
-
1
])
*
prime
)
curchecksum
-=
(
uint64
(
b
[
i
-
1
])
*
prime
)
if
i
-
blk
_beg_i
>=
chunk
_m
ax
{
if
i
-
blk
gBegI
>=
chunk
M
ax
{
// push block
// push block
out
=
append
(
out
,
b
[
blk
_beg_i
:
i
])
out
=
append
(
out
,
b
[
blk
gBegI
:
i
])
blk
_beg_i
=
i
blk
gBegI
=
i
}
}
// first 13 bits of polynomial are 0
// first 13 bits of polynomial are 0
if
poly
%
8192
==
0
&&
i
-
blk
_beg_i
>=
min
_blk_s
ize
{
if
poly
%
8192
==
0
&&
i
-
blk
gBegI
>=
min
BlkS
ize
{
// push block
// push block
out
=
append
(
out
,
b
[
blk
_beg_i
:
i
])
out
=
append
(
out
,
b
[
blk
gBegI
:
i
])
blk
_beg_i
=
i
blk
gBegI
=
i
}
}
}
}
if
i
>
blk
_beg_i
{
if
i
>
blk
gBegI
{
out
=
append
(
out
,
b
[
blk
_beg_i
:
])
out
=
append
(
out
,
b
[
blk
gBegI
:
])
}
}
return
out
return
out
}
}
merkledag/dagreader.go
View file @
02deb3cc
...
@@ -9,7 +9,7 @@ import (
...
@@ -9,7 +9,7 @@ import (
u
"github.com/jbenet/go-ipfs/util"
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.
// DagReader provides a way to easily read the data contained in a dag.
type
DagReader
struct
{
type
DagReader
struct
{
...
...
peer/peer.go
View file @
02deb3cc
...
@@ -16,7 +16,7 @@ import (
...
@@ -16,7 +16,7 @@ import (
// ID is a byte slice representing the identity of a peer.
// ID is a byte slice representing the identity of a peer.
type
ID
mh
.
Multihash
type
ID
mh
.
Multihash
//
U
tililty function for comparing two peer ID's
//
Equal is u
tililty function for comparing two peer ID's
func
(
id
ID
)
Equal
(
other
ID
)
bool
{
func
(
id
ID
)
Equal
(
other
ID
)
bool
{
return
bytes
.
Equal
(
id
,
other
)
return
bytes
.
Equal
(
id
,
other
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment