Add white list and black list to hostdb
PROGRAMMING TASK
Description of Task
This change would add a black list and a white list to the hostdb to give the renter more control over the hosts that it uses.
Reason or Need for Change
As it stands now there is no easy way for the renter to use or not use specific hosts. By adding a black list and a white list the renter will be able to choose hosts they want to use and similarly choose hosts they don't want to use.
Design / Proposal
- Changes to HostDB
I would propose adding awhiteList
andblackList
to thehostdb
along withuseWhilteList
anduseBlackList
. The two lists would be maps containing host pubkeys. Theuse
fields would be booleans that can be set by the user and by default they would be false. WhenuseBlackList
istrue
, the hosts in theblackList
won't be returned from thehosttree
(building upon current blacklist functionality) and any contracts with hosts in theblackList
would be canceled. WhenuseWhiteList
istrue
, any time thehosttree
is queried, a new whitelistedhosttree
will be built in place and any contracts with hosts not in thewhiteList
would be canceled. Both theblackList
and thewhiteList
would be persisted in new json files. The user will have 3 modes that they can run in; normal, blacklist, and whitelist.
Need to determine most efficient way to pass the white and black list information back and forth from the renter and the hostdb.
-
Changes to API
The API will need to be extend to allow the user to set the newuse
fields of a hostdb as well as add and remove hosts from the either list. Client package methods can also be added,BlackListHost
andWhiteListHost
for adding hosts to either list and respectiveUseList
methods for enabling each list.ClearLists
would probably also be useful. -
Testing
A siatest will be created. The test should do something like the following:- Start new group
- Wait for the renter to have contracts
- Black list a hosts
- Confirm the contract is dropped and the hosts does not renew a contract
- Confirm that host is no longer in the hostdb
- Add a new host and white list them
- Confirm all contracts are dropped and only the whitelist host has a contract
- Confirm the host is the only host in the hostdb
Unit tests should be created to tests any new list methods.