This code is based on pool-reference code from chia org.
It has been modified to provide more funcionalities required by a production pool.