Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
19eb3513
提交
19eb3513
authored
2月 04, 2015
作者:
Brian Tiger Chow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(routing) rename grandcentral to supernode
thanks @mappum remove .go-ipfs
上级
09186366
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
37 行增加
和
37 行删除
+37
-37
main.go
cmd/routingd/main.go
+2
-2
core.go
core/corerouting/core.go
+14
-14
client.go
routing/supernode/client.go
+4
-4
loopback.go
routing/supernode/proxy/loopback.go
+0
-0
standard.go
routing/supernode/proxy/standard.go
+5
-5
server.go
routing/supernode/server.go
+3
-3
grandcentral_test.go
test/integration/grandcentral_test.go
+9
-9
没有找到文件。
cmd/routingd/main.go
浏览文件 @
19eb3513
...
...
@@ -12,7 +12,7 @@ import (
syncds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
core
"github.com/jbenet/go-ipfs/core"
corehttp
"github.com/jbenet/go-ipfs/core/corehttp"
"github.com/jbenet/go-ipfs/core/corerouting"
corerouting
"github.com/jbenet/go-ipfs/core/corerouting"
config
"github.com/jbenet/go-ipfs/repo/config"
fsrepo
"github.com/jbenet/go-ipfs/repo/fsrepo"
s3datastore
"github.com/jbenet/go-ipfs/thirdparty/s3-datastore"
...
...
@@ -68,7 +68,7 @@ func run() error {
node
,
err
:=
core
.
NewIPFSNode
(
ctx
,
core
.
OnlineWithOptions
(
repo
,
corerouting
.
GrandCentral
Server
(
enhanced
),
corerouting
.
Supernode
Server
(
enhanced
),
core
.
DefaultHostOption
),
)
if
err
!=
nil
{
...
...
core/corerouting/core.go
浏览文件 @
19eb3513
...
...
@@ -8,8 +8,8 @@ import (
core
"github.com/jbenet/go-ipfs/core"
"github.com/jbenet/go-ipfs/p2p/peer"
routing
"github.com/jbenet/go-ipfs/routing"
grandcentral
"github.com/jbenet/go-ipfs/routing/grandcentral
"
gcproxy
"github.com/jbenet/go-ipfs/routing/
grandcentral
/proxy"
supernode
"github.com/jbenet/go-ipfs/routing/supernode
"
gcproxy
"github.com/jbenet/go-ipfs/routing/
supernode
/proxy"
)
// NB: DHT option is included in the core to avoid 1) because it's a sane
...
...
@@ -17,16 +17,16 @@ import (
// the core if it's going to be the default)
var
(
errHostMissing
=
errors
.
New
(
"
grandcentral
client requires a Host component"
)
errIdentityMissing
=
errors
.
New
(
"
grandcentral
server requires a peer ID identity"
)
errPeerstoreMissing
=
errors
.
New
(
"
grandcentral
server requires a peerstore"
)
errServersMissing
=
errors
.
New
(
"
grandcentral
client requires at least 1 server peer"
)
errHostMissing
=
errors
.
New
(
"
supernode routing
client requires a Host component"
)
errIdentityMissing
=
errors
.
New
(
"
supernode routing
server requires a peer ID identity"
)
errPeerstoreMissing
=
errors
.
New
(
"
supernode routing
server requires a peerstore"
)
errServersMissing
=
errors
.
New
(
"
supernode routing
client requires at least 1 server peer"
)
)
//
GrandCentral
Server returns a configuration for a routing server that stores
//
Supernode
Server returns a configuration for a routing server that stores
// routing records to the provided datastore. Only routing records are store in
// the datastore.
func
GrandCentral
Server
(
recordSource
datastore
.
ThreadSafeDatastore
)
core
.
RoutingOption
{
func
Supernode
Server
(
recordSource
datastore
.
ThreadSafeDatastore
)
core
.
RoutingOption
{
return
func
(
ctx
context
.
Context
,
node
*
core
.
IpfsNode
)
(
routing
.
IpfsRouting
,
error
)
{
if
node
.
Peerstore
==
nil
{
return
nil
,
errPeerstoreMissing
...
...
@@ -37,7 +37,7 @@ func GrandCentralServer(recordSource datastore.ThreadSafeDatastore) core.Routing
if
node
.
Identity
==
""
{
return
nil
,
errIdentityMissing
}
server
,
err
:=
grandcentral
.
NewServer
(
recordSource
,
node
.
Peerstore
,
node
.
Identity
)
server
,
err
:=
supernode
.
NewServer
(
recordSource
,
node
.
Peerstore
,
node
.
Identity
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -45,13 +45,13 @@ func GrandCentralServer(recordSource datastore.ThreadSafeDatastore) core.Routing
Handler
:
server
,
Local
:
node
.
Identity
,
}
node
.
PeerHost
.
SetStreamHandler
(
gcproxy
.
Protocol
GC
R
,
proxy
.
HandleStream
)
return
grandcentral
.
NewClient
(
proxy
,
node
.
PeerHost
,
node
.
Peerstore
,
node
.
Identity
)
node
.
PeerHost
.
SetStreamHandler
(
gcproxy
.
Protocol
SN
R
,
proxy
.
HandleStream
)
return
supernode
.
NewClient
(
proxy
,
node
.
PeerHost
,
node
.
Peerstore
,
node
.
Identity
)
}
}
// TODO doc
func
GrandCentral
Client
(
remotes
...
peer
.
PeerInfo
)
core
.
RoutingOption
{
func
Supernode
Client
(
remotes
...
peer
.
PeerInfo
)
core
.
RoutingOption
{
return
func
(
ctx
context
.
Context
,
node
*
core
.
IpfsNode
)
(
routing
.
IpfsRouting
,
error
)
{
if
len
(
remotes
)
<
1
{
return
nil
,
errServersMissing
...
...
@@ -78,7 +78,7 @@ func GrandCentralClient(remotes ...peer.PeerInfo) core.RoutingOption {
ids
=
append
(
ids
,
info
.
ID
)
}
proxy
:=
gcproxy
.
Standard
(
node
.
PeerHost
,
ids
)
node
.
PeerHost
.
SetStreamHandler
(
gcproxy
.
Protocol
GC
R
,
proxy
.
HandleStream
)
return
grandcentral
.
NewClient
(
proxy
,
node
.
PeerHost
,
node
.
Peerstore
,
node
.
Identity
)
node
.
PeerHost
.
SetStreamHandler
(
gcproxy
.
Protocol
SN
R
,
proxy
.
HandleStream
)
return
supernode
.
NewClient
(
proxy
,
node
.
PeerHost
,
node
.
Peerstore
,
node
.
Identity
)
}
}
routing/
grandcentral
/client.go
→
routing/
supernode
/client.go
浏览文件 @
19eb3513
package
grandcentral
package
supernode
import
(
"bytes"
...
...
@@ -10,13 +10,13 @@ import (
peer
"github.com/jbenet/go-ipfs/p2p/peer"
routing
"github.com/jbenet/go-ipfs/routing"
pb
"github.com/jbenet/go-ipfs/routing/dht/pb"
proxy
"github.com/jbenet/go-ipfs/routing/
grandcentral
/proxy"
proxy
"github.com/jbenet/go-ipfs/routing/
supernode
/proxy"
eventlog
"github.com/jbenet/go-ipfs/thirdparty/eventlog"
u
"github.com/jbenet/go-ipfs/util"
errors
"github.com/jbenet/go-ipfs/util/debugerror"
)
var
log
=
eventlog
.
Logger
(
"
grandcentral
"
)
var
log
=
eventlog
.
Logger
(
"
supernode
"
)
type
Client
struct
{
peerhost
host
.
Host
...
...
@@ -128,7 +128,7 @@ func makeRecord(ps peer.Peerstore, p peer.ID, k u.Key, v []byte) (*pb.Record, er
func
(
c
*
Client
)
Ping
(
ctx
context
.
Context
,
id
peer
.
ID
)
(
time
.
Duration
,
error
)
{
defer
log
.
EventBegin
(
ctx
,
"ping"
,
id
)
.
Done
()
return
time
.
Nanosecond
,
errors
.
New
(
"
grandcentral
routing does not support the ping method"
)
return
time
.
Nanosecond
,
errors
.
New
(
"
supernode
routing does not support the ping method"
)
}
var
_
routing
.
IpfsRouting
=
&
Client
{}
routing/
grandcentral
/proxy/loopback.go
→
routing/
supernode
/proxy/loopback.go
浏览文件 @
19eb3513
File moved
routing/
grandcentral
/proxy/standard.go
→
routing/
supernode
/proxy/standard.go
浏览文件 @
19eb3513
...
...
@@ -13,9 +13,9 @@ import (
errors
"github.com/jbenet/go-ipfs/util/debugerror"
)
const
Protocol
GCR
=
"/ipfs/grandcentral
"
const
Protocol
SNR
=
"/ipfs/supernoderouting
"
var
log
=
eventlog
.
Logger
(
"
grandcentral
/proxy"
)
var
log
=
eventlog
.
Logger
(
"
supernode
/proxy"
)
type
Proxy
interface
{
HandleStream
(
inet
.
Stream
)
...
...
@@ -34,7 +34,7 @@ func Standard(h host.Host, remotes []peer.ID) Proxy {
func
(
p
*
standard
)
HandleStream
(
s
inet
.
Stream
)
{
// TODO(brian): Should clients be able to satisfy requests?
log
.
Error
(
"
grandcentral
client received (dropped) a routing message from"
,
s
.
Conn
()
.
RemotePeer
())
log
.
Error
(
"
supernode
client received (dropped) a routing message from"
,
s
.
Conn
()
.
RemotePeer
())
s
.
Close
()
}
...
...
@@ -64,7 +64,7 @@ func (px *standard) sendMessage(ctx context.Context, m *dhtpb.Message, remote pe
if
err
=
px
.
Host
.
Connect
(
ctx
,
peer
.
PeerInfo
{
ID
:
remote
});
err
!=
nil
{
return
err
}
s
,
err
:=
px
.
Host
.
NewStream
(
Protocol
GC
R
,
remote
)
s
,
err
:=
px
.
Host
.
NewStream
(
Protocol
SN
R
,
remote
)
if
err
!=
nil
{
return
err
}
...
...
@@ -100,7 +100,7 @@ func (px *standard) sendRequest(ctx context.Context, m *dhtpb.Message, remote pe
e
.
SetError
(
err
)
return
nil
,
err
}
s
,
err
:=
px
.
Host
.
NewStream
(
Protocol
GC
R
,
remote
)
s
,
err
:=
px
.
Host
.
NewStream
(
Protocol
SN
R
,
remote
)
if
err
!=
nil
{
e
.
SetError
(
err
)
return
nil
,
err
...
...
routing/
grandcentral
/server.go
→
routing/
supernode
/server.go
浏览文件 @
19eb3513
package
grandcentral
package
supernode
import
(
"fmt"
...
...
@@ -8,7 +8,7 @@ import (
datastore
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
peer
"github.com/jbenet/go-ipfs/p2p/peer"
dhtpb
"github.com/jbenet/go-ipfs/routing/dht/pb"
proxy
"github.com/jbenet/go-ipfs/routing/
grandcentral
/proxy"
proxy
"github.com/jbenet/go-ipfs/routing/
supernode
/proxy"
util
"github.com/jbenet/go-ipfs/util"
errors
"github.com/jbenet/go-ipfs/util/debugerror"
)
...
...
@@ -21,7 +21,7 @@ type Server struct {
*
proxy
.
Loopback
// so server can be injected into client
}
// NewServer creates a new
GrandCentral
routing Server
// NewServer creates a new
Supernode
routing Server
func
NewServer
(
ds
datastore
.
ThreadSafeDatastore
,
ps
peer
.
Peerstore
,
local
peer
.
ID
)
(
*
Server
,
error
)
{
s
:=
&
Server
{
local
,
ds
,
ps
,
nil
}
s
.
Loopback
=
&
proxy
.
Loopback
{
...
...
test/integration/grandcentral_test.go
浏览文件 @
19eb3513
...
...
@@ -21,9 +21,9 @@ import (
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
func
Test
Grandcentral
BootstrappedAddCat
(
t
*
testing
.
T
)
{
// create 8
grandcentral
bootstrap nodes
// create 2
grandcentral
clients both bootstrapped to the bootstrap nodes
func
Test
Supernode
BootstrappedAddCat
(
t
*
testing
.
T
)
{
// create 8
supernode-routing
bootstrap nodes
// create 2
supernode-routing
clients both bootstrapped to the bootstrap nodes
// let the bootstrap nodes share a single datastore
// add a large file on one node then cat the file from the other
conf
:=
testutil
.
LatencyConfig
{
...
...
@@ -31,16 +31,16 @@ func TestGrandcentralBootstrappedAddCat(t *testing.T) {
RoutingLatency
:
0
,
BlockstoreLatency
:
0
,
}
if
err
:=
Run
Grandcentral
BootstrappedAddCat
(
RandomBytes
(
100
*
unit
.
MB
),
conf
);
err
!=
nil
{
if
err
:=
Run
Supernode
BootstrappedAddCat
(
RandomBytes
(
100
*
unit
.
MB
),
conf
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
func
Run
Grandcentral
BootstrappedAddCat
(
data
[]
byte
,
conf
testutil
.
LatencyConfig
)
error
{
func
Run
Supernode
BootstrappedAddCat
(
data
[]
byte
,
conf
testutil
.
LatencyConfig
)
error
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
servers
,
clients
,
err
:=
Initialize
GrandCentral
Network
(
ctx
,
8
,
2
,
conf
)
servers
,
clients
,
err
:=
Initialize
Supernode
Network
(
ctx
,
8
,
2
,
conf
)
if
err
!=
nil
{
return
err
}
...
...
@@ -73,7 +73,7 @@ func RunGrandcentralBootstrappedAddCat(data []byte, conf testutil.LatencyConfig)
return
nil
}
func
Initialize
GrandCentral
Network
(
func
Initialize
Supernode
Network
(
ctx
context
.
Context
,
numServers
,
numClients
int
,
conf
testutil
.
LatencyConfig
)
([]
*
core
.
IpfsNode
,
[]
*
core
.
IpfsNode
,
error
)
{
...
...
@@ -100,7 +100,7 @@ func InitializeGrandCentralNetwork(
for
i
:=
range
iter
.
N
(
numServers
)
{
p
:=
serverPeers
[
i
]
bootstrap
,
err
:=
core
.
NewIPFSNode
(
ctx
,
MocknetTestRepo
(
p
,
mn
.
Host
(
p
),
conf
,
corerouting
.
GrandCentral
Server
(
routingDatastore
)))
corerouting
.
Supernode
Server
(
routingDatastore
)))
if
err
!=
nil
{
return
nil
,
nil
,
err
}
...
...
@@ -117,7 +117,7 @@ func InitializeGrandCentralNetwork(
for
i
:=
range
iter
.
N
(
numClients
)
{
p
:=
clientPeers
[
i
]
n
,
err
:=
core
.
NewIPFSNode
(
ctx
,
MocknetTestRepo
(
p
,
mn
.
Host
(
p
),
conf
,
corerouting
.
GrandCentral
Client
(
bootstrapInfos
...
)))
corerouting
.
Supernode
Client
(
bootstrapInfos
...
)))
if
err
!=
nil
{
return
nil
,
nil
,
err
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论