Add basic http auth to rpc server.
Make error logging in peer.go unique.

Helps tracking down errors.
Don't propagate inv messages to connecting peers.

Only queue messages for peers that have finished connecting to prevent
filling goroutines and causing deadlocks.
Bucketizing for addrmanager

Implement the bucketing by source group and group using essentially the
same algorithm as the address maanger in bitcoind.

Fix up the saving of peer.json to do so in a json format that keeps bucket
metadata.

If we fail to load the some of the data we asssume that we have
incomplete information, so we nuke the existing file and reinitialise so
we have a clean slate.
move the intiial chain cache generation into bm.

Blockmanager is otherwise the only current consumer of chain and it is
messy to do it outside of it.
Keep track of currently requested blocks per peer.

Use this information so that we do not request a block per peer we got
an inv for it, makes multi peer much quieter and rather more bandwidth
efficient.

In order to remove a number of possible races we combine blockhandling
an synchandler and use one channel for all messages. This ensures that
all messages from a single peer will be recieved in order.  It also
removes the need for a lot of locking between the peer removal code and
the block/inv handlers.
Revert "Comment multi-peer connect while code is under dev."

This reverts commit 7609ff396ad209c9dd21fef3b026081898ad3912.
Disconnect misbehaving peers who send unsolicited blocks.
Fix shutdown hangs.

We would occasionally hang or a while during server shudown, this is due
to an outbound peer waiting on a connection or a sleep. However, we
don't actually require to wait for the peers to finish at all. So just
let them finish.

Secondly, make peer.disconnnect and server.shutdown atomic varaibles so
that checking them from multiple goroutines isn't race, and clean up
their usage.
Don't create additional outbound peers if any --connect are specified.
lack of a peers.json isn't an error, don't log in that case.
Remove unused wakeup timer in peerHandler.
Return nil in GetAddress if no addresses present.

Honestly thought we already did this, but turns out no.
Hold amgr lock in {load,save}Peers.

We're traversing internal datastructures here.
RFC4193 is fc00::/7, not fc00::/15.  Also fix two typos in RFC4843()
and RFC6052
add tests for RFC*, Local, Valid, and Routable.
make logging about peers rather quieter.

Only log errors for most cases if the peer is persisent (and thus requested).
Only log by default after version exchange, and after losing a peer that had
completed version exchange. Make most other messages debug.
Remove a (largely harmless) race on p.conn

Add a Connected() member function that checks atomic variables to see if
the peer is connected.
Convert the rest of the subsystems to use atomics for shutdown vars.
Remove races on chain.

Chain is not concurrency safe, so we move the chainNotifySink handling
into the main blockmanager goroutine. Due to a possible deadlock if the
buffer is filled this still has to be a single channel that isn't linked
to the other ones. There is a possible starvation issue where the main
msgChan gets selected more often than the  notification sink, but until
chain is concurrency safe this is rather unavoidable.