Skip to content

feat(shared): expose live upload activity for shared files over EC (#466) - #473

Merged
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:feat/shared-upload-activity-466
Jul 13, 2026
Merged

feat(shared): expose live upload activity for shared files over EC (#466)#473
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:feat/shared-upload-activity-466

Conversation

@got3nks

@got3nks got3nks commented Jul 13, 2026

Copy link
Copy Markdown

Implements @ngosang's #466 — Tier 1 and Tier 2 in one PR (Tier 2 is downgrade-safe, see below). Touches the core, the EC protocol, and amuleapi.

What clients get

GET /api/v0/shared (list) and /shared/{hash} (detail) gain four fields, plus the same on the SSE shared_added/shared_updated payload:

  • upload_speed_bps — the file's current combined upload rate (Σ over the peers it's uploading to).
  • uploading — peers it's actively uploading to right now. Together with queued_count this gives the uploading / queued split (Expose live upload activity for shared files over EC (speed, active peers, last-active time) #466 pt 3), the upload-side analogue of the Downloads transferring / total sources.
  • last_upload — unix ts of the last time data was sent for the file.
  • shared_since — when the file was completed / first shared.

upload_speed_bps + uploading are live (refresh every tick); the two timestamps persist in known.met and read 0 when unknown.

Core

All Tier-1 data already existed on CKnownFile::m_ClientUploadList; added GetUploadDatarate() / GetTransferringClientCount() (summed live) plus two persisted timestamps: m_lastUploadDatetime stamped in CFileStatistic::AddTransferred (the single upload-bytes chokepoint), and m_dateShared stamped once at completion / first-hash. Uploading never rewrites the file, so — unlike a download's mtime-backed "last reception" — the upload timestamp needs its own tag.

EC + dirty-marking

Four new EC_TAG_KNOWNFILE_* tags (0x04170x041A); the live ones emit before the EC_DETAIL_UPDATE early-return like EC_TAG_PARTFILE_SPEED. SetUploadState marks the file EC-dirty on US_UPLOADING transitions so a file that stops uploading but stays queued decays to 0 — completed/shared files have no per-tick Process() sweep the way downloads do.

known.met compatibility

The two timestamps are additive FT_* tags. An older aMule reads them fine (unrecognized tags fall through to default: and are preserved in m_taglist, then rewritten on save), so they survive a downgrade round-trip and never corrupt anything. New state is tags-only; the fixed header is unchanged.

Verification

Build clean (amuled + amuleapi + amulegui); webapi ctests 4/4 (RefresherTest decodes the new tags); curl 04 69/69 live against a connected daemon; clang-format (cf18) + clang-tidy Tier-2 clean. amulegui built from this branch connects to a 3.0.1 remote amuled without issue (new fields simply absent). Rebased on current master.

Desktop GUI columns (amule/amulegui) that consume these are a follow-up, as noted in the issue.

…mule-project#466)

The Shared Files view could only show static counters (transferred,
requests, accepts, complete sources) — unlike Downloads, there was no way
to tell an actively-seeded file from an idle one. Surface per-file upload
activity over EC so clients (the REST API now, the desktop GUI later) can
add the corresponding columns.

Core (CKnownFile):
  * GetUploadDatarate() / GetTransferringClientCount() — live, summed from
    m_ClientUploadList: current upload speed and peers uploading now.
  * m_lastUploadDatetime — stamped in CFileStatistic::AddTransferred (the
    single point where sent bytes are attributed to a file), the upload-side
    analogue of the download's m_lastDateChanged.
  * m_dateShared — stamped once when a file completes (CompleteFileEnded) or
    is first hashed into the share (CKnownFileList::Append, afterHashing).
  Both persist in known.met as new FT_ tags (FT_LASTUPLOADED / FT_SHAREDSINCE);
  absent on a pre-feature known.met => 0 (unknown). Uploading never rewrites
  the shared file, so the timestamp can't ride the .met date the way downloads
  do — it needs its own tag. The unknown-tag preserve-and-rewrite path keeps
  this forward/backward compatible.

EC / dirty-marking:
  * New tags EC_TAG_KNOWNFILE_UPLOAD_SPEED / _UPLOADING_COUNT / _LAST_UPLOAD
    (live, emitted before the UPDATE early-return) and _SHARED_SINCE (full
    detail).
  * SetUploadState marks the file EC-dirty on US_UPLOADING transitions so a
    file that stops uploading but stays queued drops its speed to 0 —
    completed/shared files have no per-tick Process() sweep like downloads.

REST + SSE (amuleapi):
  * /shared list + detail gain upload_speed_bps, uploading, last_upload,
    shared_since; the SSE shared_added/shared_updated payload and EqualShared
    comparator carry them so live changes emit events.

Tests: RefresherTest decodes the new tags; curl 04 asserts the fields.
Docs: docs/api/REFERENCE.md.
@got3nks
got3nks force-pushed the feat/shared-upload-activity-466 branch from d38f937 to 614634b Compare July 13, 2026 14:50
@got3nks
got3nks merged commit 5722207 into amule-org:master Jul 13, 2026
12 checks passed
@got3nks
got3nks deleted the feat/shared-upload-activity-466 branch July 13, 2026 14:54
got3nks pushed a commit that referenced this pull request Jul 31, 2026
This is a deliberate UI change, not a behaviour-preserving refactor --
worth being explicit about per review discussion on #675. None of the
74 sites touched here have ever rendered their border: the legacy
`Add(window, proportion, flag, border)` form only applies `border`
when `flag` carries a direction bit (wxALL/wxLEFT/wxRIGHT/wxTOP/
wxBOTTOM), and all 74 omitted it. Converting to wxSizerFlags() and
supplying a real direction bit means these borders render for the
first time, which will reflow the affected dialogs to some degree.

Per #663 (the case that originally surfaced this pattern): the
recorded border values were never validated by anything, since they
never rendered. Each site was judged against its structural siblings
rather than ported verbatim -- where siblings already carried a
working border, matched to it; where a site was the outlier in an
otherwise-consistent row/grid, adjusted to match rather than
introducing a new, never-tested value. A few sites lost their border
entirely where every sibling in the same row already had none (the
stray value read as leftover noise, not an intended margin).

Three additional non-legacy-syntax inconsistencies folded into the
same pass (found while scoping #675, confirmed still present):
- PreferencesRemoteControlsTab: "Low rights password" carried
  Border(wxLEFT|wxRIGHT, 20) while every other same-column label in
  the grid ("Web template", "Full rights password") uses
  Border(wxRIGHT, 5) -- the 20px left indent looked like it was
  copy-pasted from the unrelated UPnP-port row's indent, not a
  deliberate choice for this row.
- PreferencesOnlineSigTab: the "Save online signature file in" path
  field had no Expand()/proportion despite sitting in a column its
  parent FlexGridSizer marks growable -- it couldn't actually grow to
  fill the space reserved for it.
- PreferencesGeneralTab: the "Browser Selection" row (text field +
  Browse button) still used the legacy 3-arg Add() form while the
  structurally identical "Video Player" row already used
  wxSizerFlags() -- modernized for consistency, no behaviour change
  (both used border 0).

Scope: src/muuli_wdr.cpp only, matching where #663/#473 originally
established (and didn't fully carry through) the wxSizerFlags()
convention.

Testing: full build verified (macOS). Visually walked every dialog
these 20 functions produce that's reachable without live server/
download/client data in a fresh test config: main status bar,
search, transfer panes, shared-files header, servers/Kad tabs,
Friends/Messages panels, and all 15 Preferences tabs -- no clipped or
overlapping controls, and the two directly-testable fixes (the
OnlineSig path field now expanding, the RemoteControls password grid
column now aligned) confirmed visually.

NOT independently verified: fileDetails, clientDetails, commentLstDlg,
and CategoriesEditWindow all require live downloads/shared files/
clients/categories to reach via the UI, which a from-scratch test
config doesn't have -- these got the same siblings-based border
review as everything else, but I have not seen them rendered.
Sizer-border rendering is exactly where wxGTK/wxMSW/wxOSX diverge, so
this needs eyes on Linux and Windows too, per the #675 review
discussion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant