Some thoughts on refactoring on the road to sharding

Secured
#1
A lot of simplifications will come out of refactoring with new control flows. Paul, Clay and myself just got out of a meeting figuring out what kind of things we wanted to do with the refactoring hopefully over the next few months, if there is some community support for it. It would involve building a router that takes in p2p messages and then parcels them out to different threads that handle different aspects of the code. As part of this threading to have channels between more parts of the code, so that the actions are more message initiated rather than looking for things in queues.
One of the big problems according to Paul S is the mixing of follower and leader activities in the control flows, which has made for some awkward to debug code. The first step would be to delete the leader code (which is a small part of what the thing does, since all nodes need to do validation, which is harder.) The leader aspect sets the order of validated items. After getting the updated control flows to be message activated, adding back in the leader code would be done in a more controlled manner than it currently is in. Having things be more message based than timer based is one of the first steps on the way to sharding the system.