diff options
author | Alan Fitton <ajf@eth0.org.uk> | 2011-04-12 10:54:29 +0000 |
---|---|---|
committer | Alan Fitton <ajf@eth0.org.uk> | 2011-04-12 10:54:29 +0000 |
commit | 42eddac0e9f0216175fef223fd9b1023ed502a6e (patch) | |
tree | 7fd853c8fdabc678bc1df0f4eb5160420347ac8e /src/requests.c | |
parent | f4a194f08d0c48641f5394cd07be61931a432241 (diff) |
some quite significant changes to only receive/update recently-active torrents, if enabled. also use a hash table and tree row references for lookup. hopefully performance will be much better for people with large number of torrents.
Diffstat (limited to 'src/requests.c')
-rw-r--r-- | src/requests.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/requests.c b/src/requests.c index d3edc3a..4c841e4 100644 --- a/src/requests.c +++ b/src/requests.c @@ -110,10 +110,18 @@ JsonNode *torrent_remove(JsonArray * array, gboolean removeData) return root; } -JsonNode *torrent_get(void) +JsonNode *torrent_get(gboolean recent) { JsonNode *root = base_request(METHOD_TORRENT_GET); + JsonObject *args = node_get_arguments(root); JsonArray *fields = json_array_new(); + + if (recent) { + JsonArray *ids = json_array_new(); + json_array_add_string_element(ids, FIELD_RECENTLY_ACTIVE); + json_object_set_array_member(args, PARAM_IDS, ids); + } + json_array_add_string_element(fields, FIELD_ETA); json_array_add_string_element(fields, FIELD_PEERS); json_array_add_string_element(fields, FIELD_FILES); @@ -151,7 +159,7 @@ JsonNode *torrent_get(void) json_array_add_string_element(fields, FIELD_ERRORSTR); json_array_add_string_element(fields, FIELD_WANTED); json_array_add_string_element(fields, FIELD_PRIORITIES); - json_object_set_array_member(node_get_arguments(root), + json_object_set_array_member(args, PARAM_FIELDS, fields); return root; } |