{"action":"created","comment":{"url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments/32676856","id":32676856,"diff_hunk":"@@ -5,68 +5,69 @@ import (\n \t\"github.com/NebulousLabs/Sia/types\"\n )\n \n-// MinerStatus is the information that gets returned to the front end. Each\n-// item is returned in the format that it's meant to be displayed.\n-type MinerInfo struct {\n-\tState          string\n-\tMining         bool\n-\tThreads        int\n-\tRunningThreads int\n-\tHashRate       int64\n-\tBlocksPerWeek  float64\n-\tBlocksMined    int\n-\tOrphansMined   int\n-\tAddress        types.UnlockHash\n-}\n+const (\n+\tMinerDir = \"miner\"\n+)\n \n-// The Miner interface provides access to mining features.\n-type Miner interface {\n+// A BlockBuilder contains functions that can interface with external miners,\n+// providing and receiving blocks that have experienced nonce grinding.\n+type BlockManager interface {\n \t// BlockForWork returns a block that is ready for nonce grinding. All\n \t// blocks returned by BlockForWork have a unique merkle root, meaning that\n \t// each can safely start from nonce 0.\n \tBlockForWork() (types.Block, crypto.Hash, types.Target)\n \n-\t// FindBlock will have the miner make 1 attempt to find a solved block that\n-\t// builds on the current consensus set. It will give up after a few\n-\t// seconds, returning a block, a bool indicating whether the block is\n-\t// sovled, and an error. FindBlock will submit the block to the consensus\n-\t// set.\n-\tFindBlock() (types.Block, bool, error)\n-\n \t// HeaderForWork returns a block header that can be grinded on and\n \t// resubmitted to the miner. HeaderForWork() will remember the block that\n \t// corresponds to the header for 50 calls.\n \tHeaderForWork() (types.BlockHeader, types.Target)\n \n-\t// MinerInfo returns a MinerInfo struct, containing information about the\n-\t// miner.\n-\tMinerInfo() MinerInfo\n+\t// SubmitBlock takes a block that has been worked on and has a valid\n+\t// target. Typically used with external miners.\n+\tSubmitBlock(types.Block) error\n \n-\t// MinerNotify is a channel to inform subscribers of when the miner has\n-\t// updated. This is primarily used for synchronization during testing.\n-\tMinerNotify() <-chan struct{}\n+\t// SubmitHeader takes a block header that has been worked on and has a\n+\t// valid target. A superior choice to SubmitBlock.\n+\tSubmitHeader(types.BlockHeader) error\n+}\n \n-\t// SetThreads sets the number of threads in the miner.\n-\tSetThreads(int) error\n+// A CPUMiner provides access to a single-threaded cpu miner.\n+type CPUMiner interface {\n+\t// CPUHashrate returns the hashrate of the cpu miner in hashes per second.\n+\tCPUHashrate() int\n \n-\t// SolveBlock will have the miner make 1 attempt to solve the input block.\n-\t// It will give up after a few seconds, returning the block, a bool\n-\t// indicating whether it has been solved, and an error. SolveBlock is very\n-\t// slow, and will not submit the block the the consensus set.\n-\tSolveBlock(types.Block, types.Target) (types.Block, bool)\n+\t// Mining returns true if the cpu miner is enabled, and false otherwise.\n+\tCPUMining() bool\n+\n+\t// FindBlock will have the miner make 1 attempt to find a solved block that\n+\t// builds on the current consensus set. It will give up after a few\n+\t// seconds, returning the block and a bool indicating whether the block is\n+\t// sovled.\n+\tFindBlock() (types.Block, bool)\n \n \t// StartMining turns on the miner, which will endlessly work for new\n \t// blocks.\n-\tStartMining() error\n+\tStartCPUMining()\n \n \t// StopMining turns off the miner, but keeps the same number of threads.\n-\tStopMining() error\n+\tStopCPUMining()\n \n-\t// SubmitBlock takes a block that has been worked on and has a valid\n-\t// target. Typically used with external miners.\n-\tSubmitBlock(types.Block) error\n+\t// SolveBlock will have the miner make 1 attempt to solve the input block,\n+\t// which amounts to trying a few thousand different nonces. SolveBlock is\n+\t// primarily used for testing.\n+\tSolveBlock(types.Block, types.Target) (types.Block, bool)\n+}\n \n-\t// SubmitHeader takes a block header that has been worked on and has a\n-\t// valid target. A superior choice to SubmitBlock.\n-\tSubmitHeader(types.BlockHeader) error\n+// The Miner interface provides access to mining features.\n+type Miner interface {\n+\tBlockManager\n+\tCPUMiner\n+\n+\t// BlocksMined returns the number of blocks and stale blocks that have been\n+\t// mined using this miner.\n+\tBlocksMined() (goodBlocks, staleBlocks int)\n+\n+\t// MinerNotify is a channel to inform subscribers of when the miner has\n+\t// updated. This is primarily used for synchronization during testing.\n+\tMinerNotify() <-chan struct{}","path":"modules/miner.go","position":111,"original_position":111,"commit_id":"37da7d1909a36cfdde20b4ee1bf597b29a7b51a7","original_commit_id":"37da7d1909a36cfdde20b4ee1bf597b29a7b51a7","user":{"login":"lukechampine","id":3344749,"avatar_url":"https://avatars.githubusercontent.com/u/3344749?v=3","gravatar_id":"","url":"https://api.github.com/users/lukechampine","html_url":"https://github.com/lukechampine","followers_url":"https://api.github.com/users/lukechampine/followers","following_url":"https://api.github.com/users/lukechampine/following{/other_user}","gists_url":"https://api.github.com/users/lukechampine/gists{/gist_id}","starred_url":"https://api.github.com/users/lukechampine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukechampine/subscriptions","organizations_url":"https://api.github.com/users/lukechampine/orgs","repos_url":"https://api.github.com/users/lukechampine/repos","events_url":"https://api.github.com/users/lukechampine/events{/privacy}","received_events_url":"https://api.github.com/users/lukechampine/received_events","type":"User","site_admin":false},"body":"I am a little wary of this interface separation, given that no type implements just `BlockManager` or just `CPUMiner`. It may make more sense to relegate the CPU miner to a testing package or subfolder, given that it's only used for testing.","created_at":"2015-06-17T21:26:54Z","updated_at":"2015-06-17T21:26:54Z","html_url":"https://github.com/NebulousLabs/Sia/pull/608#discussion_r32676856","pull_request_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/608","_links":{"self":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments/32676856"},"html":{"href":"https://github.com/NebulousLabs/Sia/pull/608#discussion_r32676856"},"pull_request":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/608"}}},"pull_request":{"url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/608","id":37941406,"html_url":"https://github.com/NebulousLabs/Sia/pull/608","diff_url":"https://github.com/NebulousLabs/Sia/pull/608.diff","patch_url":"https://github.com/NebulousLabs/Sia/pull/608.patch","issue_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/608","number":608,"state":"open","locked":false,"title":"Miner cleanup","user":{"login":"DavidVorick","id":2316841,"avatar_url":"https://avatars.githubusercontent.com/u/2316841?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidVorick","html_url":"https://github.com/DavidVorick","followers_url":"https://api.github.com/users/DavidVorick/followers","following_url":"https://api.github.com/users/DavidVorick/following{/other_user}","gists_url":"https://api.github.com/users/DavidVorick/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidVorick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidVorick/subscriptions","organizations_url":"https://api.github.com/users/DavidVorick/orgs","repos_url":"https://api.github.com/users/DavidVorick/repos","events_url":"https://api.github.com/users/DavidVorick/events{/privacy}","received_events_url":"https://api.github.com/users/DavidVorick/received_events","type":"User","site_admin":false},"body":"CPU miner is now single threaded.\r\n\r\nThe interface got broken into multiple interfaces.\r\n\r\nFindBlock no longer also submits the block to the consensus set, which just seems like a more intuitive way of doing things.\r\n\r\nThere's a logger for the miner now.\r\n\r\nMiner got safelocks.\r\n\r\nLots of code de-duplication.","created_at":"2015-06-17T20:12:31Z","updated_at":"2015-06-17T21:26:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b418c1157e9f4a887a9a595ae334923af901a09e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/608/commits","review_comments_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/608/comments","review_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/608/comments","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/37da7d1909a36cfdde20b4ee1bf597b29a7b51a7","head":{"label":"NebulousLabs:miner-cleanup","ref":"miner-cleanup","sha":"37da7d1909a36cfdde20b4ee1bf597b29a7b51a7","user":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":25370072,"name":"Sia","full_name":"NebulousLabs/Sia","owner":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NebulousLabs/Sia","description":"Blockchain-based marketplace for file storage","fork":false,"url":"https://api.github.com/repos/NebulousLabs/Sia","forks_url":"https://api.github.com/repos/NebulousLabs/Sia/forks","keys_url":"https://api.github.com/repos/NebulousLabs/Sia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NebulousLabs/Sia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NebulousLabs/Sia/teams","hooks_url":"https://api.github.com/repos/NebulousLabs/Sia/hooks","issue_events_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/events{/number}","events_url":"https://api.github.com/repos/NebulousLabs/Sia/events","assignees_url":"https://api.github.com/repos/NebulousLabs/Sia/assignees{/user}","branches_url":"https://api.github.com/repos/NebulousLabs/Sia/branches{/branch}","tags_url":"https://api.github.com/repos/NebulousLabs/Sia/tags","blobs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NebulousLabs/Sia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/refs{/sha}","trees_url":"https://api.github.com/repos/NebulousLabs/Sia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/{sha}","languages_url":"https://api.github.com/repos/NebulousLabs/Sia/languages","stargazers_url":"https://api.github.com/repos/NebulousLabs/Sia/stargazers","contributors_url":"https://api.github.com/repos/NebulousLabs/Sia/contributors","subscribers_url":"https://api.github.com/repos/NebulousLabs/Sia/subscribers","subscription_url":"https://api.github.com/repos/NebulousLabs/Sia/subscription","commits_url":"https://api.github.com/repos/NebulousLabs/Sia/commits{/sha}","git_commits_url":"https://api.github.com/repos/NebulousLabs/Sia/git/commits{/sha}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/comments{/number}","issue_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/comments{/number}","contents_url":"https://api.github.com/repos/NebulousLabs/Sia/contents/{+path}","compare_url":"https://api.github.com/repos/NebulousLabs/Sia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NebulousLabs/Sia/merges","archive_url":"https://api.github.com/repos/NebulousLabs/Sia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NebulousLabs/Sia/downloads","issues_url":"https://api.github.com/repos/NebulousLabs/Sia/issues{/number}","pulls_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls{/number}","milestones_url":"https://api.github.com/repos/NebulousLabs/Sia/milestones{/number}","notifications_url":"https://api.github.com/repos/NebulousLabs/Sia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NebulousLabs/Sia/labels{/name}","releases_url":"https://api.github.com/repos/NebulousLabs/Sia/releases{/id}","created_at":"2014-10-17T17:50:25Z","updated_at":"2015-06-11T02:26:19Z","pushed_at":"2015-06-17T21:12:43Z","git_url":"git://github.com/NebulousLabs/Sia.git","ssh_url":"git@github.com:NebulousLabs/Sia.git","clone_url":"https://github.com/NebulousLabs/Sia.git","svn_url":"https://github.com/NebulousLabs/Sia","homepage":"http://siacoin.com","size":29167,"stargazers_count":45,"watchers_count":45,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":9,"mirror_url":null,"open_issues_count":41,"forks":9,"open_issues":41,"watchers":45,"default_branch":"master"}},"base":{"label":"NebulousLabs:master","ref":"master","sha":"44261b08c32c1d6ee8f78e242f9a4151b7bf78e1","user":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":25370072,"name":"Sia","full_name":"NebulousLabs/Sia","owner":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NebulousLabs/Sia","description":"Blockchain-based marketplace for file storage","fork":false,"url":"https://api.github.com/repos/NebulousLabs/Sia","forks_url":"https://api.github.com/repos/NebulousLabs/Sia/forks","keys_url":"https://api.github.com/repos/NebulousLabs/Sia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NebulousLabs/Sia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NebulousLabs/Sia/teams","hooks_url":"https://api.github.com/repos/NebulousLabs/Sia/hooks","issue_events_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/events{/number}","events_url":"https://api.github.com/repos/NebulousLabs/Sia/events","assignees_url":"https://api.github.com/repos/NebulousLabs/Sia/assignees{/user}","branches_url":"https://api.github.com/repos/NebulousLabs/Sia/branches{/branch}","tags_url":"https://api.github.com/repos/NebulousLabs/Sia/tags","blobs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NebulousLabs/Sia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/refs{/sha}","trees_url":"https://api.github.com/repos/NebulousLabs/Sia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/{sha}","languages_url":"https://api.github.com/repos/NebulousLabs/Sia/languages","stargazers_url":"https://api.github.com/repos/NebulousLabs/Sia/stargazers","contributors_url":"https://api.github.com/repos/NebulousLabs/Sia/contributors","subscribers_url":"https://api.github.com/repos/NebulousLabs/Sia/subscribers","subscription_url":"https://api.github.com/repos/NebulousLabs/Sia/subscription","commits_url":"https://api.github.com/repos/NebulousLabs/Sia/commits{/sha}","git_commits_url":"https://api.github.com/repos/NebulousLabs/Sia/git/commits{/sha}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/comments{/number}","issue_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/comments{/number}","contents_url":"https://api.github.com/repos/NebulousLabs/Sia/contents/{+path}","compare_url":"https://api.github.com/repos/NebulousLabs/Sia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NebulousLabs/Sia/merges","archive_url":"https://api.github.com/repos/NebulousLabs/Sia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NebulousLabs/Sia/downloads","issues_url":"https://api.github.com/repos/NebulousLabs/Sia/issues{/number}","pulls_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls{/number}","milestones_url":"https://api.github.com/repos/NebulousLabs/Sia/milestones{/number}","notifications_url":"https://api.github.com/repos/NebulousLabs/Sia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NebulousLabs/Sia/labels{/name}","releases_url":"https://api.github.com/repos/NebulousLabs/Sia/releases{/id}","created_at":"2014-10-17T17:50:25Z","updated_at":"2015-06-11T02:26:19Z","pushed_at":"2015-06-17T21:12:43Z","git_url":"git://github.com/NebulousLabs/Sia.git","ssh_url":"git@github.com:NebulousLabs/Sia.git","clone_url":"https://github.com/NebulousLabs/Sia.git","svn_url":"https://github.com/NebulousLabs/Sia","homepage":"http://siacoin.com","size":29167,"stargazers_count":45,"watchers_count":45,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":9,"mirror_url":null,"open_issues_count":41,"forks":9,"open_issues":41,"watchers":45,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/608"},"html":{"href":"https://github.com/NebulousLabs/Sia/pull/608"},"issue":{"href":"https://api.github.com/repos/NebulousLabs/Sia/issues/608"},"comments":{"href":"https://api.github.com/repos/NebulousLabs/Sia/issues/608/comments"},"review_comments":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/608/comments"},"review_comment":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/608/commits"},"statuses":{"href":"https://api.github.com/repos/NebulousLabs/Sia/statuses/37da7d1909a36cfdde20b4ee1bf597b29a7b51a7"}}}}