<!-- XE-13295 · [net/sync.go] M9: SyncTo() tidak rate-limit — sync berulang bisa menyebabkan network congestion · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13295>. The page is the record; this is the same page for reading.*

XE-13295 · Bounty

# \[net/sync.go\] M9: SyncTo() tidak rate-limit — sync berulang bisa menyebabkan network congestion

Closed · invalid
—
[xe#440](https://github.com/xeprotocol/xe/issues/440)
filed 2026-11-12 02:52 UTC
by wahyu20260100233-ops

Verdict
:   Invalid

Tier
:   —

Claimed
:   —

Area
:   P2P / sync

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-20 00:51 UTC

Told
:   2026-11-20 00:49 UTC

### Patches

None linked.

### History

- [557544](https://bounty.xe.network/log/557544) 2026-11-20 00:49 UTC reply.mirrored
- [557085](https://bounty.xe.network/log/557085) 2026-11-20 00:48 UTC reply.sent
- [554329](https://bounty.xe.network/log/554329) 2026-11-20 00:37 UTC github.state\_pushed
- [554318](https://bounty.xe.network/log/554318) 2026-11-20 00:37 UTC github.labels
- [553357](https://bounty.xe.network/log/553357) 2026-11-20 00:33 UTC proposal.adopted
- [553165](https://bounty.xe.network/log/553165) 2026-11-20 00:33 UTC proposal.adopted
- [553164](https://bounty.xe.network/log/553164) 2026-11-20 00:33 UTC ticket.status new → closed
- [552775](https://bounty.xe.network/log/552775) 2026-11-20 00:33 UTC proposal.adopted
- [552774](https://bounty.xe.network/log/552774) 2026-11-20 00:33 UTC ticket.facts area
- [552766](https://bounty.xe.network/log/552766) 2026-11-20 00:33 UTC proposal.adopted
- [552765](https://bounty.xe.network/log/552765) 2026-11-20 00:33 UTC ticket.facts
- [550831](https://bounty.xe.network/log/550831) 2026-11-20 00:30 UTC note.added

[Full history](https://bounty.xe.network/log?ref=XE-13295) · [JSON](https://bounty.xe.network/v1/tickets/XE-13295) · [markdown](https://bounty.xe.network/XE-13295.md)

### Report

## Ringkasan

`SyncTo` dipanggil dari `SyncAll` (periodik) dan `peerSyncWorker` (background). Tidak ada rate-limit antara sync attempt. Kalau sync sering gagal, bisa menyebabkan network congestion.

## Lokasi

- File: `net/sync.go`
- Lines: 124-143, 383-404

## Kode

```
func (t *tracker) SyncTo(ctx context.Context, h host.Host, pid peer.ID, opts ...SyncOption) error {
    ...
    if err := t.syncPeer(ctx, h, pid, opts...); err != nil {
        return err
    }
    return nil
}

func (t *tracker) peerSyncWorker(ctx context.Context, h host.Host, pid peer.ID) {
    ...
    for {
        select {
        case <-ctx.Done():
            return
        case <-t.syncCh[pid]:
            if err := t.SyncTo(ctx, h, pid); err != nil {
                logging.Warnf("sync: failed to sync with %s: %v", pid, err)
            }
        }
    }
}
```

## Impact

Sync berulang tanpa jeda bisa menyebabkan network congestion, waste bandwidth.

## Suggested Fix

```
func (t *tracker) peerSyncWorker(ctx context.Context, h host.Host, pid peer.ID) {
    ...
    for {
        select {
        case <-ctx.Done():
            return
        case <-t.syncCh[pid]:
            if err := t.SyncTo(ctx, h, pid); err != nil {
                logging.Warnf("sync: failed to sync with %s: %v", pid, err)
            }
            time.Sleep(t.syncInterval)  // tambah jeda
        }
    }
}
```

Atau gunakan rate limiter per peer:

```
type rateLimiter struct {
    mu    sync.Mutex
    last  map[peer.ID]time.Time
    limit time.Duration
}

func (rl *rateLimiter) allow(pid peer.ID) bool {
    rl.mu.Lock()
    defer rl.mu.Unlock()
    now := time.Now()
    if t, ok := rl.last[pid]; ok && now.Sub(t) < rl.limit {
        return false
    }
    rl.last[pid] = now
    return true
}
```

### Thread

**XE desk**team2026-11-20 00:49 UTCgithub

Thanks for the report. We read it against the code and could not confirm a bug in what it describes.

This report is closed as invalid. If we have missed something, file a new report that links
https://bounty.xe.network/XE-13295 and says what; it is read like any other.
