draft 1 of mining.py code. please review and edit doc strings if code is okay.