Corda에서 특정 노드 시작

2020/09/30 추가



RPC의 페이지가 404가 되어 있었으므로, 링크의 재붙여를 실시.

본편



도, 노부 코후입니다.
이번 기사는 라이트에, 특정 노드의 기동 방법에 대해 기술합니다.

「Corda란」「Corda의 인스톨・셋업」등에 대해서는 생략하겠습니다.

특정 노드 시작



공식 문서는 이 페이지의 내용입니다.

확인하겠습니다.
$ pwd
/cordapp-template-kotlin
$ ll
total 88
-rw-r--r--  1 nobkovskii  staff   579  6 13 16:32 LICENCE
-rw-r--r--  1 nobkovskii  staff  4798  6 13 16:32 README.md
-rw-r--r--  1 nobkovskii  staff   232  6 13 16:32 TRADEMARK
drwxr-xr-x  7 nobkovskii  staff   224  6 27 12:08 build
-rw-r--r--  1 nobkovskii  staff  4289  6 27 12:07 build.gradle
drwxr-xr-x  5 nobkovskii  staff   160  6 27 12:07 clients
drwxr-xr-x  4 nobkovskii  staff   128  6 13 16:32 config
drwxr-xr-x  5 nobkovskii  staff   160  6 27 12:07 contracts
drwxr-xr-x  3 nobkovskii  staff    96  6 13 16:32 gradle
-rw-r--r--  1 nobkovskii  staff    65  6 13 16:32 gradle.properties
-rwxr-xr-x  1 nobkovskii  staff  5296  6 13 16:32 gradlew
-rw-r--r--  1 nobkovskii  staff  2176  6 13 16:32 gradlew.bat
drwxr-xr-x  3 nobkovskii  staff    96  6 13 16:34 logs
-rw-r--r--  1 nobkovskii  staff    57  6 13 16:32 settings.gradle
drwxr-xr-x  5 nobkovskii  staff   160  6 27 12:07 workflows

노드를 배포하겠습니다.
$ ./gradlew clean deployNodes
〜〜〜〜〜〜〜 諸々 〜〜〜〜〜〜〜〜〜〜
BUILD SUCCESSFUL in 40s
18 actionable tasks: 17 executed, 1 up-to-date

시작하려는 노드의 디렉토리로 이동합니다.
$ cd build/nodes/PartyA/
$ ll
total 130784
drwxr-xr-x  6 nobkovskii  staff       192  6 27 12:25 additional-node-infos
drwxr-xr-x  5 nobkovskii  staff       160  6 27 12:25 certificates
-rwxr-xr-x  1 nobkovskii  staff  63718634  6 27 12:25 corda.jar
drwxr-xr-x  5 nobkovskii  staff       160  6 27 12:25 cordapps
drwxr-xr-x  3 nobkovskii  staff        96  6 27 12:25 drivers
drwxr-xr-x  4 nobkovskii  staff       128  6 27 12:25 logs
-rw-r--r--  1 nobkovskii  staff      4498  6 27 12:25 network-parameters
-rw-r--r--  1 nobkovskii  staff       474  6 27 12:25 node.conf
-rw-r--r--  1 nobkovskii  staff      4689  6 27 12:25 nodeInfo-E4477B559304AADFC0638772C0956A38FA2E2A7A5EB0E65D0D83E5884831879A
-rw-r--r--  1 nobkovskii  staff   2560000  6 27 12:25 persistence.mv.db
-rw-r--r--  1 nobkovskii  staff      8021  6 27 12:25 persistence.trace.db

노드를 시작합니다.
$ java -jar corda.jar 

   ______               __
  / ____/     _________/ /___ _
 / /     __  / ___/ __  / __ `/         Kind of like a regular database but
/ /___  /_/ / /  / /_/ / /_/ /          with emojis, colours and ascii art. 😎  
\____/     /_/   \__,_/\__,_/

--- Corda Open Source 4.0 (503a2ff) -------------------------------------------------------------


Logs can be found in                    : /cordapp-template-kotlin/build/nodes/PartyA/logs
⚠️   ATTENTION: This node is running in development mode! 👩‍💻   This is not safe for production deployment.
Advertised P2P messaging addresses      : localhost:10005
RPC connection address                  : localhost:10006
RPC admin connection address            : localhost:10046
Loaded 2 CorDapp(s)                     : Contract CorDapp: Template CorDapp version 1 by vendor Corda Open Source with licence Apache License, Version 2.0, Workflow CorDapp: Template Flows version 1 by vendor Corda Open Source with licence Apache License, Version 2.0
Node for "PartyA" started up and registered in 8.82 sec


Welcome to the Corda interactive shell.
Useful commands include 'help' to see what is available, and 'bye' to shut down the node.

Thu Jun 27 12:29:33 JST 2019>>>  

특정 노드의 시작은 이상입니다.

노드에서 여러 가지 시도



RPC를 사용하여 노드를 쿼리할 수 있습니다.
제공된 함수 목록은 이 페이지에 있습니다.

노드 쉘의 예입니다.
>>> help
Try one of these commands with the -h or --help switch:                                                                                                   

NAME          DESCRIPTION                                                                                                                                 
bye           Exits, same as exit.                                                                                                                        
dashboard     a monitoring dashboard                                                                                                                      
egrep         search file(s) for lines that match a pattern                                                                                               
env           display the term env                                                                                                                        
exit          Exits.                                                                                                                                      
filter        a filter for a stream of map                                                                                                                
flow          Commands to work with flows. Flows are how you can change the ledger.                                                                       
hashLookup    Checks if a transaction with matching Id hash exists.                                                                                       
help          provides basic help                                                                                                                         
java          various java language commands                                                                                                              
jdbc          JDBC connection                                                                                                                             
jndi          Java Naming and Directory Interface                                                                                                         
jpa           Java persistance API                                                                                                                        
jul           java.util.logging commands                                                                                                                  
jvm           JVM information                                                                                                                             
less          opposite of more                                                                                                                            
man           format and display the on-line manual pages                                                                                                 
output-format Commands to inspect and update the output format.                                                                                           
repl          list the repl or change the current repl                                                                                                    
run           Runs a method from the CordaRPCOps interface on the node.                                                                                   
shell         shell related command                                                                                                                       
sleep         sleep for some time                                                                                                                         
sort          sort a map                                                                                                                                  
start         An alias for 'flow start'                                                                                                                   
system        vm system properties commands                                                                                                               
thread        JVM thread commands                 

>>> flow list
com.template.flows.Hoge
com.template.flows.Initiator
net.corda.core.flows.ContractUpgradeFlow$Authorise
net.corda.core.flows.ContractUpgradeFlow$Deauthorise
net.corda.core.flows.ContractUpgradeFlow$Initiate

>>> run vaultQuery contractStateType: com.template.states.TemplateState                                   
states: []
statesMetadata: []
totalStatesAvailable: -1
stateTypes: "UNCONSUMED"
otherResults: []

>>> run networkMapSnapshot
- addresses:
  - "localhost:10005"
  legalIdentitiesAndCerts:
  - "O=PartyA, L=London, C=GB"
  platformVersion: 4
  serial: 1561605953758
- addresses:
  - "localhost:10002"
  legalIdentitiesAndCerts:
  - "O=Notary, L=London, C=GB"
  platformVersion: 4
  serial: 1561605950491
- addresses:
  - "localhost:10011"
  legalIdentitiesAndCerts:
  - "O=PartyC, L=Tokyo, C=JP"
  platformVersion: 4
  serial: 1561605953606
- addresses:
  - "localhost:10008"
  legalIdentitiesAndCerts:
  - "O=PartyB, L=New York, C=US"
  platformVersion: 4
  serial: 1561605953669

>>> run nodeInfoFromParty party : "PartyA"
addresses:
- "localhost:10005"
legalIdentitiesAndCerts:
- "O=PartyA, L=London, C=GB"
platformVersion: 4
serial: 1561605953758

>>> run wellKnownPartyFromAnonymous party : "Notary"                   
"O=Notary, L=London, C=GB"


위의 방법으로 여러 노드를 시작하고 IOU를 발행합니다.



조금 보기 힘들지만, 다른 터미널에서 PartyA와 PartyB를 위의 방법으로 시작해 보겠습니다.
※실행하고 있는 Flow는 전전 전회당의 「Corda-Tutorial_HelloWorld pt2」를 참조해 주세요

여러 노드를 시작하고 flow_watch를 확인하십시오.
+--------+--------------------
| PartyA |
+--------+
$ java -jar corda.jar 
+--------+--------------------
| PartyB |
+--------+
$ java -jar corda.jar 
>>> flow watch
+--------+--------------------
| PartyA |
+--------+
>>>  flow start Hoge value : 100 , otherParty : "PartyB"

 ✅   Starting
          Requesting signature by notary service
              Requesting signature by Notary service
              Validating response from Notary service
     ✅   Broadcasting transaction to participants
➡️   Done
Flow completed with result: kotlin.Unit
+--------+--------------------
| PartyB |
+--------+
Id               Flow name                        Initiator       Status                           
---------------------------------------------------------------------------------------------------
5e32759a-0d9c-44 Foo                              O=PartyA, L=Lon In progress                      
499d4584-090a-43 Foo                              O=PartyA, L=Lon In progress                      
b3699c03-4b17-4c Foo                              O=PartyA, L=Lon No return value                  
Waiting for completion or Ctrl-C ... 

+--------+
| Ctrl-C |
+--------+

>>> run vaultQuery contractStateType: com.template.states.MyState 
states:
- state:
    data: !<com.template.states.MyState>
      value: 100
      lender: "O=PartyA, L=London, C=GB"
      borrower: "O=PartyB, L=New York, C=US"
    contract: "com.template.contracts.MyContract"
    notary: "O=Notary, L=London, C=GB"
    encumbrance: null
    constraint: !<net.corda.core.contracts.SignatureAttachmentConstraint>
      key: "aSq9DsNNvGhYxYyqA9wd2eduEAZ5AXWgJTbTEw3G5d2maAq8vtLE4kZHgCs5jcB1N31cx1hpsLeqG2ngSysVHqcXhbNts6SkRWDaV7xNcr6MtcbufGUchxredBb6"
  ref:
    txhash: "D62E4C3B6D52113A6103E796558468C07684A37C316AC2629A2344D7F37CDE85"
    index: 0


다른 탭 실행의 이미지↓




게다가 Corda의 사용법을 알았습니다.
슬슬, 좀 더 유스 케이스에 따라 실장해 가고 싶은 오늘 요즘.

이번은 이상입니다.
고마워요.

좋은 웹페이지 즐겨찾기