Skip to content

Metadata builders for *.multicall RPC methods #17

@cjlucas

Description

@cjlucas

NOTE: This is a proposed feature, feel free to add your thoughts or opinions

Background Info

Previously, the only supported way to batch get data for all objects was to use a *.multicall backed method such as RTorrent.get_torrents() or Torrent.get_files(). The problem with this implementation is that the user has no say in which attributes are fetched. For clients with hundreds of torrents, this could result in slow response times.

Proposed Change

The solution to this would be to provider a builder interface to the user, which would allow the user to choose which attributes are to be fetched (including any identifying attributes, such as an info hash) thereby resulting in much faster response times.

Also, a RuntimeError would be raised If any metadata instance method is called that wasn't supplied during the building process.

Example

Assume RTorrent has an instance method get_torrent_metadata_builder() which returns a list of TorrentMetadata objects

metadata_list = RTorrent.get_torrent_metadata_builder()\
    .get_info_hash()\ # this would be fetched anyways, as it is an identifying attribute
    .is_accepting_seeders()\
    .get_down_rate()\
    .call()

for metadata in metadata_list:
    metadata.get_info_hash()
    metadata.is_accepting_seeders()
    metadata.get_down_rate()
    metadata.get_up_rate() # would raise a RuntimeError

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions