implement a series of functions for mining. Close #12, close #15, close #16.