Skip to content

Host Revamp

David Vorick requested to merge host-revenue into master

I don't know how this blew up so much, it was a lot simpler when I got started. I'm still not done testing, and there are a handful of other features I'd like to add, but I don't see those being ready by v0.5.0. It's time to call it quits on the feature adding until we're ready to start moving towards v1.0. I haven't finished writing tests yet, it's likely that some of the tests will turn up more bugs - some of the fancier logic still isn't checked.

I added some tracking to the RPCs. Now, the host will count each time any of the RPCs are hit, which will give us information about how hosts are being used. This is particularly useful as a natural way to tell if the ports are forwarded. A very low hit count would indicate that the host has low visibility. A high hit count would indicate that the ports are probably forwarded correctly. Currently, there's no way to access these fields from outside the package.

The logger package will now get upset if you call Write after you call Close, or if you call Close twice.

The host is now able to track consensus on the transactions that it has. It can tell if a transaction is not in the consensus set, and will know to resubmit the transaction. It can tell if it has been double spent, and will know to delete the obligation. It can tell if there was a reorg after it submitted a storage proof.

The host now cleanly closes. All goroutines will get to terminate before stuff like the logger is closed, and when Close terminates there should be no more threads running in the host. Additionally, exported functions that require host resources will return errors if they are called after the host has been closed.

Host now passes golint, and a travis check has been added that will run golint on the host.

Errcheck has been run on the host, not all offences have been removed due to defer Closer type stuff, but a few mistakes were found and corrected. @lukechampine may disagree with some of the error handling, so it's worth a close look + discussion. I'm thinking mostly about checking the errors on conn.SetDeadline

Things that could still be done:

  • rpc tracking is not exported
  • bandwidth ratelimiting
  • merkle tree caching
  • allowing edits to a file in random places (requires merkle tree caching)
  • paid bandwidth
  • toggle switch to stop the host from accepting new contracts
  • some of the informational functions could be consolidated, which may make mocking easier

Merge request reports