use of com.jd.blockchain.ledger.RoleSet in project jdchain-core by blockchain-jd-com.
the class UserRoleDatasetEditor method getUserRoles.
/**
* 查询角色授权;
*
* <br>
* 如果不存在,则返回 null;
*
* @param address
* @return
*/
@Override
public UserRoles getUserRoles(Bytes userAddress) {
// 只返回最新版本;
DataEntry<Bytes, byte[]> kv = dataset.getDataEntry(userAddress);
if (kv == null) {
return null;
}
RoleSet roleSet = BinaryProtocol.decode(kv.getValue());
return new UserRoles(userAddress, kv.getVersion(), roleSet);
}
use of com.jd.blockchain.ledger.RoleSet in project jdchain-core by blockchain-jd-com.
the class UserRoleDatasetEditor method getUserRoles.
@Override
public UserRoles[] getUserRoles() {
DataEntry<Bytes, byte[]>[] kvEntries = dataset.getDataEntries(0, (int) dataset.getDataCount());
UserRoles[] pns = new UserRoles[kvEntries.length];
RoleSet roleset;
for (int i = 0; i < pns.length; i++) {
roleset = BinaryProtocol.decode(kvEntries[i].getValue());
pns[i] = new UserRoles(kvEntries[i].getKey(), kvEntries[i].getVersion(), roleset);
}
return pns;
}