Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
02deb3cc
提交
02deb3cc
authored
9月 11, 2014
作者:
Siraj Ravel
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
last golint
上级
61586864
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
14 行增加
和
13 行删除
+14
-13
splitting.go
importer/splitting.go
+12
-11
dagreader.go
merkledag/dagreader.go
+1
-1
peer.go
peer/peer.go
+1
-1
没有找到文件。
importer/splitting.go
浏览文件 @
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
>=
chunkM
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
>=
minBlkS
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
浏览文件 @
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
浏览文件 @
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
)
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论