Add announcePeer feature.
TODO: fix sync write congestion control Request timeout
This commit is contained in:
@@ -63,10 +63,13 @@ func (dp *dialPool) stop() {
|
||||
|
||||
func (dp *dialPool) connectLoop(ctx context.Context) {
|
||||
dhtCtx, cancel := context.WithTimeout(ctx, dhtTimeout)
|
||||
// TODO: handle tokens
|
||||
addrs, _, err := dp.dht.GetPeers(dhtCtx, dp.infoHash)
|
||||
addrs, tokens, err := dp.dht.GetPeers(dhtCtx, dp.infoHash)
|
||||
cancel()
|
||||
|
||||
if len(tokens) > 0 {
|
||||
dp.dht.AnnouncePeer(ctx, dp.infoHash, tokens)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
select {
|
||||
case dp.results <- dialResult{done: true, err: err}:
|
||||
|
||||
@@ -26,7 +26,7 @@ const (
|
||||
|
||||
const (
|
||||
maxPeers = 8
|
||||
maxPending = 5
|
||||
maxPending = 50
|
||||
dialTimeout = 30 * time.Second
|
||||
retryInterval = 30 * time.Second
|
||||
dhtTimeout = 5 * time.Minute
|
||||
|
||||
Reference in New Issue
Block a user