Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
bd3ee739
提交
bd3ee739
authored
12月 17, 2014
作者:
Brian Tiger Chow
提交者:
Juan Batiz-Benet
12月 17, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
doc: some comments about the future of the decision engine
License: MIT Signed-off-by:
Brian Tiger Chow
<
brian@perfmode.com
>
上级
ce2d0a22
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
40 行增加
和
4 行删除
+40
-4
engine.go
exchange/bitswap/decision/engine.go
+40
-4
没有找到文件。
exchange/bitswap/decision/engine.go
浏览文件 @
bd3ee739
...
@@ -11,6 +11,36 @@ import (
...
@@ -11,6 +11,36 @@ import (
u
"github.com/jbenet/go-ipfs/util"
u
"github.com/jbenet/go-ipfs/util"
)
)
// TODO consider taking responsibility for other types of requests. For
// example, there could be a |cancelQueue| for all of the cancellation
// messages that need to go out. There could also be a |wantlistQueue| for
// the local peer's wantlists. Alternatively, these could all be bundled
// into a single, intelligent global queue that efficiently
// batches/combines and takes all of these into consideration.
//
// Right now, messages go onto the network for four reasons:
// 1. an initial `sendwantlist` message to a provider of the first key in a request
// 2. a periodic full sweep of `sendwantlist` messages to all providers
// 3. upon receipt of blocks, a `cancel` message to all peers
// 4. draining the priority queue of `blockrequests` from peers
//
// Presently, only `blockrequests` are handled by the decision engine.
// However, there is an opportunity to give it more responsibility! If the
// decision engine is given responsibility for all of the others, it can
// intelligently decide how to combine requests efficiently.
//
// Some examples of what would be possible:
//
// * when sending out the wantlists, include `cancel` requests
// * when handling `blockrequests`, include `sendwantlist` and `cancel` as appropriate
// * when handling `cancel`, if we recently received a wanted block from a
// peer, include a partial wantlist that contains a few other high priority
// blocks
//
// In a sense, if we treat the decision engine as a black box, it could do
// whatever it sees fit to produce desired outcomes (get wanted keys
// quickly, maintain good relationships with peers, etc).
var
log
=
u
.
Logger
(
"engine"
)
var
log
=
u
.
Logger
(
"engine"
)
const
(
const
(
...
@@ -26,18 +56,24 @@ type Envelope struct {
...
@@ -26,18 +56,24 @@ type Envelope struct {
}
}
type
Engine
struct
{
type
Engine
struct
{
//
FIXME peerRequestQueue isn't threadsafe nor is it protected by a mutex
.
//
peerRequestQueue is a priority queue of requests received from peers
.
//
consider a way to avoid sharing the peerRequestQueue between the worker
//
Requests are popped from the queue, packaged up, and placed in the
//
and the receiver
//
outbox.
peerRequestQueue
*
taskQueue
peerRequestQueue
*
taskQueue
// FIXME it's a bit odd for the client and the worker to both share memory
// (both modify the peerRequestQueue) and also to communicate over the
// workSignal channel. consider sending requests over the channel and
// allowing the worker to have exclusive access to the peerRequestQueue. In
// that case, no lock would be required.
workSignal
chan
struct
{}
workSignal
chan
struct
{}
// outbox contains outgoing messages to peers
outbox
chan
Envelope
outbox
chan
Envelope
bs
bstore
.
Blockstore
bs
bstore
.
Blockstore
lock
sync
.
RWMutex
lock
sync
.
RWMutex
// protects the fields immediatly below
// ledgerMap lists Ledgers by their Partner key.
// ledgerMap lists Ledgers by their Partner key.
ledgerMap
map
[
u
.
Key
]
*
ledger
ledgerMap
map
[
u
.
Key
]
*
ledger
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论