Quorum网络启动

第一步:kill冲突进程

yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ su root
密码: 
root@yanhao-ThinkPad-T480:/home/yanhao/quorum/fromscratch-again# netstat -nap|grep 22001
tcp6       0      0 :::22001                :::*                    LISTEN      3155/docker-proxy   
root@yanhao-ThinkPad-T480:/home/yanhao/quorum/fromscratch-again# netstat -nap|grep 22000
tcp6       0      0 :::22000                :::*                    LISTEN      2693/docker-proxy   
root@yanhao-ThinkPad-T480:/home/yanhao/quorum/fromscratch-again# kill 2693
root@yanhao-ThinkPad-T480:/home/yanhao/quorum/fromscratch-again# kill 3155

第二步:启动本地两个Tessera节点

yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cd new-node-1t
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ ls
config.json  db1.trace.db    new-node-1.pub
db1.mv.db    new-node-1.key  tessera.log
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ java -jar ../tessera.jar -configfile config.json >> tessera.log 2>&1 &
[1] 30584
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ cd ../new-node-2t
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ java -jar ../tessera.jar -configfile config.json >> tessera.log 2>&1 &
[2] 31600
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ ps
  PID TTY          TIME CMD
10805 pts/0    00:00:00 bash
30584 pts/0    00:00:21 java
31600 pts/0    00:00:22 java
32005 pts/0    00:00:00 ps

第三步:启动两个本地节点

yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ cd ..
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ps
  PID TTY          TIME CMD
  356 pts/0    00:00:00 geth
  481 pts/0    00:00:00 geth
  595 pts/0    00:00:00 ps
10805 pts/0    00:00:00 bash
30584 pts/0    00:00:23 java
31600 pts/0    00:00:29 java

(第四步可以是:连接到其中某个节点并部署合约,以节点1为例)

yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-1/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
coinbase: 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
 datadir: /home/yanhao/quorum/fromscratch-again/new-node-1
 modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 quorumExtension:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0

> eth.accounts
["0x03af8e050a5f40aec7a16eefefd9082aa89c038a", "0xe754b58a7147619d70b49dded8bddfb2b66366b4"]

>  personal.unlockAccount(eth.accounts[0])
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password: 
true

> loadScript('private-contract.js')
Contract transaction send: TransactionHash: 0x289cfde30f057b6d6cb24570d54a225227464d51cb5eb1f6d01c6daa36d63e6c waiting to be mined...
true
> Contract mined! Address: 0x701118c5f2a39db8e05d32c5bfb269cb0bb787b9
[object Object]

(然后在节点2中调用合约函数)

yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-2/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
at block: 2 (Fri, 18 Sep 2020 14:44:42 CST)
 datadir: /home/yanhao/quorum/fromscratch-again/new-node-2
 modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 quorumExtension:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0

> var abi=[{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initVal","type":"uint256"}],"payable":false,"type":"constructor"}];
undefined
> var address="0x701118c5f2a39db8e05d32c5bfb269cb0bb787b9";
undefined
> var contract=eth.contract(abi).at(address);
undefined
> contract.get()
42
> 

上述脚本(private-contract.js)在节点1上部署了一个简单的状态值为42的存储合约,交易是节点1和节点2之间私有的,这意味着其他节点将看不到这个状态值。
所以,进入节点2的geth终端,使用ABI和合约地址创建合约实例,然后尝试读取状态值,可以得到42(如上)。

第四步:启动cakeshop

$ cd new-node-1
$ CAKESHOP_SHARED_CONFIG="../contractregistry" java -Dserver.port=8080 -jar ../../cakeshop.war
-//进入节点 2 目录
$ cd new-node-2
$ CAKESHOP_SHARED_CONFIG="../contractregistry" java -Dserver.port=8081 -jar ../../cakeshop.war

(密码yanhao12)

第五步:安装atom

参考:Ubuntu 18.04 中安装 Atom 代码编辑器

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值