{"action":"created","comment":{"url":"https://api.github.com/repos/corda/corda/pulls/comments/122390010","pull_request_review_id":44500614,"id":122390010,"diff_hunk":"@@ -0,0 +1,992 @@\n+.. highlight:: kotlin\n+.. raw:: html\n+\n+   <script type=\"text/javascript\" src=\"_static/jquery.js\"></script>\n+   <script type=\"text/javascript\" src=\"_static/codesets.js\"></script>\n+\n+Writing the flow\n+================\n+A flow describes the sequence of steps for agreeing a specific ledger update. By installing new flows on our node, we\n+allow the node to handle new business processes.\n+\n+We'll have to define two flows to issue an ``IOUState`` onto the ledger:\n+* One to be run by the node initiating the creation of the IOU\n+* One to be run by the node responding to an IOU creation request\n+\n+Let's start writing our flows. We'll do this by modifying either TemplateFlow.java or\n+TemplateFlow.kt.\n+\n+FlowLogic\n+---------\n+Each flow is implemented as a ``FlowLogic`` subclass. You define the steps taken by the flow by overriding\n+``FlowLogic.call``.\n+\n+We will define two ``FlowLogic`` instances communicating as a pair. The first will be called ``Initiator``, and will\n+be run by the sender of the IOU. The other will be called ``Acceptor``, and will be run by the recipient. Overwrite\n+the existing template code with the following:\n+\n+.. container:: codeset\n+\n+    .. code-block:: kotlin\n+\n+        package com.template\n+\n+        import co.paralleluniverse.fibers.Suspendable\n+        import net.corda.core.flows.FlowLogic\n+        import net.corda.core.flows.InitiatedBy\n+        import net.corda.core.flows.InitiatingFlow\n+        import net.corda.core.flows.StartableByRPC\n+        import net.corda.core.identity.Party\n+        import net.corda.core.transactions.SignedTransaction\n+        import net.corda.core.utilities.ProgressTracker\n+\n+        object IOUFlow {\n+            @InitiatingFlow\n+            @StartableByRPC\n+            class Initiator(val iouValue: Int,\n+                            val otherParty: Party): FlowLogic<SignedTransaction>() {\n+\n+                /** The progress tracker provides checkpoints indicating the progress of the flow to observers. */\n+                override val progressTracker = ProgressTracker()\n+\n+                /** The flow logic is encapsulated within the call() method. */\n+                @Suspendable\n+                override fun call(): SignedTransaction { }\n+            }\n+\n+            @InitiatedBy(Initiator::class)\n+            class Acceptor(val otherParty: Party) : FlowLogic<Unit>() {\n+\n+                @Suspendable\n+                override fun call() { }\n+            }\n+        }\n+\n+    .. code-block:: java\n+\n+        package com.template;\n+\n+        import co.paralleluniverse.fibers.Suspendable;\n+        import net.corda.core.flows.*;\n+        import net.corda.core.identity.Party;\n+        import net.corda.core.transactions.SignedTransaction;\n+        import net.corda.core.utilities.ProgressTracker;\n+\n+        public class IOUFlow {\n+            @InitiatingFlow\n+            @StartableByRPC\n+            public static class Initiator extends FlowLogic<SignedTransaction> {\n+                private final Integer iouValue;\n+                private final Party otherParty;\n+\n+                /** The progress tracker provides checkpoints indicating the progress of the flow to observers. */\n+                private final ProgressTracker progressTracker = new ProgressTracker();\n+\n+                public Initiator(Integer iouValue, Party otherParty) {\n+                    this.iouValue = iouValue;\n+                    this.otherParty = otherParty;\n+                }\n+\n+                /** The flow logic is encapsulated within the call() method. */\n+                @Suspendable\n+                @Override\n+                public SignedTransaction call() throws FlowException { }\n+            }\n+\n+            @InitiatedBy(Initiator.class)\n+            public static class Acceptor extends FlowLogic<Void> {\n+\n+                private final Party otherParty;\n+\n+                public Acceptor(Party otherParty) {\n+                    this.otherParty = otherParty;\n+                }\n+\n+                @Suspendable\n+                @Override\n+                public Void call() throws FlowException { }\n+            }\n+        }\n+\n+We can see that we have two ``FlowLogic`` subclasses, each overriding ``FlowLogic.call``. There's a few things to note:\n+\n+* ``FlowLogic.call`` has a return type that matches the generic passed to ``FlowLogic`` - this is the return type of\n+  running the flow\n+* The ``FlowLogic`` subclasses can have constructor parameters, which can be used as arguments to ``FlowLogic.call``\n+* ``FlowLogic.call`` is annotated ``@Suspendable`` - this means that the flow will be check-pointed and serialised to\n+  disk when it encounters a long-running operation, allowing your node to move on to running other flows. Forgetting\n+  this annotation out will lead to some very weird error messages\n+* There are also a few more annotations, on the ``FlowLogic`` subclasses themselves:\n+  * ``@InitiatingFlow`` means that this flow can be started directly by the node\n+  * ``StartableByRPC`` allows the node owner to start this flow via an RPC call\n+  * ``@InitiatedBy(myClass: Class)`` means that this flow will only start in response to a message sent by another\n+    node running the ``myClass`` flow\n+\n+Flow outline\n+------------\n+Now that we've defined our ``FlowLogic`` subclasses, what are the steps we need to take to issue a new IOU onto\n+the ledger?\n+\n+On the initiator side, we need to:\n+  1. Create a valid transaction proposal for the creation of a new IOU\n+  2. Verifying the transaction\n+  3. Sign the transaction ourselves\n+  4. Gather the acceptor's signature\n+  5. Get the transaction notarised, to protect against double-spends","path":"docs/source/hello-world-flow.rst","position":135,"original_position":135,"commit_id":"e9b1f8f27d2de39f9c586802bce6dee45aa50366","original_commit_id":"e9b1f8f27d2de39f9c586802bce6dee45aa50366","user":{"login":"roger3cev","id":22620030,"avatar_url":"https://avatars2.githubusercontent.com/u/22620030?v=3","gravatar_id":"","url":"https://api.github.com/users/roger3cev","html_url":"https://github.com/roger3cev","followers_url":"https://api.github.com/users/roger3cev/followers","following_url":"https://api.github.com/users/roger3cev/following{/other_user}","gists_url":"https://api.github.com/users/roger3cev/gists{/gist_id}","starred_url":"https://api.github.com/users/roger3cev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roger3cev/subscriptions","organizations_url":"https://api.github.com/users/roger3cev/orgs","repos_url":"https://api.github.com/users/roger3cev/repos","events_url":"https://api.github.com/users/roger3cev/events{/privacy}","received_events_url":"https://api.github.com/users/roger3cev/received_events","type":"User","site_admin":false},"body":"do we need to do this for an issuance with no timewindow? perhaps we can say potentially you need to do this","created_at":"2017-06-16T08:27:35Z","updated_at":"2017-06-16T08:53:32Z","html_url":"https://github.com/corda/corda/pull/848#discussion_r122390010","pull_request_url":"https://api.github.com/repos/corda/corda/pulls/848","_links":{"self":{"href":"https://api.github.com/repos/corda/corda/pulls/comments/122390010"},"html":{"href":"https://github.com/corda/corda/pull/848#discussion_r122390010"},"pull_request":{"href":"https://api.github.com/repos/corda/corda/pulls/848"}}},"pull_request":{"url":"https://api.github.com/repos/corda/corda/pulls/848","id":125799017,"html_url":"https://github.com/corda/corda/pull/848","diff_url":"https://github.com/corda/corda/pull/848.diff","patch_url":"https://github.com/corda/corda/pull/848.patch","issue_url":"https://api.github.com/repos/corda/corda/issues/848","number":848,"state":"open","locked":false,"title":"Hello, World! CorDapp tutorial","user":{"login":"joeldudleyr3","id":24230167,"avatar_url":"https://avatars3.githubusercontent.com/u/24230167?v=3","gravatar_id":"","url":"https://api.github.com/users/joeldudleyr3","html_url":"https://github.com/joeldudleyr3","followers_url":"https://api.github.com/users/joeldudleyr3/followers","following_url":"https://api.github.com/users/joeldudleyr3/following{/other_user}","gists_url":"https://api.github.com/users/joeldudleyr3/gists{/gist_id}","starred_url":"https://api.github.com/users/joeldudleyr3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeldudleyr3/subscriptions","organizations_url":"https://api.github.com/users/joeldudleyr3/orgs","repos_url":"https://api.github.com/users/joeldudleyr3/repos","events_url":"https://api.github.com/users/joeldudleyr3/events{/privacy}","received_events_url":"https://api.github.com/users/joeldudleyr3/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-06-15T11:19:55Z","updated_at":"2017-06-16T08:53:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6c25d4d35bdb88ecadfba122718faa8eac087d8e","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/corda/corda/pulls/848/commits","review_comments_url":"https://api.github.com/repos/corda/corda/pulls/848/comments","review_comment_url":"https://api.github.com/repos/corda/corda/pulls/comments{/number}","comments_url":"https://api.github.com/repos/corda/corda/issues/848/comments","statuses_url":"https://api.github.com/repos/corda/corda/statuses/e9b1f8f27d2de39f9c586802bce6dee45aa50366","head":{"label":"corda:joel-tut","ref":"joel-tut","sha":"e9b1f8f27d2de39f9c586802bce6dee45aa50366","user":{"login":"corda","id":22600631,"avatar_url":"https://avatars2.githubusercontent.com/u/22600631?v=3","gravatar_id":"","url":"https://api.github.com/users/corda","html_url":"https://github.com/corda","followers_url":"https://api.github.com/users/corda/followers","following_url":"https://api.github.com/users/corda/following{/other_user}","gists_url":"https://api.github.com/users/corda/gists{/gist_id}","starred_url":"https://api.github.com/users/corda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corda/subscriptions","organizations_url":"https://api.github.com/users/corda/orgs","repos_url":"https://api.github.com/users/corda/repos","events_url":"https://api.github.com/users/corda/events{/privacy}","received_events_url":"https://api.github.com/users/corda/received_events","type":"Organization","site_admin":false},"repo":{"id":70137417,"name":"corda","full_name":"corda/corda","owner":{"login":"corda","id":22600631,"avatar_url":"https://avatars2.githubusercontent.com/u/22600631?v=3","gravatar_id":"","url":"https://api.github.com/users/corda","html_url":"https://github.com/corda","followers_url":"https://api.github.com/users/corda/followers","following_url":"https://api.github.com/users/corda/following{/other_user}","gists_url":"https://api.github.com/users/corda/gists{/gist_id}","starred_url":"https://api.github.com/users/corda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corda/subscriptions","organizations_url":"https://api.github.com/users/corda/orgs","repos_url":"https://api.github.com/users/corda/repos","events_url":"https://api.github.com/users/corda/events{/privacy}","received_events_url":"https://api.github.com/users/corda/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/corda/corda","description":"Corda is a distributed ledger platform designed to record, manage and automate legal agreements between business partners. Designed by (and for) the world's largest financial institutions, it offers a unique response to the privacy and scalability challenges facing decentralised applications.","fork":false,"url":"https://api.github.com/repos/corda/corda","forks_url":"https://api.github.com/repos/corda/corda/forks","keys_url":"https://api.github.com/repos/corda/corda/keys{/key_id}","collaborators_url":"https://api.github.com/repos/corda/corda/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/corda/corda/teams","hooks_url":"https://api.github.com/repos/corda/corda/hooks","issue_events_url":"https://api.github.com/repos/corda/corda/issues/events{/number}","events_url":"https://api.github.com/repos/corda/corda/events","assignees_url":"https://api.github.com/repos/corda/corda/assignees{/user}","branches_url":"https://api.github.com/repos/corda/corda/branches{/branch}","tags_url":"https://api.github.com/repos/corda/corda/tags","blobs_url":"https://api.github.com/repos/corda/corda/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/corda/corda/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/corda/corda/git/refs{/sha}","trees_url":"https://api.github.com/repos/corda/corda/git/trees{/sha}","statuses_url":"https://api.github.com/repos/corda/corda/statuses/{sha}","languages_url":"https://api.github.com/repos/corda/corda/languages","stargazers_url":"https://api.github.com/repos/corda/corda/stargazers","contributors_url":"https://api.github.com/repos/corda/corda/contributors","subscribers_url":"https://api.github.com/repos/corda/corda/subscribers","subscription_url":"https://api.github.com/repos/corda/corda/subscription","commits_url":"https://api.github.com/repos/corda/corda/commits{/sha}","git_commits_url":"https://api.github.com/repos/corda/corda/git/commits{/sha}","comments_url":"https://api.github.com/repos/corda/corda/comments{/number}","issue_comment_url":"https://api.github.com/repos/corda/corda/issues/comments{/number}","contents_url":"https://api.github.com/repos/corda/corda/contents/{+path}","compare_url":"https://api.github.com/repos/corda/corda/compare/{base}...{head}","merges_url":"https://api.github.com/repos/corda/corda/merges","archive_url":"https://api.github.com/repos/corda/corda/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/corda/corda/downloads","issues_url":"https://api.github.com/repos/corda/corda/issues{/number}","pulls_url":"https://api.github.com/repos/corda/corda/pulls{/number}","milestones_url":"https://api.github.com/repos/corda/corda/milestones{/number}","notifications_url":"https://api.github.com/repos/corda/corda/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/corda/corda/labels{/name}","releases_url":"https://api.github.com/repos/corda/corda/releases{/id}","deployments_url":"https://api.github.com/repos/corda/corda/deployments","created_at":"2016-10-06T08:46:29Z","updated_at":"2017-06-15T19:50:57Z","pushed_at":"2017-06-16T08:06:01Z","git_url":"git://github.com/corda/corda.git","ssh_url":"git@github.com:corda/corda.git","clone_url":"https://github.com/corda/corda.git","svn_url":"https://github.com/corda/corda","homepage":"https://www.corda.net","size":88453,"stargazers_count":745,"watchers_count":745,"language":"Kotlin","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":217,"mirror_url":null,"open_issues_count":63,"forks":217,"open_issues":63,"watchers":745,"default_branch":"master"}},"base":{"label":"corda:master","ref":"master","sha":"b52d3706ebbc615ecd85504ed63effeff2d20f71","user":{"login":"corda","id":22600631,"avatar_url":"https://avatars2.githubusercontent.com/u/22600631?v=3","gravatar_id":"","url":"https://api.github.com/users/corda","html_url":"https://github.com/corda","followers_url":"https://api.github.com/users/corda/followers","following_url":"https://api.github.com/users/corda/following{/other_user}","gists_url":"https://api.github.com/users/corda/gists{/gist_id}","starred_url":"https://api.github.com/users/corda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corda/subscriptions","organizations_url":"https://api.github.com/users/corda/orgs","repos_url":"https://api.github.com/users/corda/repos","events_url":"https://api.github.com/users/corda/events{/privacy}","received_events_url":"https://api.github.com/users/corda/received_events","type":"Organization","site_admin":false},"repo":{"id":70137417,"name":"corda","full_name":"corda/corda","owner":{"login":"corda","id":22600631,"avatar_url":"https://avatars2.githubusercontent.com/u/22600631?v=3","gravatar_id":"","url":"https://api.github.com/users/corda","html_url":"https://github.com/corda","followers_url":"https://api.github.com/users/corda/followers","following_url":"https://api.github.com/users/corda/following{/other_user}","gists_url":"https://api.github.com/users/corda/gists{/gist_id}","starred_url":"https://api.github.com/users/corda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corda/subscriptions","organizations_url":"https://api.github.com/users/corda/orgs","repos_url":"https://api.github.com/users/corda/repos","events_url":"https://api.github.com/users/corda/events{/privacy}","received_events_url":"https://api.github.com/users/corda/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/corda/corda","description":"Corda is a distributed ledger platform designed to record, manage and automate legal agreements between business partners. Designed by (and for) the world's largest financial institutions, it offers a unique response to the privacy and scalability challenges facing decentralised applications.","fork":false,"url":"https://api.github.com/repos/corda/corda","forks_url":"https://api.github.com/repos/corda/corda/forks","keys_url":"https://api.github.com/repos/corda/corda/keys{/key_id}","collaborators_url":"https://api.github.com/repos/corda/corda/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/corda/corda/teams","hooks_url":"https://api.github.com/repos/corda/corda/hooks","issue_events_url":"https://api.github.com/repos/corda/corda/issues/events{/number}","events_url":"https://api.github.com/repos/corda/corda/events","assignees_url":"https://api.github.com/repos/corda/corda/assignees{/user}","branches_url":"https://api.github.com/repos/corda/corda/branches{/branch}","tags_url":"https://api.github.com/repos/corda/corda/tags","blobs_url":"https://api.github.com/repos/corda/corda/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/corda/corda/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/corda/corda/git/refs{/sha}","trees_url":"https://api.github.com/repos/corda/corda/git/trees{/sha}","statuses_url":"https://api.github.com/repos/corda/corda/statuses/{sha}","languages_url":"https://api.github.com/repos/corda/corda/languages","stargazers_url":"https://api.github.com/repos/corda/corda/stargazers","contributors_url":"https://api.github.com/repos/corda/corda/contributors","subscribers_url":"https://api.github.com/repos/corda/corda/subscribers","subscription_url":"https://api.github.com/repos/corda/corda/subscription","commits_url":"https://api.github.com/repos/corda/corda/commits{/sha}","git_commits_url":"https://api.github.com/repos/corda/corda/git/commits{/sha}","comments_url":"https://api.github.com/repos/corda/corda/comments{/number}","issue_comment_url":"https://api.github.com/repos/corda/corda/issues/comments{/number}","contents_url":"https://api.github.com/repos/corda/corda/contents/{+path}","compare_url":"https://api.github.com/repos/corda/corda/compare/{base}...{head}","merges_url":"https://api.github.com/repos/corda/corda/merges","archive_url":"https://api.github.com/repos/corda/corda/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/corda/corda/downloads","issues_url":"https://api.github.com/repos/corda/corda/issues{/number}","pulls_url":"https://api.github.com/repos/corda/corda/pulls{/number}","milestones_url":"https://api.github.com/repos/corda/corda/milestones{/number}","notifications_url":"https://api.github.com/repos/corda/corda/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/corda/corda/labels{/name}","releases_url":"https://api.github.com/repos/corda/corda/releases{/id}","deployments_url":"https://api.github.com/repos/corda/corda/deployments","created_at":"2016-10-06T08:46:29Z","updated_at":"2017-06-15T19:50:57Z","pushed_at":"2017-06-16T08:06:01Z","git_url":"git://github.com/corda/corda.git","ssh_url":"git@github.com:corda/corda.git","clone_url":"https://github.com/corda/corda.git","svn_url":"https://github.com/corda/corda","homepage":"https://www.corda.net","size":88453,"stargazers_count":745,"watchers_count":745,"language":"Kotlin","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":217,"mirror_url":null,"open_issues_count":63,"forks":217,"open_issues":63,"watchers":745,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/corda/corda/pulls/848"},"html":{"href":"https://github.com/corda/corda/pull/848"},"issue":{"href":"https://api.github.com/repos/corda/corda/issues/848"},"comments":{"href":"https://api.github.com/repos/corda/corda/issues/848/comments"},"review_comments":{"href":"https://api.github.com/repos/corda/corda/pulls/848/comments"},"review_comment":{"href":"https://api.github.com/repos/corda/corda/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/corda/corda/pulls/848/commits"},"statuses":{"href":"https://api.github.com/repos/corda/corda/statuses/e9b1f8f27d2de39f9c586802bce6dee45aa50366"}}}}
{"actor":{"display_login":"roger3cev"}}