Search in sources :

Example 1 with RoleSet

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);
}
Also used : Bytes(utils.Bytes) RoleSet(com.jd.blockchain.ledger.RoleSet) UserRoles(com.jd.blockchain.ledger.UserRoles)

Example 2 with 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;
}
Also used : DataEntry(utils.DataEntry) RoleSet(com.jd.blockchain.ledger.RoleSet) UserRoles(com.jd.blockchain.ledger.UserRoles)

Aggregations

RoleSet (com.jd.blockchain.ledger.RoleSet)2 UserRoles (com.jd.blockchain.ledger.UserRoles)2 Bytes (utils.Bytes)1 DataEntry (utils.DataEntry)1