* commit '61ad0cd7bf5dd3d69e5c6b4cf358f1f08f651de4': gateway upgraded submodules; upgraded submodules; upgraded submodules and fixed bugs; upgraded submodules; refactored BlockchainQueryService; upgraded utils; update samples upgraded core module; upgraded explorer and utils;tags/1.5.0
@@ -1,6 +1,7 @@ | |||||
package com.jd.blockchain.gateway.boot; | package com.jd.blockchain.gateway.boot; | ||||
import com.jd.blockchain.gateway.GatewayServerBooter; | import com.jd.blockchain.gateway.GatewayServerBooter; | ||||
import utils.ConsoleUtils; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
@@ -17,7 +18,7 @@ public class GatewayBooter { | |||||
try { | try { | ||||
GatewayServerBooter.main(args); | GatewayServerBooter.main(args); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
System.err.println("Error!!! --[" + e.getClass().getName() + "] " + e.getMessage()); | |||||
ConsoleUtils.error("Gateway start error!", e); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -12,6 +12,9 @@ peer.port=7080 | |||||
#共识节点的服务是否启用安全证书; | #共识节点的服务是否启用安全证书; | ||||
peer.secure=false | peer.secure=false | ||||
#账本节点拓扑信息落盘,默认false | |||||
topology.store=false | |||||
#共识节点的服务提供解析器 | #共识节点的服务提供解析器 | ||||
#BftSmart共识Provider:com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider | #BftSmart共识Provider:com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider | ||||
#简单消息共识Provider:com.jd.blockchain.consensus.mq.MsgQueueConsensusProvider | #简单消息共识Provider:com.jd.blockchain.consensus.mq.MsgQueueConsensusProvider | ||||
@@ -30,7 +30,7 @@ | |||||
<logger name="org.springframework" level="error"></logger> | <logger name="org.springframework" level="error"></logger> | ||||
<logger name="bftsmart" level="error"></logger> | <logger name="bftsmart" level="error"></logger> | ||||
<!--修改此处,以变更日志等级--> | <!--修改此处,以变更日志等级--> | ||||
<root level="info"> | |||||
<root level="all"> | |||||
<appender-ref ref="Console"/> | <appender-ref ref="Console"/> | ||||
<appender-ref ref="GWRolling"/> | <appender-ref ref="GWRolling"/> | ||||
<appender-ref ref="GWRollingError"/> | <appender-ref ref="GWRollingError"/> | ||||
@@ -11,6 +11,7 @@ import java.lang.reflect.InvocationTargetException; | |||||
import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
import java.nio.charset.StandardCharsets; | import java.nio.charset.StandardCharsets; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Arrays; | |||||
import java.util.Date; | import java.util.Date; | ||||
import java.util.List; | import java.util.List; | ||||
@@ -36,7 +37,7 @@ public class PeerBooter { | |||||
HomeContext homeContext = HomeBooter.createHomeContext(args); | HomeContext homeContext = HomeBooter.createHomeContext(args); | ||||
startPeer(homeContext); | startPeer(homeContext); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
System.err.println("Error!!! --[" + e.getClass().getName() + "] " + e.getMessage()); | |||||
e.printStackTrace(); | |||||
} | } | ||||
} | } | ||||
@@ -30,7 +30,7 @@ | |||||
<logger name="org.springframework" level="error"></logger> | <logger name="org.springframework" level="error"></logger> | ||||
<logger name="bftsmart" level="error"></logger> | <logger name="bftsmart" level="error"></logger> | ||||
<!--修改此处,以变更日志等级--> | <!--修改此处,以变更日志等级--> | ||||
<root level="info"> | |||||
<root level="all"> | |||||
<appender-ref ref="Console"/> | <appender-ref ref="Console"/> | ||||
<appender-ref ref="PeerRolling"/> | <appender-ref ref="PeerRolling"/> | ||||
<appender-ref ref="PeerRollingError"/> | <appender-ref ref="PeerRollingError"/> | ||||
@@ -2,7 +2,7 @@ | |||||
本项目为`JD Chain SDK`的使用样例,开发者可以参考此项目快速上手`JD Chain SDK`,主要包括[交易发送查询](#交易发送查询),[合约开发部署](#合约开发部署)两部分。 | 本项目为`JD Chain SDK`的使用样例,开发者可以参考此项目快速上手`JD Chain SDK`,主要包括[交易发送查询](#交易发送查询),[合约开发部署](#合约开发部署)两部分。 | ||||
本项目提供了基于内存的`JD Chain`四节点+网关的网络环境启动程序[TestNet](/sdk-samples/src/main/java/com/jdchain/samples/sdk/TestNet.java),运行`TestNet`的`main`方法启动测试网络,等待日志输出:`START TESTNET SUCCESS`,网络启动成功会写入一些测试数据,可直接运行本项目提供的所有测试用例。 | |||||
本项目提供了基于内存的`JD Chain`四节点+网关的网络环境启动程序[TestNet](sdk-samples/src/main/java/com/jdchain/samples/sdk/TestNet.java),运行`TestNet`的`main`方法启动测试网络,等待日志输出:`START TESTNET SUCCESS`,网络启动成功会写入一些测试数据,可直接运行本项目提供的所有测试用例。 | |||||
> `TestNet`测试网络默认会占用`8910`/`8920`/`8930`/`8940`/`8911`/`8921`/`8931`/`8941`用于共识服务,`12000`/`12010`/`12020`/`12030`用于四节点`API`服务端口,`11000`用于网关`API`服务端口,启动前请检查相关端口可用。 | > `TestNet`测试网络默认会占用`8910`/`8920`/`8930`/`8940`/`8911`/`8921`/`8931`/`8941`用于共识服务,`12000`/`12010`/`12020`/`12030`用于四节点`API`服务端口,`11000`用于网关`API`服务端口,启动前请检查相关端口可用。 | ||||
@@ -10,31 +10,31 @@ | |||||
### 交易发送查询 | ### 交易发送查询 | ||||
相关代码放在[sdk-sample](/sdk-samples/src)下。 | |||||
相关代码放在[sdk-sample](sdk-samples/src)下。 | |||||
> 若并非使用`TestNet`启动的测试网络,开发者在运行本样例前,请根据实际环境修改[config.properties](/sdk-samples/src/main/resources/config.properties)中的网关配置,用户配置等信息。 | |||||
> 若并非使用`TestNet`启动的测试网络,开发者在运行本样例前,请根据实际环境修改[config.properties](sdk-samples/src/main/resources/config.properties)中的网关配置,用户配置等信息。 | |||||
#### 交易发送 | #### 交易发送 | ||||
参照[UserSample](/sdk-samples/src/test/java/com/jdchain/samples/sdk/UserSample.java)实现注册用户,配置用户角色权限功能; | |||||
参照[UserSample](sdk-samples/src/test/java/com/jdchain/samples/sdk/UserSample.java)实现注册用户,配置用户角色权限功能; | |||||
参照[DataAccountSample](/sdk-samples/src/test/java/com/jdchain/samples/sdk/DataAccountSample.java)实现注册数据账户,存储`KV`数据功能; | |||||
参照[DataAccountSample](sdk-samples/src/test/java/com/jdchain/samples/sdk/DataAccountSample.java)实现注册数据账户,存储`KV`数据功能; | |||||
参照[EventSample](/sdk-samples/src/test/java/com/jdchain/samples/sdk/EventSample.java)实现注册事件账户,发布事件,事件监听功能; | |||||
参照[EventSample](sdk-samples/src/test/java/com/jdchain/samples/sdk/EventSample.java)实现注册事件账户,发布事件,事件监听功能; | |||||
参照[ContractSample](/sdk-samples/src/test/java/com/jdchain/samples/sdk/ContractSample.java)实现合约调用,非插件方式合约部署功能。 | |||||
参照[ContractSample](sdk-samples/src/test/java/com/jdchain/samples/sdk/ContractSample.java)实现合约调用,非插件方式合约部署功能。 | |||||
#### 数据查询 | #### 数据查询 | ||||
参照[QuerySample](/sdk-samples/src/test/java/com/jdchain/samples/sdk/QuerySample.java)实现对于区块链上数据查询功能。 | |||||
参照[QuerySample](sdk-samples/src/test/java/com/jdchain/samples/sdk/QuerySample.java)实现对于区块链上数据查询功能。 | |||||
### 合约开发部署 | ### 合约开发部署 | ||||
[contract-samples](/contract-samples/src)提供了通过合约注册用户,注册数据账户,注册事件账户,设置`KV`,发布事件的简单合约样例。 | |||||
[contract-samples](contract-samples/src)提供了通过合约注册用户,注册数据账户,注册事件账户,设置`KV`,发布事件的简单合约样例。 | |||||
> 若并非使用`TestNet`启动的测试网络,开发者在运行本样例前,请根据实际环境修改[pom.xml](/contract-samples/pom.xml)中的网关配置,用户配置等信息。 | |||||
> 若并非使用`TestNet`启动的测试网络,开发者在运行本样例前,请根据实际环境修改[pom.xml](contract-samples/pom.xml)中的网关配置,用户配置等信息。 | |||||
修改相关代码,确认配置正确,`contract-samples`项目目录下命令行执行: | 修改相关代码,确认配置正确,`contract-samples`项目目录下命令行执行: | ||||
@@ -27,7 +27,10 @@ public class SampleContractImpl implements EventProcessingAware, SampleContract | |||||
@Override | @Override | ||||
public void setKV(String address, String key, String value) { | public void setKV(String address, String key, String value) { | ||||
// 查询最新版本,初始为-1 | // 查询最新版本,初始为-1 | ||||
TypedKVEntry[] entries = eventContext.getLedger().getDataEntries(eventContext.getCurrentLedgerHash(), address, key); | |||||
// 查询已提交区块数据,不包括此操作所在未提交区块的所有数据 | |||||
// TypedKVEntry[] entries = eventContext.getLedger().getDataEntries(eventContext.getCurrentLedgerHash(), address, key); | |||||
// 可查询包括此操作所在未提交区块的所有数据 | |||||
TypedKVEntry[] entries = eventContext.getUncommittedLedger().getDataEntries(address, key); | |||||
long version = -1; | long version = -1; | ||||
if (null != entries && entries.length > 0) { | if (null != entries && entries.length > 0) { | ||||
version = entries[0].getVersion(); | version = entries[0].getVersion(); | ||||
@@ -76,7 +79,10 @@ public class SampleContractImpl implements EventProcessingAware, SampleContract | |||||
@Override | @Override | ||||
public void publishEvent(String address, String topic, String content) { | public void publishEvent(String address, String topic, String content) { | ||||
// 查询最新序号,初始为-1 | // 查询最新序号,初始为-1 | ||||
Event event = eventContext.getLedger().getLatestEvent(eventContext.getCurrentLedgerHash(), address, topic); | |||||
// 查询已提交区块数据,不包括此操作所在未提交区块的所有数据 | |||||
// Event event = eventContext.getLedger().getRuntimeLedger().getLatestEvent(address, topic); | |||||
// 可查询包括此操作所在未提交区块的所有数据 | |||||
Event event = eventContext.getUncommittedLedger().getLatestEvent(address, topic); | |||||
long sequence = -1; | long sequence = -1; | ||||
if (null != event) { | if (null != event) { | ||||
sequence = event.getSequence(); | sequence = event.getSequence(); | ||||
@@ -95,6 +95,9 @@ public class TestNet { | |||||
// 启动网关 | // 启动网关 | ||||
startGateway(peerNodes); | startGateway(peerNodes); | ||||
// 睡10秒,等待网关启动成功 | |||||
Thread.sleep(10000); | |||||
// 初始化样例数据 | // 初始化样例数据 | ||||
initSampleData(ledgerHash); | initSampleData(ledgerHash); | ||||
@@ -284,7 +287,7 @@ public class TestNet { | |||||
txTemp.eventAccounts().register(user.getIdentity()); | txTemp.eventAccounts().register(user.getIdentity()); | ||||
txTemp.eventAccount(user.getAddress()).publish("sample-event", "sample-content", -1); | txTemp.eventAccount(user.getAddress()).publish("sample-event", "sample-content", -1); | ||||
// 初始化一个合约 | // 初始化一个合约 | ||||
txTemp.contracts().deploy(user.getIdentity(), FileUtils.readBytes(new ClassPathResource("contract-samples-1.4.0.RELEASE.car").getFile())); | |||||
txTemp.contracts().deploy(user.getIdentity(), FileUtils.readBytes(new ClassPathResource("contract-samples-1.4.2.RELEASE.car").getFile())); | |||||
PreparedTransaction ptx = txTemp.prepare(); | PreparedTransaction ptx = txTemp.prepare(); | ||||
ptx.sign(admin); | ptx.sign(admin); | ||||
@@ -1,5 +1,8 @@ | |||||
package com.jdchain.samples.sdk; | package com.jdchain.samples.sdk; | ||||
import com.jd.blockchain.crypto.KeyGenUtils; | |||||
import com.jd.blockchain.ledger.BlockchainIdentity; | |||||
import com.jd.blockchain.ledger.BlockchainIdentityData; | |||||
import com.jd.blockchain.ledger.BlockchainKeyGenerator; | import com.jd.blockchain.ledger.BlockchainKeyGenerator; | ||||
import com.jd.blockchain.ledger.BlockchainKeypair; | import com.jd.blockchain.ledger.BlockchainKeypair; | ||||
import com.jd.blockchain.ledger.BytesDataList; | import com.jd.blockchain.ledger.BytesDataList; | ||||
@@ -40,7 +43,30 @@ public class ContractSample extends SampleBase { | |||||
BlockchainKeypair contractAccount = BlockchainKeyGenerator.getInstance().generate(); | BlockchainKeypair contractAccount = BlockchainKeyGenerator.getInstance().generate(); | ||||
System.out.println("合约地址:" + contractAccount.getAddress()); | System.out.println("合约地址:" + contractAccount.getAddress()); | ||||
// 部署合约 | // 部署合约 | ||||
txTemp.contracts().deploy(contractAccount.getIdentity(), FileUtils.readBytes("src/main/resources/contract-samples-1.4.0.RELEASE.car")); | |||||
txTemp.contracts().deploy(contractAccount.getIdentity(), FileUtils.readBytes("src/main/resources/contract-samples-1.4.2.RELEASE.car")); | |||||
// 准备交易 | |||||
PreparedTransaction ptx = txTemp.prepare(); | |||||
// 交易签名 | |||||
ptx.sign(adminKey); | |||||
// 提交交易 | |||||
TransactionResponse response = ptx.commit(); | |||||
Assert.assertTrue(response.isSuccess()); | |||||
} | |||||
/** | |||||
* 有两种方式更新合约代码: | |||||
* 1. contract-samples模块下,配置好pom里面的参数,其中contractAddress设置为已部署上链合约公钥信息,执行 mvn clean deploy 即可 | |||||
* 2. 打包contract-samples项目生成 car包,参考testUpdate测试代码部署 | |||||
*/ | |||||
@Test | |||||
public void testUpdate() { | |||||
// 新建交易 | |||||
TransactionTemplate txTemp = blockchainService.newTransaction(ledger); | |||||
// 解析合约身份信息 | |||||
BlockchainIdentity contractIdentity = new BlockchainIdentityData(KeyGenUtils.decodePubKey("7VeRCfSaoBW3uRuvTqVb26PYTNwvQ1iZ5HBY92YKpEVN7Qht")); | |||||
System.out.println("合约地址:" + contractIdentity.getAddress()); | |||||
// 部署合约 | |||||
txTemp.contracts().deploy(contractIdentity, FileUtils.readBytes("src/main/resources/contract-samples-1.4.2.RELEASE.car")); | |||||
// 准备交易 | // 准备交易 | ||||
PreparedTransaction ptx = txTemp.prepare(); | PreparedTransaction ptx = txTemp.prepare(); | ||||
// 交易签名 | // 交易签名 | ||||
@@ -47,7 +47,7 @@ public class DataAccountSample extends SampleBase { | |||||
TransactionTemplate txTemp = blockchainService.newTransaction(ledger); | TransactionTemplate txTemp = blockchainService.newTransaction(ledger); | ||||
// 请正确填写数据账户地址 | // 请正确填写数据账户地址 | ||||
// expVersion是针对此key的插入更新操作次数严格递增,初始为-1 | |||||
// expVersion是针对此key的插入更新操作次数严格递增,初始为-1,再次运行本测试用例请修改该值,否则服务端将报版本冲突异常。 | |||||
txTemp.dataAccount(Bytes.fromBase58("LdeNr7H1CUbqe3kWjwPwiqHcmd86zEQz2VRye")) | txTemp.dataAccount(Bytes.fromBase58("LdeNr7H1CUbqe3kWjwPwiqHcmd86zEQz2VRye")) | ||||
.setText("key1", "value1", -1) | .setText("key1", "value1", -1) | ||||
.setInt64("key2", 1, -1) | .setInt64("key2", 1, -1) | ||||
@@ -98,7 +98,7 @@ public class EventSample extends SampleBase { | |||||
TransactionTemplate txTemp = blockchainService.newTransaction(ledger); | TransactionTemplate txTemp = blockchainService.newTransaction(ledger); | ||||
// 请正确填写数据账户地址 | // 请正确填写数据账户地址 | ||||
// sequence是针对此消息name的插入更新操作次数严格递增,初始为-1 | |||||
// sequence是针对此消息name的插入更新操作次数严格递增,初始为-1,再次运行本测试用例请修改该值,否则服务端将报版本冲突异常。 | |||||
txTemp.eventAccount(Bytes.fromBase58("LdeNr7H1CUbqe3kWjwPwiqHcmd86zEQz2VRye")) | txTemp.eventAccount(Bytes.fromBase58("LdeNr7H1CUbqe3kWjwPwiqHcmd86zEQz2VRye")) | ||||
.publish("topic1", "content1", -1) | .publish("topic1", "content1", -1) | ||||
.publish("topic1", "content2", 0) | .publish("topic1", "content2", 0) | ||||
@@ -35,7 +35,10 @@ import org.junit.Test; | |||||
public class QuerySample extends SampleBase { | public class QuerySample extends SampleBase { | ||||
HashDigest sampleHash = Crypto.resolveAsHashDigest(Base58Utils.decode("j5sTuEAWmLWKFwXgpdUCxbQN1XmZfkQdC94UT2AqQEt7hp")); | HashDigest sampleHash = Crypto.resolveAsHashDigest(Base58Utils.decode("j5sTuEAWmLWKFwXgpdUCxbQN1XmZfkQdC94UT2AqQEt7hp")); | ||||
String sampleAddress = "LdeNr7H1CUbqe3kWjwPwiqHcmd86zEQz2VRye"; | |||||
String sampleUserAddress = "LdeNr7H1CUbqe3kWjwPwiqHcmd86zEQz2VRye"; | |||||
String sampleDataAccountAddress = "LdeNr7H1CUbqe3kWjwPwiqHcmd86zEQz2VRye"; | |||||
String sampleContractAddress = "LdeNr7H1CUbqe3kWjwPwiqHcmd86zEQz2VRye"; | |||||
String sampleEventAddress = "LdeNr7H1CUbqe3kWjwPwiqHcmd86zEQz2VRye"; | |||||
String sampleKey = "sample-key"; | String sampleKey = "sample-key"; | ||||
String sampleEvent = "sample-event"; | String sampleEvent = "sample-event"; | ||||
long sampleVersion = 0; | long sampleVersion = 0; | ||||
@@ -287,7 +290,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getUser() { | public void getUser() { | ||||
UserInfo user = blockchainService.getUser(ledger, sampleAddress); | |||||
UserInfo user = blockchainService.getUser(ledger, sampleUserAddress); | |||||
if (null != user) { | if (null != user) { | ||||
System.out.println(user.getAddress().toString()); | System.out.println(user.getAddress().toString()); | ||||
} | } | ||||
@@ -298,7 +301,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getDataAccount() { | public void getDataAccount() { | ||||
DataAccountInfo dataAccount = blockchainService.getDataAccount(ledger, sampleAddress); | |||||
DataAccountInfo dataAccount = blockchainService.getDataAccount(ledger, sampleDataAccountAddress); | |||||
if (null != dataAccount) { | if (null != dataAccount) { | ||||
System.out.println(dataAccount.getAddress().toString()); | System.out.println(dataAccount.getAddress().toString()); | ||||
} | } | ||||
@@ -309,7 +312,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getDataEntriesByKey() { | public void getDataEntriesByKey() { | ||||
TypedKVEntry[] kvs = blockchainService.getDataEntries(ledger, sampleAddress, sampleKey); | |||||
TypedKVEntry[] kvs = blockchainService.getDataEntries(ledger, sampleDataAccountAddress, sampleKey); | |||||
for (TypedKVEntry kv : kvs) { | for (TypedKVEntry kv : kvs) { | ||||
System.out.println(kv.getKey() + ":" + kv.getVersion() + ":" + kv.getValue()); | System.out.println(kv.getKey() + ":" + kv.getVersion() + ":" + kv.getValue()); | ||||
} | } | ||||
@@ -320,7 +323,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getDataEntriesWithKeyAndVersion() { | public void getDataEntriesWithKeyAndVersion() { | ||||
TypedKVEntry[] kvs = blockchainService.getDataEntries(ledger, sampleAddress, new KVInfoVO(new KVDataVO[]{new KVDataVO(sampleKey, new long[]{-1})})); | |||||
TypedKVEntry[] kvs = blockchainService.getDataEntries(ledger, sampleDataAccountAddress, new KVInfoVO(new KVDataVO[]{new KVDataVO(sampleKey, new long[]{0})})); | |||||
for (TypedKVEntry kv : kvs) { | for (TypedKVEntry kv : kvs) { | ||||
System.out.println(kv.getKey() + ":" + kv.getVersion() + ":" + kv.getValue()); | System.out.println(kv.getKey() + ":" + kv.getVersion() + ":" + kv.getValue()); | ||||
} | } | ||||
@@ -331,7 +334,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getDataEntriesTotalCount() { | public void getDataEntriesTotalCount() { | ||||
long count = blockchainService.getDataEntriesTotalCount(ledger, sampleAddress); | |||||
long count = blockchainService.getDataEntriesTotalCount(ledger, sampleDataAccountAddress); | |||||
System.out.println(count); | System.out.println(count); | ||||
} | } | ||||
@@ -340,7 +343,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getDataEntries() { | public void getDataEntries() { | ||||
TypedKVEntry[] kvs = blockchainService.getDataEntries(ledger, sampleAddress, 0, 1); | |||||
TypedKVEntry[] kvs = blockchainService.getDataEntries(ledger, sampleDataAccountAddress, 0, 1); | |||||
for (TypedKVEntry kv : kvs) { | for (TypedKVEntry kv : kvs) { | ||||
System.out.println(kv.getKey() + ":" + kv.getVersion() + ":" + kv.getValue()); | System.out.println(kv.getKey() + ":" + kv.getVersion() + ":" + kv.getValue()); | ||||
} | } | ||||
@@ -351,7 +354,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getContract() { | public void getContract() { | ||||
ContractInfo contract = blockchainService.getContract(ledger, sampleAddress); | |||||
ContractInfo contract = blockchainService.getContract(ledger, sampleContractAddress); | |||||
if (null != contract) { | if (null != contract) { | ||||
System.out.println(contract.getAddress().toString()); | System.out.println(contract.getAddress().toString()); | ||||
} | } | ||||
@@ -389,7 +392,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getLatestEvent() { | public void getLatestEvent() { | ||||
Event event = blockchainService.getLatestEvent(ledger, sampleEvent); | |||||
Event event = blockchainService.getLatestSystemEvent(ledger, sampleEvent); | |||||
Assert.assertNull(event); | Assert.assertNull(event); | ||||
} | } | ||||
@@ -418,7 +421,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getUserEventAccount() { | public void getUserEventAccount() { | ||||
BlockchainIdentity id = blockchainService.getUserEventAccount(ledger, sampleAddress); | |||||
BlockchainIdentity id = blockchainService.getUserEventAccount(ledger, sampleEventAddress); | |||||
if (null != id) { | if (null != id) { | ||||
System.out.println(id.getAddress().toString()); | System.out.println(id.getAddress().toString()); | ||||
} | } | ||||
@@ -438,7 +441,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getUserEventNameTotalCount() { | public void getUserEventNameTotalCount() { | ||||
long count = blockchainService.getUserEventNameTotalCount(ledger, sampleAddress); | |||||
long count = blockchainService.getUserEventNameTotalCount(ledger, sampleEventAddress); | |||||
System.out.println(count); | System.out.println(count); | ||||
} | } | ||||
@@ -447,7 +450,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getUserEventNames() { | public void getUserEventNames() { | ||||
String[] names = blockchainService.getUserEventNames(ledger, sampleAddress, 0, 1); | |||||
String[] names = blockchainService.getUserEventNames(ledger, sampleEventAddress, 0, 1); | |||||
for (String name : names) { | for (String name : names) { | ||||
System.out.println(name); | System.out.println(name); | ||||
} | } | ||||
@@ -458,7 +461,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getLatestUserEvent() { | public void getLatestUserEvent() { | ||||
Event event = blockchainService.getLatestEvent(ledger, sampleAddress, sampleEvent); | |||||
Event event = blockchainService.getLatestEvent(ledger, sampleEventAddress, sampleEvent); | |||||
if (null != event) { | if (null != event) { | ||||
BytesValue content = event.getContent(); | BytesValue content = event.getContent(); | ||||
switch (content.getType()) { | switch (content.getType()) { | ||||
@@ -483,7 +486,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getUserEventsTotalCount() { | public void getUserEventsTotalCount() { | ||||
long count = blockchainService.getUserEventsTotalCount(ledger, sampleAddress, sampleEvent); | |||||
long count = blockchainService.getUserEventsTotalCount(ledger, sampleEventAddress, sampleEvent); | |||||
System.out.println(count); | System.out.println(count); | ||||
} | } | ||||
@@ -492,7 +495,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getUserEvents() { | public void getUserEvents() { | ||||
Event[] events = blockchainService.getUserEvents(ledger, sampleAddress, sampleEvent, 0, 1); | |||||
Event[] events = blockchainService.getUserEvents(ledger, sampleEventAddress, sampleEvent, 0, 1); | |||||
for (Event event : events) { | for (Event event : events) { | ||||
BytesValue content = event.getContent(); | BytesValue content = event.getContent(); | ||||
switch (content.getType()) { | switch (content.getType()) { | ||||
@@ -517,7 +520,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getContractByAddressAndVersion() { | public void getContractByAddressAndVersion() { | ||||
ContractInfo contract = blockchainService.getContract(ledger, sampleAddress, sampleVersion); | |||||
ContractInfo contract = blockchainService.getContract(ledger, sampleContractAddress, sampleVersion); | |||||
if (null != contract) { | if (null != contract) { | ||||
System.out.println(contract.getAddress().toString()); | System.out.println(contract.getAddress().toString()); | ||||
System.out.println(contract.getChainCodeVersion()); | System.out.println(contract.getChainCodeVersion()); | ||||
@@ -573,7 +576,7 @@ public class QuerySample extends SampleBase { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void getUserPrivileges() { | public void getUserPrivileges() { | ||||
UserPrivilegeSet userPrivileges = blockchainService.getUserPrivileges(ledger, sampleAddress); | |||||
UserPrivilegeSet userPrivileges = blockchainService.getUserPrivileges(ledger, sampleUserAddress); | |||||
if (null != userPrivileges) { | if (null != userPrivileges) { | ||||
for (String role : userPrivileges.getUserRole()) { | for (String role : userPrivileges.getUserRole()) { | ||||
System.out.println(role); | System.out.println(role); | ||||