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;
}
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());
}
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);
}
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);
}
Aggregations