Keep cache of nodes under discovery in the local database

Introduces SQLite database to keep a cache of nodes for discovery.
Move node lookup code into a new module `node_cache`.

This will greatly improve performance by doing less network requests
and will allow both implementing timeouts and getting rid of using
maintenance mode.

Change-Id: I543cb32d9d04f55bcf4573e9e0d341317cae4df6
Partial-Bug: #1391868
Partial-Bug: #1391871