Browse Source

rename;

tags/1.1.0
huanghaiquan 5 years ago
parent
commit
fd4bd71ac2
11 changed files with 49 additions and 142 deletions
  1. +0
    -26
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/AccountPrivilege.java
  2. +0
    -13
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/Authorization.java
  3. +0
    -22
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/Gateway.java
  4. +24
    -61
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/LedgerAdminAccount.java
  5. +3
    -3
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/ParticipantDataset.java
  6. +3
    -3
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/RolePrivilegeDataset.java
  7. +10
    -4
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/UserRoleDataset.java
  8. +1
    -1
      source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerMetaDataTest.java
  9. +4
    -5
      source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/RolePrivilegeDatasetTest.java
  10. +3
    -3
      source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/UserRoleDatasetTest.java
  11. +1
    -1
      source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/ParticipantNode.java

+ 0
- 26
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/AccountPrivilege.java View File

@@ -1,26 +0,0 @@
package com.jd.blockchain.ledger.core;

public interface AccountPrivilege {

/**
* 数据“读”的操作码;
*
* @return
*/
byte getReadingOpCode();

/**
* “写”的操作码;
*
* @return
*/
byte getWrittingOpCode();

/**
* 其它的扩展操作码;
*
* @return
*/
byte[] getExtOpCodes();

}

+ 0
- 13
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/Authorization.java View File

@@ -1,13 +0,0 @@
package com.jd.blockchain.ledger.core;

/**
* {@link Authorization} 抽象了对特定用户/角色的授权信息;
*
* @author huanghaiquan
*
*/
public class Authorization {


}

+ 0
- 22
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/Gateway.java View File

@@ -1,22 +0,0 @@
package com.jd.blockchain.ledger.core;
import com.jd.blockchain.ledger.ParticipantNode;
/**
* @author hhq
* @version 1.0
* @created 14-6��-2018 12:13:32
*/
public class Gateway extends Node {
public ParticipantNode m_Participant;
public Gateway(){
}
public void finalize() throws Throwable {
super.finalize();
}
}

+ 24
- 61
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/LedgerAdminAccount.java View File

@@ -38,12 +38,10 @@ public class LedgerAdminAccount implements Transactional, LedgerAdminInfo {
private final Bytes metaPrefix; private final Bytes metaPrefix;
private final Bytes settingPrefix; private final Bytes settingPrefix;
private final Bytes rolePrivilegePrefix;
private final Bytes userRolePrefix;
private LedgerMetadata_V2 origMetadata; private LedgerMetadata_V2 origMetadata;
private LedgerMetadataImpl metadata;
private LedgerMetadataInfo metadata;
/** /**
* 原来的账本设置; * 原来的账本设置;
@@ -58,22 +56,23 @@ public class LedgerAdminAccount implements Transactional, LedgerAdminInfo {
/** /**
* 账本的参与节点; * 账本的参与节点;
*/ */
private ParticipantDataSet participants;
private ParticipantDataset participants;
private RolePrivilegeDataSet rolePrivileges;
/**
* “角色-权限”数据集;
*/
private RolePrivilegeDataset rolePrivileges;
private UserRoleDataSet userRoles;
/**
* “用户-角色”数据集;
*/
private UserRoleDataset userRoles;
/** /**
* 账本参数配置; * 账本参数配置;
*/ */
private LedgerSettings settings; private LedgerSettings settings;
// /**
// * 账本的全局权限设置;
// */
// private PrivilegeDataSet privileges;
private ExPolicyKVStorage storage; private ExPolicyKVStorage storage;
private HashDigest adminAccountHash; private HashDigest adminAccountHash;
@@ -115,25 +114,14 @@ public class LedgerAdminAccount implements Transactional, LedgerAdminInfo {
VersioningKVStorage versioningStorage) { VersioningKVStorage versioningStorage) {
this.metaPrefix = Bytes.fromString(keyPrefix + LEDGER_META_PREFIX); this.metaPrefix = Bytes.fromString(keyPrefix + LEDGER_META_PREFIX);
this.settingPrefix = Bytes.fromString(keyPrefix + LEDGER_SETTING_PREFIX); this.settingPrefix = Bytes.fromString(keyPrefix + LEDGER_SETTING_PREFIX);
this.rolePrivilegePrefix = Bytes.fromString(keyPrefix + ROLE_PRIVILEGE_PREFIX);
this.userRolePrefix = Bytes.fromString(keyPrefix + USER_ROLE_PREFIX);
ParticipantNode[] parties = initSetting.getConsensusParticipants(); ParticipantNode[] parties = initSetting.getConsensusParticipants();
if (parties.length == 0) { if (parties.length == 0) {
throw new LedgerException("No participant!"); throw new LedgerException("No participant!");
} }
// 检查参与者列表是否已经按照 id 升序排列,并且 id 不冲突;
// 注:参与者的 id 要求从 0 开始编号,顺序依次递增,不允许跳空;
for (int i = 0; i < parties.length; i++) {
// if (parties[i].getAddress() != i) {
// throw new LedgerException("The id of participant isn't match the order of the
// participant list!");
// }
}
// 初始化元数据; // 初始化元数据;
this.metadata = new LedgerMetadataImpl();
this.metadata = new LedgerMetadataInfo();
this.metadata.setSeed(initSetting.getLedgerSeed()); this.metadata.setSeed(initSetting.getLedgerSeed());
// 新配置; // 新配置;
this.settings = new LedgerConfiguration(initSetting.getConsensusProvider(), initSetting.getConsensusSettings(), this.settings = new LedgerConfiguration(initSetting.getConsensusProvider(), initSetting.getConsensusSettings(),
@@ -144,7 +132,7 @@ public class LedgerAdminAccount implements Transactional, LedgerAdminInfo {
// 基于原配置初始化参与者列表; // 基于原配置初始化参与者列表;
String partiPrefix = keyPrefix + LEDGER_PARTICIPANT_PREFIX; String partiPrefix = keyPrefix + LEDGER_PARTICIPANT_PREFIX;
this.participants = new ParticipantDataSet(previousSettings.getCryptoSetting(), partiPrefix, exPolicyStorage,
this.participants = new ParticipantDataset(previousSettings.getCryptoSetting(), partiPrefix, exPolicyStorage,
versioningStorage); versioningStorage);
for (ParticipantNode p : parties) { for (ParticipantNode p : parties) {
@@ -152,11 +140,11 @@ public class LedgerAdminAccount implements Transactional, LedgerAdminInfo {
} }
String rolePrivilegePrefix = keyPrefix + ROLE_PRIVILEGE_PREFIX; String rolePrivilegePrefix = keyPrefix + ROLE_PRIVILEGE_PREFIX;
this.rolePrivileges = new RolePrivilegeDataSet(this.settings.getCryptoSetting(), rolePrivilegePrefix,
this.rolePrivileges = new RolePrivilegeDataset(this.settings.getCryptoSetting(), rolePrivilegePrefix,
exPolicyStorage, versioningStorage); exPolicyStorage, versioningStorage);
String userRolePrefix = keyPrefix + USER_ROLE_PREFIX; String userRolePrefix = keyPrefix + USER_ROLE_PREFIX;
this.userRoles = new UserRoleDataSet(this.settings.getCryptoSetting(), userRolePrefix, exPolicyStorage,
this.userRoles = new UserRoleDataset(this.settings.getCryptoSetting(), userRolePrefix, exPolicyStorage,
versioningStorage); versioningStorage);
// 初始化其它属性; // 初始化其它属性;
@@ -168,38 +156,26 @@ public class LedgerAdminAccount implements Transactional, LedgerAdminInfo {
VersioningKVStorage versioningKVStorage, boolean readonly) { VersioningKVStorage versioningKVStorage, boolean readonly) {
this.metaPrefix = Bytes.fromString(keyPrefix + LEDGER_META_PREFIX); this.metaPrefix = Bytes.fromString(keyPrefix + LEDGER_META_PREFIX);
this.settingPrefix = Bytes.fromString(keyPrefix + LEDGER_SETTING_PREFIX); this.settingPrefix = Bytes.fromString(keyPrefix + LEDGER_SETTING_PREFIX);
this.rolePrivilegePrefix = Bytes.fromString(keyPrefix + ROLE_PRIVILEGE_PREFIX);
this.userRolePrefix = Bytes.fromString(keyPrefix + USER_ROLE_PREFIX);
this.storage = kvStorage; this.storage = kvStorage;
this.readonly = readonly; this.readonly = readonly;
this.origMetadata = loadAndVerifyMetadata(adminAccountHash); this.origMetadata = loadAndVerifyMetadata(adminAccountHash);
this.metadata = new LedgerMetadataImpl(origMetadata);
this.metadata = new LedgerMetadataInfo(origMetadata);
this.settings = loadAndVerifySettings(metadata.getSettingsHash()); this.settings = loadAndVerifySettings(metadata.getSettingsHash());
// 复制记录一份配置作为上一个区块的原始配置,该实例仅供读取,不做修改,也不会回写到存储; // 复制记录一份配置作为上一个区块的原始配置,该实例仅供读取,不做修改,也不会回写到存储;
this.previousSettings = new LedgerConfiguration(settings); this.previousSettings = new LedgerConfiguration(settings);
this.previousSettingHash = metadata.getSettingsHash(); this.previousSettingHash = metadata.getSettingsHash();
this.adminAccountHash = adminAccountHash; this.adminAccountHash = adminAccountHash;
// this.privileges = new PrivilegeDataSet(metadata.getPrivilegesHash(),
// metadata.getSetting().getCryptoSetting(),
// PrefixAppender.prefix(LEDGER_PRIVILEGE_PREFIX, kvStorage),
// PrefixAppender.prefix(LEDGER_PRIVILEGE_PREFIX, versioningKVStorage),
// readonly);
// this.participants = new ParticipantDataSet(metadata.getParticipantsHash(),
// previousSetting.getCryptoSetting(),
// PrefixAppender.prefix(LEDGER_PARTICIPANT_PREFIX, kvStorage),
// PrefixAppender.prefix(LEDGER_PARTICIPANT_PREFIX, versioningKVStorage),
// readonly);
String partiPrefix = keyPrefix + LEDGER_PARTICIPANT_PREFIX; String partiPrefix = keyPrefix + LEDGER_PARTICIPANT_PREFIX;
this.participants = new ParticipantDataSet(metadata.getParticipantsHash(), previousSettings.getCryptoSetting(),
this.participants = new ParticipantDataset(metadata.getParticipantsHash(), previousSettings.getCryptoSetting(),
partiPrefix, kvStorage, versioningKVStorage, readonly); partiPrefix, kvStorage, versioningKVStorage, readonly);
String rolePrivilegePrefix = keyPrefix + ROLE_PRIVILEGE_PREFIX; String rolePrivilegePrefix = keyPrefix + ROLE_PRIVILEGE_PREFIX;
this.rolePrivileges = new RolePrivilegeDataSet(metadata.getRolePrivilegesHash(),
this.rolePrivileges = new RolePrivilegeDataset(metadata.getRolePrivilegesHash(),
previousSettings.getCryptoSetting(), rolePrivilegePrefix, kvStorage, versioningKVStorage, readonly); previousSettings.getCryptoSetting(), rolePrivilegePrefix, kvStorage, versioningKVStorage, readonly);
String userRolePrefix = keyPrefix + USER_ROLE_PREFIX; String userRolePrefix = keyPrefix + USER_ROLE_PREFIX;
this.userRoles = new UserRoleDataSet(metadata.getUserRolesHash(), previousSettings.getCryptoSetting(),
this.userRoles = new UserRoleDataset(metadata.getUserRolesHash(), previousSettings.getCryptoSetting(),
userRolePrefix, kvStorage, versioningKVStorage, readonly); userRolePrefix, kvStorage, versioningKVStorage, readonly);
} }
@@ -297,19 +273,6 @@ public class LedgerAdminAccount implements Transactional, LedgerAdminInfo {
return participants.getParticipantCount(); return participants.getParticipantCount();
} }
// /*
// * (non-Javadoc)
// *
// * @see
// *
// com.jd.blockchain.ledger.core.LedgerAdministration#getParticipant(java.lang.
// * String)
// */
// @Override
// public ParticipantNode getParticipant(int id) {
// return participants.getParticipant(id);
// }
@Override @Override
public ParticipantNode[] getParticipants() { public ParticipantNode[] getParticipants() {
return participants.getParticipants(); return participants.getParticipants();
@@ -397,7 +360,7 @@ public class LedgerAdminAccount implements Transactional, LedgerAdminInfo {
return BinaryProtocol.decode(bytes); return BinaryProtocol.decode(bytes);
} }
private byte[] serializeMetadata(LedgerMetadataImpl config) {
private byte[] serializeMetadata(LedgerMetadataInfo config) {
return BinaryProtocol.encode(config, LedgerMetadata_V2.class); return BinaryProtocol.encode(config, LedgerMetadata_V2.class);
} }
@@ -407,10 +370,10 @@ public class LedgerAdminAccount implements Transactional, LedgerAdminInfo {
return; return;
} }
participants.cancel(); participants.cancel();
metadata = new LedgerMetadataImpl(origMetadata);
metadata = new LedgerMetadataInfo(origMetadata);
} }
public static class LedgerMetadataImpl implements LedgerMetadata_V2 {
public static class LedgerMetadataInfo implements LedgerMetadata_V2 {
private byte[] seed; private byte[] seed;
@@ -424,10 +387,10 @@ public class LedgerAdminAccount implements Transactional, LedgerAdminInfo {
private HashDigest userRolesHash; private HashDigest userRolesHash;
public LedgerMetadataImpl() {
public LedgerMetadataInfo() {
} }
public LedgerMetadataImpl(LedgerMetadata_V2 metadata) {
public LedgerMetadataInfo(LedgerMetadata_V2 metadata) {
this.seed = metadata.getSeed(); this.seed = metadata.getSeed();
this.participantsHash = metadata.getParticipantsHash(); this.participantsHash = metadata.getParticipantsHash();
this.settingsHash = metadata.getSettingsHash(); this.settingsHash = metadata.getSettingsHash();


source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/ParticipantDataSet.java → source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/ParticipantDataset.java View File

@@ -11,7 +11,7 @@ import com.jd.blockchain.storage.service.VersioningKVStorage;
import com.jd.blockchain.utils.Bytes; import com.jd.blockchain.utils.Bytes;
import com.jd.blockchain.utils.Transactional; import com.jd.blockchain.utils.Transactional;


public class ParticipantDataSet implements Transactional, MerkleProvable {
public class ParticipantDataset implements Transactional, MerkleProvable {


static { static {
DataContractRegistry.register(ParticipantNode.class); DataContractRegistry.register(ParticipantNode.class);
@@ -19,12 +19,12 @@ public class ParticipantDataSet implements Transactional, MerkleProvable {


private MerkleDataSet dataset; private MerkleDataSet dataset;


public ParticipantDataSet(CryptoSetting cryptoSetting, String prefix, ExPolicyKVStorage exPolicyStorage,
public ParticipantDataset(CryptoSetting cryptoSetting, String prefix, ExPolicyKVStorage exPolicyStorage,
VersioningKVStorage verStorage) { VersioningKVStorage verStorage) {
dataset = new MerkleDataSet(cryptoSetting, prefix, exPolicyStorage, verStorage); dataset = new MerkleDataSet(cryptoSetting, prefix, exPolicyStorage, verStorage);
} }


public ParticipantDataSet(HashDigest merkleRootHash, CryptoSetting cryptoSetting, String prefix,
public ParticipantDataset(HashDigest merkleRootHash, CryptoSetting cryptoSetting, String prefix,
ExPolicyKVStorage exPolicyStorage, VersioningKVStorage verStorage, boolean readonly) { ExPolicyKVStorage exPolicyStorage, VersioningKVStorage verStorage, boolean readonly) {
dataset = new MerkleDataSet(merkleRootHash, cryptoSetting, prefix, exPolicyStorage, verStorage, readonly); dataset = new MerkleDataSet(merkleRootHash, cryptoSetting, prefix, exPolicyStorage, verStorage, readonly);
} }

source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/RolePrivilegeDataSet.java → source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/RolePrivilegeDataset.java View File

@@ -10,16 +10,16 @@ import com.jd.blockchain.storage.service.VersioningKVStorage;
import com.jd.blockchain.utils.Bytes; import com.jd.blockchain.utils.Bytes;
import com.jd.blockchain.utils.Transactional; import com.jd.blockchain.utils.Transactional;


public class RolePrivilegeDataSet implements Transactional, MerkleProvable, RolePrivilegeSettings {
public class RolePrivilegeDataset implements Transactional, MerkleProvable, RolePrivilegeSettings {


private MerkleDataSet dataset; private MerkleDataSet dataset;


public RolePrivilegeDataSet(CryptoSetting cryptoSetting, String prefix, ExPolicyKVStorage exPolicyStorage,
public RolePrivilegeDataset(CryptoSetting cryptoSetting, String prefix, ExPolicyKVStorage exPolicyStorage,
VersioningKVStorage verStorage) { VersioningKVStorage verStorage) {
dataset = new MerkleDataSet(cryptoSetting, prefix, exPolicyStorage, verStorage); dataset = new MerkleDataSet(cryptoSetting, prefix, exPolicyStorage, verStorage);
} }


public RolePrivilegeDataSet(HashDigest merkleRootHash, CryptoSetting cryptoSetting, String prefix,
public RolePrivilegeDataset(HashDigest merkleRootHash, CryptoSetting cryptoSetting, String prefix,
ExPolicyKVStorage exPolicyStorage, VersioningKVStorage verStorage, boolean readonly) { ExPolicyKVStorage exPolicyStorage, VersioningKVStorage verStorage, boolean readonly) {
dataset = new MerkleDataSet(merkleRootHash, cryptoSetting, prefix, exPolicyStorage, verStorage, readonly); dataset = new MerkleDataSet(merkleRootHash, cryptoSetting, prefix, exPolicyStorage, verStorage, readonly);
} }

source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/UserRoleDataSet.java → source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/UserRoleDataset.java View File

@@ -11,16 +11,22 @@ import com.jd.blockchain.storage.service.VersioningKVStorage;
import com.jd.blockchain.utils.Bytes; import com.jd.blockchain.utils.Bytes;
import com.jd.blockchain.utils.Transactional; import com.jd.blockchain.utils.Transactional;


public class UserRoleDataSet implements Transactional, MerkleProvable, UserRoleSettings {
/**
* User-Role authorization data set;
*
* @author huanghaiquan
*
*/
public class UserRoleDataset implements Transactional, MerkleProvable, UserRoleSettings {

private MerkleDataSet dataset; private MerkleDataSet dataset;


public UserRoleDataSet(CryptoSetting cryptoSetting, String prefix, ExPolicyKVStorage exPolicyStorage,
public UserRoleDataset(CryptoSetting cryptoSetting, String prefix, ExPolicyKVStorage exPolicyStorage,
VersioningKVStorage verStorage) { VersioningKVStorage verStorage) {
dataset = new MerkleDataSet(cryptoSetting, prefix, exPolicyStorage, verStorage); dataset = new MerkleDataSet(cryptoSetting, prefix, exPolicyStorage, verStorage);
} }


public UserRoleDataSet(HashDigest merkleRootHash, CryptoSetting cryptoSetting, String prefix,
public UserRoleDataset(HashDigest merkleRootHash, CryptoSetting cryptoSetting, String prefix,
ExPolicyKVStorage exPolicyStorage, VersioningKVStorage verStorage, boolean readonly) { ExPolicyKVStorage exPolicyStorage, VersioningKVStorage verStorage, boolean readonly) {
dataset = new MerkleDataSet(merkleRootHash, cryptoSetting, prefix, exPolicyStorage, verStorage, readonly); dataset = new MerkleDataSet(merkleRootHash, cryptoSetting, prefix, exPolicyStorage, verStorage, readonly);
} }

+ 1
- 1
source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerMetaDataTest.java View File

@@ -79,7 +79,7 @@ public class LedgerMetaDataTest {
// new Bytes(consensusSettingBytes), cryptoConfig); // new Bytes(consensusSettingBytes), cryptoConfig);
HashDigest settingsHash = Crypto.getHashFunction("SHA256").hash(consensusSettingBytes); HashDigest settingsHash = Crypto.getHashFunction("SHA256").hash(consensusSettingBytes);


LedgerAdminAccount.LedgerMetadataImpl ledgerMetadata = new LedgerAdminAccount.LedgerMetadataImpl();
LedgerAdminAccount.LedgerMetadataInfo ledgerMetadata = new LedgerAdminAccount.LedgerMetadataInfo();


ledgerMetadata.setSeed(seed); ledgerMetadata.setSeed(seed);
ledgerMetadata.setSettingsHash(settingsHash); ledgerMetadata.setSettingsHash(settingsHash);


source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/RolePrivilegeDataSetTest.java → source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/RolePrivilegeDatasetTest.java View File

@@ -2,7 +2,6 @@ package test.com.jd.blockchain.ledger;


import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;


import org.junit.Test; import org.junit.Test;


@@ -14,12 +13,12 @@ import com.jd.blockchain.crypto.service.classic.ClassicCryptoService;
import com.jd.blockchain.crypto.service.sm.SMCryptoService; import com.jd.blockchain.crypto.service.sm.SMCryptoService;
import com.jd.blockchain.ledger.core.CryptoConfig; import com.jd.blockchain.ledger.core.CryptoConfig;
import com.jd.blockchain.ledger.core.LedgerPermission; import com.jd.blockchain.ledger.core.LedgerPermission;
import com.jd.blockchain.ledger.core.RolePrivilegeDataSet;
import com.jd.blockchain.ledger.core.RolePrivilegeDataset;
import com.jd.blockchain.ledger.core.RolePrivileges; import com.jd.blockchain.ledger.core.RolePrivileges;
import com.jd.blockchain.ledger.core.TransactionPermission; import com.jd.blockchain.ledger.core.TransactionPermission;
import com.jd.blockchain.storage.service.utils.MemoryKVStorage; import com.jd.blockchain.storage.service.utils.MemoryKVStorage;


public class RolePrivilegeDataSetTest {
public class RolePrivilegeDatasetTest {


private static final String[] SUPPORTED_PROVIDER_NAMES = { ClassicCryptoService.class.getName(), private static final String[] SUPPORTED_PROVIDER_NAMES = { ClassicCryptoService.class.getName(),
SMCryptoService.class.getName() }; SMCryptoService.class.getName() };
@@ -45,7 +44,7 @@ public class RolePrivilegeDataSetTest {


String roleName = "DEFAULT"; String roleName = "DEFAULT";
String prefix = "role-privilege/"; String prefix = "role-privilege/";
RolePrivilegeDataSet rolePrivilegeDataset = new RolePrivilegeDataSet(cryptoConfig, prefix, testStorage,
RolePrivilegeDataset rolePrivilegeDataset = new RolePrivilegeDataset(cryptoConfig, prefix, testStorage,
testStorage); testStorage);
rolePrivilegeDataset.addRolePrivilege(roleName, new LedgerPermission[] { LedgerPermission.REGISTER_USER }, rolePrivilegeDataset.addRolePrivilege(roleName, new LedgerPermission[] { LedgerPermission.REGISTER_USER },
new TransactionPermission[] { TransactionPermission.CONTRACT_OPERATION }); new TransactionPermission[] { TransactionPermission.CONTRACT_OPERATION });
@@ -56,7 +55,7 @@ public class RolePrivilegeDataSetTest {
assertNotNull(rolePrivilege); assertNotNull(rolePrivilege);


HashDigest rootHash = rolePrivilegeDataset.getRootHash(); HashDigest rootHash = rolePrivilegeDataset.getRootHash();
RolePrivilegeDataSet newRolePrivilegeDataset = new RolePrivilegeDataSet(rootHash, cryptoConfig, prefix,
RolePrivilegeDataset newRolePrivilegeDataset = new RolePrivilegeDataset(rootHash, cryptoConfig, prefix,
testStorage, testStorage, true); testStorage, testStorage, true);
rolePrivilege = newRolePrivilegeDataset.getRolePrivilege(roleName); rolePrivilege = newRolePrivilegeDataset.getRolePrivilege(roleName);
assertNotNull(rolePrivilege); assertNotNull(rolePrivilege);

source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/UserRoleDataSetTest.java → source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/UserRoleDatasetTest.java View File

@@ -15,11 +15,11 @@ import com.jd.blockchain.ledger.BlockchainKeyGenerator;
import com.jd.blockchain.ledger.BlockchainKeypair; import com.jd.blockchain.ledger.BlockchainKeypair;
import com.jd.blockchain.ledger.core.CryptoConfig; import com.jd.blockchain.ledger.core.CryptoConfig;
import com.jd.blockchain.ledger.core.RolesPolicy; import com.jd.blockchain.ledger.core.RolesPolicy;
import com.jd.blockchain.ledger.core.UserRoleDataSet;
import com.jd.blockchain.ledger.core.UserRoleDataset;
import com.jd.blockchain.ledger.core.UserRoles; import com.jd.blockchain.ledger.core.UserRoles;
import com.jd.blockchain.storage.service.utils.MemoryKVStorage; import com.jd.blockchain.storage.service.utils.MemoryKVStorage;


public class UserRoleDataSetTest {
public class UserRoleDatasetTest {


private static final String[] SUPPORTED_PROVIDER_NAMES = { ClassicCryptoService.class.getName(), private static final String[] SUPPORTED_PROVIDER_NAMES = { ClassicCryptoService.class.getName(),
SMCryptoService.class.getName() }; SMCryptoService.class.getName() };
@@ -42,7 +42,7 @@ public class UserRoleDataSetTest {


MemoryKVStorage testStorage = new MemoryKVStorage(); MemoryKVStorage testStorage = new MemoryKVStorage();
String prefix = "user-roles/"; String prefix = "user-roles/";
UserRoleDataSet userRolesDataset = new UserRoleDataSet(cryptoConfig, prefix, testStorage, testStorage);
UserRoleDataset userRolesDataset = new UserRoleDataset(cryptoConfig, prefix, testStorage, testStorage);


BlockchainKeypair bckp = BlockchainKeyGenerator.getInstance().generate(); BlockchainKeypair bckp = BlockchainKeyGenerator.getInstance().generate();
String[] authRoles = { "DEFAULT", "MANAGER" }; String[] authRoles = { "DEFAULT", "MANAGER" };

+ 1
- 1
source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/ParticipantNode.java View File

@@ -14,7 +14,7 @@ import com.jd.blockchain.utils.Bytes;
* *
*/ */
@DataContract(code = DataCodes.METADATA_CONSENSUS_PARTICIPANT) @DataContract(code = DataCodes.METADATA_CONSENSUS_PARTICIPANT)
public interface ParticipantNode {// extends ConsensusNode, ParticipantInfo {
public interface ParticipantNode {


/** /**
* 节点的顺序编号;<br> * 节点的顺序编号;<br>


Loading…
Cancel
Save