{"action":"created","comment":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments/33412276","id":33412276,"diff_hunk":"@@ -53,13 +57,66 @@ class CTxMemPoolEntry\n \n     const CTransaction& GetTx() const { return this->tx; }\n     double GetPriority(unsigned int currentHeight) const;\n+    double GetCurrentPriority() const { return dCurrentPriority; }\n     CAmount GetFee() const { return nFee; }\n+    CFeeRate GetFeeRate() const { return feeRate; }\n     size_t GetTxSize() const { return nTxSize; }\n     int64_t GetTime() const { return nTime; }\n     unsigned int GetHeight() const { return nHeight; }\n     bool WasClearAtEntry() const { return hadNoDependencies; }\n+    void recalcCurrentPriority (unsigned int height) { dCurrentPriority = GetPriority(height); }\n };\n \n+// extracts a TxMemPoolEntry's transaction hash\n+struct mempoolentry_txid\n+{\n+    typedef uint256 result_type;\n+    result_type operator() (const CTxMemPoolEntry &entry) const\n+    {\n+        return entry.GetTx().GetHash();\n+    }\n+};\n+\n+class CompareTxMemPoolEntryByPriority\n+{\n+public:\n+    bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b)\n+    {\n+        if (a.GetCurrentPriority() == b.GetCurrentPriority())\n+            return a.GetFeeRate() > b.GetFeeRate();\n+        return a.GetCurrentPriority() > b.GetCurrentPriority();\n+    }\n+};\n+\n+class CompareTxMemPoolEntryByFee\n+{\n+public:\n+    bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b)\n+    {\n+        if (a.GetFeeRate() == b.GetFeeRate())\n+            return a.GetCurrentPriority() > b.GetCurrentPriority();\n+        return a.GetFeeRate() > b.GetFeeRate();\n+    }\n+};\n+\n+typedef boost::multi_index_container<\n+    CTxMemPoolEntry,\n+    boost::multi_index::indexed_by<\n+        // sorted by txid\n+        boost::multi_index::ordered_unique<mempoolentry_txid>,\n+        // sorted by fee rate\n+        boost::multi_index::ordered_non_unique<\n+            boost::multi_index::identity<CTxMemPoolEntry>,\n+            CompareTxMemPoolEntryByFee\n+        >,\n+        // sorted by priority\n+        boost::multi_index::ordered_non_unique<\n+            boost::multi_index::identity<CTxMemPoolEntry>,\n+            CompareTxMemPoolEntryByPriority\n+        >\n+    >\n+> ordered_transaction_set;","path":"src/txmempool.h","position":null,"original_position":82,"commit_id":"362bf769edc6f15495a78461902d54d649c83c08","original_commit_id":"f27cd7ed6d6bbe242a64ecabf581edd498bc65e7","user":{"login":"ashleyholman","id":549484,"avatar_url":"https://avatars.githubusercontent.com/u/549484?v=3","gravatar_id":"","url":"https://api.github.com/users/ashleyholman","html_url":"https://github.com/ashleyholman","followers_url":"https://api.github.com/users/ashleyholman/followers","following_url":"https://api.github.com/users/ashleyholman/following{/other_user}","gists_url":"https://api.github.com/users/ashleyholman/gists{/gist_id}","starred_url":"https://api.github.com/users/ashleyholman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashleyholman/subscriptions","organizations_url":"https://api.github.com/users/ashleyholman/orgs","repos_url":"https://api.github.com/users/ashleyholman/repos","events_url":"https://api.github.com/users/ashleyholman/events{/privacy}","received_events_url":"https://api.github.com/users/ashleyholman/received_events","type":"User","site_admin":false},"body":"I've now renamed it to CTxMemPool::indexed_transaction_set in my latest commit.","created_at":"2015-06-27T12:02:47Z","updated_at":"2015-06-27T12:02:47Z","html_url":"https://github.com/bitcoin/bitcoin/pull/6331#discussion_r33412276","pull_request_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6331","_links":{"self":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments/33412276"},"html":{"href":"https://github.com/bitcoin/bitcoin/pull/6331#discussion_r33412276"},"pull_request":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6331"}}},"pull_request":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6331","id":38419897,"html_url":"https://github.com/bitcoin/bitcoin/pull/6331","diff_url":"https://github.com/bitcoin/bitcoin/pull/6331.diff","patch_url":"https://github.com/bitcoin/bitcoin/pull/6331.patch","issue_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/6331","number":6331,"state":"open","locked":false,"title":"MemPool: Convert mapTx to boost::multi_index_container","user":{"login":"ashleyholman","id":549484,"avatar_url":"https://avatars.githubusercontent.com/u/549484?v=3","gravatar_id":"","url":"https://api.github.com/users/ashleyholman","html_url":"https://github.com/ashleyholman","followers_url":"https://api.github.com/users/ashleyholman/followers","following_url":"https://api.github.com/users/ashleyholman/following{/other_user}","gists_url":"https://api.github.com/users/ashleyholman/gists{/gist_id}","starred_url":"https://api.github.com/users/ashleyholman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashleyholman/subscriptions","organizations_url":"https://api.github.com/users/ashleyholman/orgs","repos_url":"https://api.github.com/users/ashleyholman/repos","events_url":"https://api.github.com/users/ashleyholman/events{/privacy}","received_events_url":"https://api.github.com/users/ashleyholman/received_events","type":"User","site_admin":false},"body":"This patch changes CTxMemPool::mapTx from a std::map to a boost::multi_index_container.\r\n\r\nThe container has three indexes:\r\n- Tx Hash\r\n- Fee Rate (fee-per-kb) - ordered from highest to lowest\r\n- Priority (at current chain height) - ordered from highest to lowest\r\n\r\nThe idea is that these indices can later be used for:\r\n- Creating blocks\r\n- Mempool eviction\r\n\r\nThe priority stuff is a bit ugly, so suggestions on alternate designs are welcome.  I would also like to add another test case that tests the ConnectTip/DisconnectTip triggers, but I need to do some more work to figure out how to construct such a test.","created_at":"2015-06-24T08:49:17Z","updated_at":"2015-06-27T12:02:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"04604640fd585c73b2858099da36f048ec9b5aa2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6331/commits","review_comments_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6331/comments","review_comment_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/6331/comments","statuses_url":"https://api.github.com/repos/bitcoin/bitcoin/statuses/362bf769edc6f15495a78461902d54d649c83c08","head":{"label":"ashleyholman:mempool_multiindex","ref":"mempool_multiindex","sha":"362bf769edc6f15495a78461902d54d649c83c08","user":{"login":"ashleyholman","id":549484,"avatar_url":"https://avatars.githubusercontent.com/u/549484?v=3","gravatar_id":"","url":"https://api.github.com/users/ashleyholman","html_url":"https://github.com/ashleyholman","followers_url":"https://api.github.com/users/ashleyholman/followers","following_url":"https://api.github.com/users/ashleyholman/following{/other_user}","gists_url":"https://api.github.com/users/ashleyholman/gists{/gist_id}","starred_url":"https://api.github.com/users/ashleyholman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashleyholman/subscriptions","organizations_url":"https://api.github.com/users/ashleyholman/orgs","repos_url":"https://api.github.com/users/ashleyholman/repos","events_url":"https://api.github.com/users/ashleyholman/events{/privacy}","received_events_url":"https://api.github.com/users/ashleyholman/received_events","type":"User","site_admin":false},"repo":{"id":12082456,"name":"bitcoin","full_name":"ashleyholman/bitcoin","owner":{"login":"ashleyholman","id":549484,"avatar_url":"https://avatars.githubusercontent.com/u/549484?v=3","gravatar_id":"","url":"https://api.github.com/users/ashleyholman","html_url":"https://github.com/ashleyholman","followers_url":"https://api.github.com/users/ashleyholman/followers","following_url":"https://api.github.com/users/ashleyholman/following{/other_user}","gists_url":"https://api.github.com/users/ashleyholman/gists{/gist_id}","starred_url":"https://api.github.com/users/ashleyholman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashleyholman/subscriptions","organizations_url":"https://api.github.com/users/ashleyholman/orgs","repos_url":"https://api.github.com/users/ashleyholman/repos","events_url":"https://api.github.com/users/ashleyholman/events{/privacy}","received_events_url":"https://api.github.com/users/ashleyholman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ashleyholman/bitcoin","description":"My bitcoin branches","fork":true,"url":"https://api.github.com/repos/ashleyholman/bitcoin","forks_url":"https://api.github.com/repos/ashleyholman/bitcoin/forks","keys_url":"https://api.github.com/repos/ashleyholman/bitcoin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ashleyholman/bitcoin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ashleyholman/bitcoin/teams","hooks_url":"https://api.github.com/repos/ashleyholman/bitcoin/hooks","issue_events_url":"https://api.github.com/repos/ashleyholman/bitcoin/issues/events{/number}","events_url":"https://api.github.com/repos/ashleyholman/bitcoin/events","assignees_url":"https://api.github.com/repos/ashleyholman/bitcoin/assignees{/user}","branches_url":"https://api.github.com/repos/ashleyholman/bitcoin/branches{/branch}","tags_url":"https://api.github.com/repos/ashleyholman/bitcoin/tags","blobs_url":"https://api.github.com/repos/ashleyholman/bitcoin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ashleyholman/bitcoin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ashleyholman/bitcoin/git/refs{/sha}","trees_url":"https://api.github.com/repos/ashleyholman/bitcoin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ashleyholman/bitcoin/statuses/{sha}","languages_url":"https://api.github.com/repos/ashleyholman/bitcoin/languages","stargazers_url":"https://api.github.com/repos/ashleyholman/bitcoin/stargazers","contributors_url":"https://api.github.com/repos/ashleyholman/bitcoin/contributors","subscribers_url":"https://api.github.com/repos/ashleyholman/bitcoin/subscribers","subscription_url":"https://api.github.com/repos/ashleyholman/bitcoin/subscription","commits_url":"https://api.github.com/repos/ashleyholman/bitcoin/commits{/sha}","git_commits_url":"https://api.github.com/repos/ashleyholman/bitcoin/git/commits{/sha}","comments_url":"https://api.github.com/repos/ashleyholman/bitcoin/comments{/number}","issue_comment_url":"https://api.github.com/repos/ashleyholman/bitcoin/issues/comments{/number}","contents_url":"https://api.github.com/repos/ashleyholman/bitcoin/contents/{+path}","compare_url":"https://api.github.com/repos/ashleyholman/bitcoin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ashleyholman/bitcoin/merges","archive_url":"https://api.github.com/repos/ashleyholman/bitcoin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ashleyholman/bitcoin/downloads","issues_url":"https://api.github.com/repos/ashleyholman/bitcoin/issues{/number}","pulls_url":"https://api.github.com/repos/ashleyholman/bitcoin/pulls{/number}","milestones_url":"https://api.github.com/repos/ashleyholman/bitcoin/milestones{/number}","notifications_url":"https://api.github.com/repos/ashleyholman/bitcoin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ashleyholman/bitcoin/labels{/name}","releases_url":"https://api.github.com/repos/ashleyholman/bitcoin/releases{/id}","created_at":"2013-08-13T13:27:13Z","updated_at":"2015-05-12T05:17:00Z","pushed_at":"2015-06-27T11:59:28Z","git_url":"git://github.com/ashleyholman/bitcoin.git","ssh_url":"git@github.com:ashleyholman/bitcoin.git","clone_url":"https://github.com/ashleyholman/bitcoin.git","svn_url":"https://github.com/ashleyholman/bitcoin","homepage":"http://www.bitcoin.org","size":49505,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bitcoin:master","ref":"master","sha":"91389e51c78ae3565b037e31dd5382b52bd75136","user":{"login":"bitcoin","id":528860,"avatar_url":"https://avatars.githubusercontent.com/u/528860?v=3","gravatar_id":"","url":"https://api.github.com/users/bitcoin","html_url":"https://github.com/bitcoin","followers_url":"https://api.github.com/users/bitcoin/followers","following_url":"https://api.github.com/users/bitcoin/following{/other_user}","gists_url":"https://api.github.com/users/bitcoin/gists{/gist_id}","starred_url":"https://api.github.com/users/bitcoin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitcoin/subscriptions","organizations_url":"https://api.github.com/users/bitcoin/orgs","repos_url":"https://api.github.com/users/bitcoin/repos","events_url":"https://api.github.com/users/bitcoin/events{/privacy}","received_events_url":"https://api.github.com/users/bitcoin/received_events","type":"Organization","site_admin":false},"repo":{"id":1181927,"name":"bitcoin","full_name":"bitcoin/bitcoin","owner":{"login":"bitcoin","id":528860,"avatar_url":"https://avatars.githubusercontent.com/u/528860?v=3","gravatar_id":"","url":"https://api.github.com/users/bitcoin","html_url":"https://github.com/bitcoin","followers_url":"https://api.github.com/users/bitcoin/followers","following_url":"https://api.github.com/users/bitcoin/following{/other_user}","gists_url":"https://api.github.com/users/bitcoin/gists{/gist_id}","starred_url":"https://api.github.com/users/bitcoin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitcoin/subscriptions","organizations_url":"https://api.github.com/users/bitcoin/orgs","repos_url":"https://api.github.com/users/bitcoin/repos","events_url":"https://api.github.com/users/bitcoin/events{/privacy}","received_events_url":"https://api.github.com/users/bitcoin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bitcoin/bitcoin","description":"Bitcoin Core integration/staging tree","fork":false,"url":"https://api.github.com/repos/bitcoin/bitcoin","forks_url":"https://api.github.com/repos/bitcoin/bitcoin/forks","keys_url":"https://api.github.com/repos/bitcoin/bitcoin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bitcoin/bitcoin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bitcoin/bitcoin/teams","hooks_url":"https://api.github.com/repos/bitcoin/bitcoin/hooks","issue_events_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/events{/number}","events_url":"https://api.github.com/repos/bitcoin/bitcoin/events","assignees_url":"https://api.github.com/repos/bitcoin/bitcoin/assignees{/user}","branches_url":"https://api.github.com/repos/bitcoin/bitcoin/branches{/branch}","tags_url":"https://api.github.com/repos/bitcoin/bitcoin/tags","blobs_url":"https://api.github.com/repos/bitcoin/bitcoin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bitcoin/bitcoin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bitcoin/bitcoin/git/refs{/sha}","trees_url":"https://api.github.com/repos/bitcoin/bitcoin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bitcoin/bitcoin/statuses/{sha}","languages_url":"https://api.github.com/repos/bitcoin/bitcoin/languages","stargazers_url":"https://api.github.com/repos/bitcoin/bitcoin/stargazers","contributors_url":"https://api.github.com/repos/bitcoin/bitcoin/contributors","subscribers_url":"https://api.github.com/repos/bitcoin/bitcoin/subscribers","subscription_url":"https://api.github.com/repos/bitcoin/bitcoin/subscription","commits_url":"https://api.github.com/repos/bitcoin/bitcoin/commits{/sha}","git_commits_url":"https://api.github.com/repos/bitcoin/bitcoin/git/commits{/sha}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/comments{/number}","issue_comment_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/comments{/number}","contents_url":"https://api.github.com/repos/bitcoin/bitcoin/contents/{+path}","compare_url":"https://api.github.com/repos/bitcoin/bitcoin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bitcoin/bitcoin/merges","archive_url":"https://api.github.com/repos/bitcoin/bitcoin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bitcoin/bitcoin/downloads","issues_url":"https://api.github.com/repos/bitcoin/bitcoin/issues{/number}","pulls_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls{/number}","milestones_url":"https://api.github.com/repos/bitcoin/bitcoin/milestones{/number}","notifications_url":"https://api.github.com/repos/bitcoin/bitcoin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bitcoin/bitcoin/labels{/name}","releases_url":"https://api.github.com/repos/bitcoin/bitcoin/releases{/id}","created_at":"2010-12-19T15:16:43Z","updated_at":"2015-06-27T00:59:23Z","pushed_at":"2015-06-27T11:59:32Z","git_url":"git://github.com/bitcoin/bitcoin.git","ssh_url":"git@github.com:bitcoin/bitcoin.git","clone_url":"https://github.com/bitcoin/bitcoin.git","svn_url":"https://github.com/bitcoin/bitcoin","homepage":"https://bitcoin.org/en/download","size":130347,"stargazers_count":7066,"watchers_count":7066,"language":"C++","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":4927,"mirror_url":null,"open_issues_count":427,"forks":4927,"open_issues":427,"watchers":7066,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6331"},"html":{"href":"https://github.com/bitcoin/bitcoin/pull/6331"},"issue":{"href":"https://api.github.com/repos/bitcoin/bitcoin/issues/6331"},"comments":{"href":"https://api.github.com/repos/bitcoin/bitcoin/issues/6331/comments"},"review_comments":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6331/comments"},"review_comment":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/6331/commits"},"statuses":{"href":"https://api.github.com/repos/bitcoin/bitcoin/statuses/362bf769edc6f15495a78461902d54d649c83c08"}}}}