Add some lots of node logic and structure.

I'm using channels to convey some state changes (for instance to recurse
in the node loop to update leader changes and connect sockets to new
leader)