bittorrent / go-btfs

BTFS - The First Scalable Decentralized Storage System - A Foundational Platform for Decentralized Applications
https://www.btfs.io
Other
236 stars 80 forks source link

[Feature] Add option to list renter contracts for a single file hash or upload ID #461

Closed mantlik closed 1 week ago

mantlik commented 1 week ago

Is your feature request related to a problem? Please describe. Contracts CLI is currently allowing to list all contracts of given status [active|finished|invalid|all] and eventually limit number of records in the output. No other filters are available. This is not scaling well and becomes a problem when more than couple of files are uploaded from the node. Currently the only solution to get contracts for a file hash or upload ID is to put very high number in the --size parameter and then filter out the result by file hash or upload ID. Once number of uploaded files reaches a thousand or more, this entire process becomes unsustainable.

Describe the solution you'd like My suggestion is to add extra parameter to the CLI to allow extract only contracts for the given file ID or upload ID. It should not be complicated to extract contracts from the database based on either file hash or upload ID, depending on how the storage key is constructed - I did not make a detailed research on it. And, in fact it is not important, either will work. Processing of data just for a single file or upload will be very light and will scale without issues with growing total number of contracts for the node.

Describe alternatives you've considered N/A

Additional context The new proposed option makes sense in the renter context only, if I do not miss anything.

yu-btc commented 1 week ago

Thanks for your feedback, we will check it. If the problem is confirmed, it will be optimized in the next version.