Search in sources :

Example 16 with BlockchainIdentity

use of com.jd.blockchain.ledger.BlockchainIdentity in project jdchain-core by blockchain-jd-com.

the class UncommittedLedgerQueryService method getUsers.

@Override
public BlockchainIdentity[] getUsers(int fromIndex, int count) {
    UserAccountSet userAccountSet = transactionContext.getDataset().getUserAccountSet();
    QueryArgs queryArgs = QueryUtils.calFromIndexAndCountDescend(fromIndex, count, (int) userAccountSet.getTotal());
    SkippingIterator<BlockchainIdentity> it = userAccountSet.identityIterator();
    it.skip(queryArgs.getFrom());
    return it.next(queryArgs.getCount(), BlockchainIdentity.class);
}
Also used : QueryArgs(utils.query.QueryArgs) BlockchainIdentity(com.jd.blockchain.ledger.BlockchainIdentity) UserAccountSet(com.jd.blockchain.ledger.core.UserAccountSet)

Example 17 with BlockchainIdentity

use of com.jd.blockchain.ledger.BlockchainIdentity in project jdchain-core by blockchain-jd-com.

the class DataAccountRegisterOperationHandle method doProcess.

@Override
protected void doProcess(DataAccountRegisterOperation op, LedgerTransactionContext transactionContext, TransactionRequestExtension requestContext, LedgerQuery ledger, OperationHandleContext handleContext, EventManager manager) {
    // TODO: 请求者应该提供数据账户的公钥签名,以更好地确保注册人对该地址和公钥具有合法使用权;
    // 权限校验;
    SecurityPolicy securityPolicy = SecurityContext.getContextUsersPolicy();
    securityPolicy.checkEndpointPermission(LedgerPermission.REGISTER_DATA_ACCOUNT, MultiIDsPolicy.AT_LEAST_ONE);
    // 操作账本;
    BlockchainIdentity bid = op.getAccountID();
    DataAccount account = ((DataAccountSetEditor) (transactionContext.getDataset().getDataAccountSet())).register(bid.getAddress(), bid.getPubKey(), null);
    account.setPermission(new AccountDataPermission(AccountType.DATA, requestContext.getEndpointAddresses().toArray(new Bytes[0])));
}
Also used : DataAccount(com.jd.blockchain.ledger.core.DataAccount) SecurityPolicy(com.jd.blockchain.ledger.SecurityPolicy) BlockchainIdentity(com.jd.blockchain.ledger.BlockchainIdentity) AccountDataPermission(com.jd.blockchain.ledger.AccountDataPermission) DataAccountSetEditor(com.jd.blockchain.ledger.core.DataAccountSetEditor)

Aggregations

BlockchainIdentity (com.jd.blockchain.ledger.BlockchainIdentity)17 QueryArgs (utils.query.QueryArgs)12 LedgerBlock (com.jd.blockchain.ledger.LedgerBlock)4 LedgerQuery (com.jd.blockchain.ledger.core.LedgerQuery)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ContractAccountSet (com.jd.blockchain.ledger.core.ContractAccountSet)3 DataAccountSet (com.jd.blockchain.ledger.core.DataAccountSet)3 EventAccountSet (com.jd.blockchain.ledger.core.EventAccountSet)3 UserAccountSet (com.jd.blockchain.ledger.core.UserAccountSet)3 ContractInfo (com.jd.blockchain.ledger.ContractInfo)2 DataAccountInfo (com.jd.blockchain.ledger.DataAccountInfo)2 SecurityPolicy (com.jd.blockchain.ledger.SecurityPolicy)2 UserInfo (com.jd.blockchain.ledger.UserInfo)2 Bytes (utils.Bytes)2 Transaction (com.jd.blockchain.gateway.service.search.Transaction)1 AccountDataPermission (com.jd.blockchain.ledger.AccountDataPermission)1 IllegalTransactionException (com.jd.blockchain.ledger.IllegalTransactionException)1 LedgerTransaction (com.jd.blockchain.ledger.LedgerTransaction)1 DataAccount (com.jd.blockchain.ledger.core.DataAccount)1 DataAccountSetEditor (com.jd.blockchain.ledger.core.DataAccountSetEditor)1