{"action":"created","comment":{"url":"https://api.github.com/repos/iotaledger/iri/pulls/comments/192173026","pull_request_review_id":124897654,"id":192173026,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MjE3MzAyNg==","diff_hunk":"@@ -0,0 +1,268 @@\n+package com.iota.iri.service.tipselection.impl;\n+\n+import com.iota.iri.controllers.TransactionViewModel;\n+import com.iota.iri.model.Hash;\n+import com.iota.iri.model.HashId;\n+import com.iota.iri.service.tipselection.RatingCalculator;\n+import com.iota.iri.storage.Tangle;\n+import com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider;\n+import com.iota.iri.utils.collections.interfaces.UnIterableMap;\n+import com.iota.iri.zmq.MessageQ;\n+import org.junit.AfterClass;\n+import org.junit.Assert;\n+import org.junit.BeforeClass;\n+import org.junit.Test;\n+import org.junit.rules.TemporaryFolder;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import java.util.HashMap;\n+import java.util.Map;\n+import java.util.Optional;\n+import java.util.Random;\n+\n+import static com.iota.iri.controllers.TransactionViewModelTest.*;\n+\n+public class WalkerAlphaTest {\n+    private static final TemporaryFolder dbFolder = new TemporaryFolder();\n+    private static final TemporaryFolder logFolder = new TemporaryFolder();\n+    private static Tangle tangle;\n+    private static WalkerAlpha walker;\n+    private final Logger log = LoggerFactory.getLogger(this.getClass());\n+\n+    @AfterClass\n+    public static void tearDown() throws Exception {\n+        tangle.shutdown();\n+        dbFolder.delete();\n+    }\n+\n+    @BeforeClass\n+    public static void setUp() throws Exception {\n+        tangle = new Tangle();\n+        dbFolder.create();\n+        logFolder.create();\n+        tangle.addPersistenceProvider(new RocksDBPersistenceProvider(dbFolder.getRoot().getAbsolutePath(), logFolder\n+                .getRoot().getAbsolutePath(), 1000));\n+        tangle.init();\n+        MessageQ messageQ = new MessageQ(0, null, 1, false);\n+\n+        walker = new WalkerAlpha(1, new Random(1), tangle, messageQ, (Optional::of));\n+    }\n+\n+\n+    @Test\n+    public void testWalkEndsOnlyInRating() throws Exception {\n+        //build a small tangle - 1,2,3,4 point to  transaction\n+        TransactionViewModel transaction, transaction1, transaction2, transaction3, transaction4;\n+        transaction = new TransactionViewModel(getRandomTransactionTrits(), getRandomTransactionHash());\n+        transaction1 = new TransactionViewModel(getRandomTransactionWithTrunkAndBranch(transaction.getHash(),\n+                transaction.getHash()), getRandomTransactionHash());\n+        transaction2 = new TransactionViewModel(getRandomTransactionWithTrunkAndBranch(transaction.getHash(),\n+                transaction.getHash()), getRandomTransactionHash());\n+        transaction3 = new TransactionViewModel(getRandomTransactionWithTrunkAndBranch(transaction.getHash(),\n+                transaction.getHash()), getRandomTransactionHash());\n+\n+        transaction.store(tangle);\n+        transaction1.store(tangle);\n+        transaction2.store(tangle);\n+        transaction3.store(tangle);\n+\n+        //calculate rating\n+        RatingCalculator ratingCalculator = new RatingOne(tangle);\n+        UnIterableMap<HashId, Integer> rating = ratingCalculator.calculate(transaction.getHash());\n+\n+        //add 4 after the rating was calculated\n+        transaction4 = new TransactionViewModel(getRandomTransactionWithTrunkAndBranch(transaction.getHash(),\n+                transaction.getHash()), getRandomTransactionHash());\n+        transaction4.store(tangle);\n+\n+        for (int i=0; i < 100; i++) {\n+            //select\n+            Hash tip = walker.walk(transaction.getHash(), rating, (o -> true));\n+\n+            Assert.assertTrue(tip != null);\n+            //log.info(\"selected tip: \" + tip.toString());\n+            Assert.assertTrue(!transaction4.getHash().equals(tip));\n+        }\n+    }\n+\n+    @Test\n+    public void showWalkDistributionAlphaHalf() throws Exception {\n+\n+        //build a small tangle - 1,2,3,4 point to  transaction\n+        TransactionViewModel transaction, transaction1, transaction2, transaction3, transaction4;","path":"src/test/java/com/iota/iri/service/tipselection/impl/WalkerAlphaTest.java","position":93,"original_position":93,"commit_id":"07c0d44cd10c19d06b672ef0c96bb9400d76811d","original_commit_id":"07c0d44cd10c19d06b672ef0c96bb9400d76811d","user":{"login":"codacy-bot","id":19940114,"node_id":"MDQ6VXNlcjE5OTQwMTE0","avatar_url":"https://avatars1.githubusercontent.com/u/19940114?v=4","gravatar_id":"","url":"https://api.github.com/users/codacy-bot","html_url":"https://github.com/codacy-bot","followers_url":"https://api.github.com/users/codacy-bot/followers","following_url":"https://api.github.com/users/codacy-bot/following{/other_user}","gists_url":"https://api.github.com/users/codacy-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/codacy-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codacy-bot/subscriptions","organizations_url":"https://api.github.com/users/codacy-bot/orgs","repos_url":"https://api.github.com/users/codacy-bot/repos","events_url":"https://api.github.com/users/codacy-bot/events{/privacy}","received_events_url":"https://api.github.com/users/codacy-bot/received_events","type":"User","site_admin":false},"body":"![Codacy](https://app.codacy.com/assets/images/favicon.png) Issue found: [Avoid unused local variables such as 'transaction4'.](https://app.codacy.com/app/iotaledger/iri/pullRequest?prid=1720102)","created_at":"2018-05-31T17:15:43Z","updated_at":"2018-05-31T17:15:43Z","html_url":"https://github.com/iotaledger/iri/pull/778#discussion_r192173026","pull_request_url":"https://api.github.com/repos/iotaledger/iri/pulls/778","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/iotaledger/iri/pulls/comments/192173026"},"html":{"href":"https://github.com/iotaledger/iri/pull/778#discussion_r192173026"},"pull_request":{"href":"https://api.github.com/repos/iotaledger/iri/pulls/778"}}},"pull_request":{"url":"https://api.github.com/repos/iotaledger/iri/pulls/778","id":191815584,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkxODE1NTg0","html_url":"https://github.com/iotaledger/iri/pull/778","diff_url":"https://github.com/iotaledger/iri/pull/778.diff","patch_url":"https://github.com/iotaledger/iri/pull/778.patch","issue_url":"https://api.github.com/repos/iotaledger/iri/issues/778","number":778,"state":"open","locked":false,"title":"Rework of the Tip Selection algorithm, to better match the IOTA whitepaper","user":{"login":"alon-e","id":25587995,"node_id":"MDQ6VXNlcjI1NTg3OTk1","avatar_url":"https://avatars3.githubusercontent.com/u/25587995?v=4","gravatar_id":"","url":"https://api.github.com/users/alon-e","html_url":"https://github.com/alon-e","followers_url":"https://api.github.com/users/alon-e/followers","following_url":"https://api.github.com/users/alon-e/following{/other_user}","gists_url":"https://api.github.com/users/alon-e/gists{/gist_id}","starred_url":"https://api.github.com/users/alon-e/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alon-e/subscriptions","organizations_url":"https://api.github.com/users/alon-e/orgs","repos_url":"https://api.github.com/users/alon-e/repos","events_url":"https://api.github.com/users/alon-e/events{/privacy}","received_events_url":"https://api.github.com/users/alon-e/received_events","type":"User","site_admin":false},"body":"# Description\r\nRework of the Tip Selection algorithm, to better match the IOTA whitepaper\r\n\r\nThis is a complete rewrite of the tip selection algorithm in IRI,\r\nEntry point selection, rating calculation, and walkers.\r\n\r\n*This PR only introduces the code - the integration and clean up of `TipsManager` is a separate PR.\r\n\r\nMain features:\r\n\r\n1. Cumulative weights are used (as opposed to an estimated calculation).\r\n\r\n1. `exp(alpha * Hy)` transition function from the IOTA whitepaper (as opposed to `Hy^(-3)` estimation)\r\n\r\n1. Walkers don't stop at an invalid transaction but ignore them instead.\r\n\r\n1. Code organization for better readability and maintainability\r\n\r\nFixes #774 #770 #771\r\n\r\n## Type of change\r\n\r\n- Enhancement (a non-breaking change which adds functionality)\r\n\r\n# How Has This Been Tested?\r\n\r\n- Unit tests\r\n- Local testnets\r\n- Running canaries on the mainnet\r\n- Metrics collection using #767\r\n\r\n# Checklist:\r\n\r\n- [x] My code follows the style guidelines for this project\r\n- [x] I have performed a self-review of my own code\r\n- [x] I have commented my code, particularly in hard-to-understand areas\r\n- [x] I have made corresponding changes to the documentation\r\n- [x] I have added tests that prove my fix is effective or that my feature works\r\n- [x] New and existing unit tests pass locally with my changes\r\n","created_at":"2018-05-31T16:57:38Z","updated_at":"2018-05-31T17:15:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"902f3733f1dc0dd26f689f8369c3e6c9d925a6a9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/iotaledger/iri/pulls/778/commits","review_comments_url":"https://api.github.com/repos/iotaledger/iri/pulls/778/comments","review_comment_url":"https://api.github.com/repos/iotaledger/iri/pulls/comments{/number}","comments_url":"https://api.github.com/repos/iotaledger/iri/issues/778/comments","statuses_url":"https://api.github.com/repos/iotaledger/iri/statuses/07c0d44cd10c19d06b672ef0c96bb9400d76811d","head":{"label":"alon-e:feat/newTipSelection","ref":"feat/newTipSelection","sha":"07c0d44cd10c19d06b672ef0c96bb9400d76811d","user":{"login":"alon-e","id":25587995,"node_id":"MDQ6VXNlcjI1NTg3OTk1","avatar_url":"https://avatars3.githubusercontent.com/u/25587995?v=4","gravatar_id":"","url":"https://api.github.com/users/alon-e","html_url":"https://github.com/alon-e","followers_url":"https://api.github.com/users/alon-e/followers","following_url":"https://api.github.com/users/alon-e/following{/other_user}","gists_url":"https://api.github.com/users/alon-e/gists{/gist_id}","starred_url":"https://api.github.com/users/alon-e/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alon-e/subscriptions","organizations_url":"https://api.github.com/users/alon-e/orgs","repos_url":"https://api.github.com/users/alon-e/repos","events_url":"https://api.github.com/users/alon-e/events{/privacy}","received_events_url":"https://api.github.com/users/alon-e/received_events","type":"User","site_admin":false},"repo":{"id":96702129,"node_id":"MDEwOlJlcG9zaXRvcnk5NjcwMjEyOQ==","name":"iri","full_name":"alon-e/iri","owner":{"login":"alon-e","id":25587995,"node_id":"MDQ6VXNlcjI1NTg3OTk1","avatar_url":"https://avatars3.githubusercontent.com/u/25587995?v=4","gravatar_id":"","url":"https://api.github.com/users/alon-e","html_url":"https://github.com/alon-e","followers_url":"https://api.github.com/users/alon-e/followers","following_url":"https://api.github.com/users/alon-e/following{/other_user}","gists_url":"https://api.github.com/users/alon-e/gists{/gist_id}","starred_url":"https://api.github.com/users/alon-e/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alon-e/subscriptions","organizations_url":"https://api.github.com/users/alon-e/orgs","repos_url":"https://api.github.com/users/alon-e/repos","events_url":"https://api.github.com/users/alon-e/events{/privacy}","received_events_url":"https://api.github.com/users/alon-e/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alon-e/iri","description":"IOTA Reference Implementation","fork":true,"url":"https://api.github.com/repos/alon-e/iri","forks_url":"https://api.github.com/repos/alon-e/iri/forks","keys_url":"https://api.github.com/repos/alon-e/iri/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alon-e/iri/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alon-e/iri/teams","hooks_url":"https://api.github.com/repos/alon-e/iri/hooks","issue_events_url":"https://api.github.com/repos/alon-e/iri/issues/events{/number}","events_url":"https://api.github.com/repos/alon-e/iri/events","assignees_url":"https://api.github.com/repos/alon-e/iri/assignees{/user}","branches_url":"https://api.github.com/repos/alon-e/iri/branches{/branch}","tags_url":"https://api.github.com/repos/alon-e/iri/tags","blobs_url":"https://api.github.com/repos/alon-e/iri/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alon-e/iri/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alon-e/iri/git/refs{/sha}","trees_url":"https://api.github.com/repos/alon-e/iri/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alon-e/iri/statuses/{sha}","languages_url":"https://api.github.com/repos/alon-e/iri/languages","stargazers_url":"https://api.github.com/repos/alon-e/iri/stargazers","contributors_url":"https://api.github.com/repos/alon-e/iri/contributors","subscribers_url":"https://api.github.com/repos/alon-e/iri/subscribers","subscription_url":"https://api.github.com/repos/alon-e/iri/subscription","commits_url":"https://api.github.com/repos/alon-e/iri/commits{/sha}","git_commits_url":"https://api.github.com/repos/alon-e/iri/git/commits{/sha}","comments_url":"https://api.github.com/repos/alon-e/iri/comments{/number}","issue_comment_url":"https://api.github.com/repos/alon-e/iri/issues/comments{/number}","contents_url":"https://api.github.com/repos/alon-e/iri/contents/{+path}","compare_url":"https://api.github.com/repos/alon-e/iri/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alon-e/iri/merges","archive_url":"https://api.github.com/repos/alon-e/iri/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alon-e/iri/downloads","issues_url":"https://api.github.com/repos/alon-e/iri/issues{/number}","pulls_url":"https://api.github.com/repos/alon-e/iri/pulls{/number}","milestones_url":"https://api.github.com/repos/alon-e/iri/milestones{/number}","notifications_url":"https://api.github.com/repos/alon-e/iri/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alon-e/iri/labels{/name}","releases_url":"https://api.github.com/repos/alon-e/iri/releases{/id}","deployments_url":"https://api.github.com/repos/alon-e/iri/deployments","created_at":"2017-07-09T18:08:14Z","updated_at":"2018-05-31T15:12:03Z","pushed_at":"2018-05-31T16:27:06Z","git_url":"git://github.com/alon-e/iri.git","ssh_url":"git@github.com:alon-e/iri.git","clone_url":"https://github.com/alon-e/iri.git","svn_url":"https://github.com/alon-e/iri","homepage":null,"size":78879,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":4,"watchers":1,"default_branch":"dev"}},"base":{"label":"iotaledger:dev","ref":"dev","sha":"f575913967e0635f0d2907967a6945fdb5b47365","user":{"login":"iotaledger","id":20126597,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwMTI2NTk3","avatar_url":"https://avatars3.githubusercontent.com/u/20126597?v=4","gravatar_id":"","url":"https://api.github.com/users/iotaledger","html_url":"https://github.com/iotaledger","followers_url":"https://api.github.com/users/iotaledger/followers","following_url":"https://api.github.com/users/iotaledger/following{/other_user}","gists_url":"https://api.github.com/users/iotaledger/gists{/gist_id}","starred_url":"https://api.github.com/users/iotaledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iotaledger/subscriptions","organizations_url":"https://api.github.com/users/iotaledger/orgs","repos_url":"https://api.github.com/users/iotaledger/repos","events_url":"https://api.github.com/users/iotaledger/events{/privacy}","received_events_url":"https://api.github.com/users/iotaledger/received_events","type":"Organization","site_admin":false},"repo":{"id":71836159,"node_id":"MDEwOlJlcG9zaXRvcnk3MTgzNjE1OQ==","name":"iri","full_name":"iotaledger/iri","owner":{"login":"iotaledger","id":20126597,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwMTI2NTk3","avatar_url":"https://avatars3.githubusercontent.com/u/20126597?v=4","gravatar_id":"","url":"https://api.github.com/users/iotaledger","html_url":"https://github.com/iotaledger","followers_url":"https://api.github.com/users/iotaledger/followers","following_url":"https://api.github.com/users/iotaledger/following{/other_user}","gists_url":"https://api.github.com/users/iotaledger/gists{/gist_id}","starred_url":"https://api.github.com/users/iotaledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iotaledger/subscriptions","organizations_url":"https://api.github.com/users/iotaledger/orgs","repos_url":"https://api.github.com/users/iotaledger/repos","events_url":"https://api.github.com/users/iotaledger/events{/privacy}","received_events_url":"https://api.github.com/users/iotaledger/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/iotaledger/iri","description":"IOTA Reference Implementation","fork":false,"url":"https://api.github.com/repos/iotaledger/iri","forks_url":"https://api.github.com/repos/iotaledger/iri/forks","keys_url":"https://api.github.com/repos/iotaledger/iri/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iotaledger/iri/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iotaledger/iri/teams","hooks_url":"https://api.github.com/repos/iotaledger/iri/hooks","issue_events_url":"https://api.github.com/repos/iotaledger/iri/issues/events{/number}","events_url":"https://api.github.com/repos/iotaledger/iri/events","assignees_url":"https://api.github.com/repos/iotaledger/iri/assignees{/user}","branches_url":"https://api.github.com/repos/iotaledger/iri/branches{/branch}","tags_url":"https://api.github.com/repos/iotaledger/iri/tags","blobs_url":"https://api.github.com/repos/iotaledger/iri/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iotaledger/iri/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iotaledger/iri/git/refs{/sha}","trees_url":"https://api.github.com/repos/iotaledger/iri/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iotaledger/iri/statuses/{sha}","languages_url":"https://api.github.com/repos/iotaledger/iri/languages","stargazers_url":"https://api.github.com/repos/iotaledger/iri/stargazers","contributors_url":"https://api.github.com/repos/iotaledger/iri/contributors","subscribers_url":"https://api.github.com/repos/iotaledger/iri/subscribers","subscription_url":"https://api.github.com/repos/iotaledger/iri/subscription","commits_url":"https://api.github.com/repos/iotaledger/iri/commits{/sha}","git_commits_url":"https://api.github.com/repos/iotaledger/iri/git/commits{/sha}","comments_url":"https://api.github.com/repos/iotaledger/iri/comments{/number}","issue_comment_url":"https://api.github.com/repos/iotaledger/iri/issues/comments{/number}","contents_url":"https://api.github.com/repos/iotaledger/iri/contents/{+path}","compare_url":"https://api.github.com/repos/iotaledger/iri/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iotaledger/iri/merges","archive_url":"https://api.github.com/repos/iotaledger/iri/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iotaledger/iri/downloads","issues_url":"https://api.github.com/repos/iotaledger/iri/issues{/number}","pulls_url":"https://api.github.com/repos/iotaledger/iri/pulls{/number}","milestones_url":"https://api.github.com/repos/iotaledger/iri/milestones{/number}","notifications_url":"https://api.github.com/repos/iotaledger/iri/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iotaledger/iri/labels{/name}","releases_url":"https://api.github.com/repos/iotaledger/iri/releases{/id}","deployments_url":"https://api.github.com/repos/iotaledger/iri/deployments","created_at":"2016-10-24T22:06:06Z","updated_at":"2018-05-31T06:41:42Z","pushed_at":"2018-05-31T16:57:39Z","git_url":"git://github.com/iotaledger/iri.git","ssh_url":"git@github.com:iotaledger/iri.git","clone_url":"https://github.com/iotaledger/iri.git","svn_url":"https://github.com/iotaledger/iri","homepage":null,"size":59115,"stargazers_count":957,"watchers_count":957,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":332,"mirror_url":null,"archived":false,"open_issues_count":192,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":332,"open_issues":192,"watchers":957,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/iotaledger/iri/pulls/778"},"html":{"href":"https://github.com/iotaledger/iri/pull/778"},"issue":{"href":"https://api.github.com/repos/iotaledger/iri/issues/778"},"comments":{"href":"https://api.github.com/repos/iotaledger/iri/issues/778/comments"},"review_comments":{"href":"https://api.github.com/repos/iotaledger/iri/pulls/778/comments"},"review_comment":{"href":"https://api.github.com/repos/iotaledger/iri/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/iotaledger/iri/pulls/778/commits"},"statuses":{"href":"https://api.github.com/repos/iotaledger/iri/statuses/07c0d44cd10c19d06b672ef0c96bb9400d76811d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"codacy-bot"}}