Search in sources :

Example 1 with LedgerAdminInfo

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

the class LedgerQueryController method getConsensusParticipants.

@RequestMapping(method = RequestMethod.GET, path = GET_CONSENSUS_PARTICIPANTS)
@Override
public ParticipantNode[] getConsensusParticipants(@PathVariable(name = "ledgerHash") HashDigest ledgerHash) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerAdminInfo ledgerAdministration = ledger.getAdminInfo();
    long participantCount = ledgerAdministration.getParticipantCount();
    if (participantCount <= 0) {
        return null;
    }
    ParticipantNode[] participantNodes = ledgerAdministration.getParticipants();
    // 重新封装,处理Proxy的问题
    if (participantNodes != null && participantNodes.length > 0) {
        ParticipantNode[] convertNodes = new ParticipantNode[participantNodes.length];
        for (int i = 0, length = participantNodes.length; i < length; i++) {
            convertNodes[i] = new ParticipantCertData(participantNodes[i]);
        }
        return convertNodes;
    }
    return null;
}
Also used : LedgerAdminInfo(com.jd.blockchain.ledger.LedgerAdminInfo) ParticipantNode(com.jd.blockchain.ledger.ParticipantNode) LedgerQuery(com.jd.blockchain.ledger.core.LedgerQuery) ParticipantCertData(com.jd.blockchain.ledger.core.ParticipantCertData) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with LedgerAdminInfo

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

the class QueryParticipantsNodeRequestProcessor method processRequest.

@Override
protected void processRequest(QueryParticipantsNodeRequest request, RpcResponseClosure done) {
    HashDigest hashDigest = Crypto.resolveAsHashDigest(Base58Utils.decode(request.getLedgerHash()));
    LedgerRepository ledgerRepository = LedgerManageUtils.getLedgerRepository(hashDigest);
    LedgerAdminInfo adminInfo = ledgerRepository.getAdminInfo(ledgerRepository.retrieveLatestBlock());
    ParticipantNode[] participants = adminInfo.getParticipants();
    done.setResponse(RpcResponse.success(BinaryProtocol.encode(participants)));
    done.run(Status.OK());
}
Also used : LedgerAdminInfo(com.jd.blockchain.ledger.LedgerAdminInfo) ParticipantNode(com.jd.blockchain.ledger.ParticipantNode) HashDigest(com.jd.blockchain.crypto.HashDigest) LedgerRepository(com.jd.blockchain.ledger.core.LedgerRepository)

Example 3 with LedgerAdminInfo

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

the class LedgerRepositoryImpl method getTransactionSet.

@Override
public TransactionSet getTransactionSet(LedgerBlock block) {
    long height = getLatestBlockHeight();
    if (height == block.getHeight()) {
        // 从缓存中返回最新区块的数据集;
        return latestState.getTransactionSet();
    }
    LedgerAdminInfo adminAccount = getAdminInfo(block);
    // All of existing block is readonly;
    return loadTransactionSet(block.getHeight(), block.getTransactionSetHash(), adminAccount.getSettings().getCryptoSetting(), keyPrefix, exPolicyStorage, versioningStorage, dataStructure, true);
}
Also used : LedgerAdminInfo(com.jd.blockchain.ledger.LedgerAdminInfo)

Example 4 with LedgerAdminInfo

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

the class LedgerQueryController method getLedgerAdminInfo.

@RequestMapping(method = RequestMethod.GET, path = GET_LEDGER_ADMIN_INFO)
@Override
public LedgerAdminInfo getLedgerAdminInfo(@PathVariable(name = "ledgerHash") HashDigest ledgerHash) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerAdminInfo ledgerAdministration = ledger.getAdminInfo();
    return ledgerAdminInfoDecorator(ledgerAdministration);
}
Also used : LedgerAdminInfo(com.jd.blockchain.ledger.LedgerAdminInfo) LedgerQuery(com.jd.blockchain.ledger.core.LedgerQuery) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

LedgerAdminInfo (com.jd.blockchain.ledger.LedgerAdminInfo)4 ParticipantNode (com.jd.blockchain.ledger.ParticipantNode)2 LedgerQuery (com.jd.blockchain.ledger.core.LedgerQuery)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 HashDigest (com.jd.blockchain.crypto.HashDigest)1 LedgerRepository (com.jd.blockchain.ledger.core.LedgerRepository)1 ParticipantCertData (com.jd.blockchain.ledger.core.ParticipantCertData)1