use of com.jd.blockchain.contract.jvm.JVMContractRuntimeConfig in project jdchain-core by blockchain-jd-com.
the class LedgerInitConfiguration method createLedgerInitSettings.
private static LedgerInitData createLedgerInitSettings(LedgerInitProperties ledgerProps, CryptoSetting cryptoSetting, ConsensusConfig consensusConfig, ParticipantProperties[] participants) {
// 创建初始化配置;
LedgerInitData initSetting = new LedgerInitData();
initSetting.setLedgerSeed(ledgerProps.getLedgerSeed());
initSetting.setIdentityMode(ledgerProps.getIdentityMode());
initSetting.setLedgerCertificates(ledgerProps.getLedgerCertificates());
initSetting.setGenesisUsers(ledgerProps.getGenesisUsers());
initSetting.setCryptoSetting(cryptoSetting);
initSetting.setConsensusParticipants(participants);
initSetting.setCreatedTime(ledgerProps.getCreatedTime());
initSetting.setLedgerDataStructure(ledgerProps.getLedgerDataStructure());
initSetting.setContractRuntimeConfig(new JVMContractRuntimeConfig(ledgerProps.getContractTimeout(), ledgerProps.getMaxStackDepth()));
// 创建共识配置;
try {
byte[] consensusSettingsBytes = encodeConsensusSettings(consensusConfig.getProvider(), consensusConfig.protocolSettings);
initSetting.setConsensusProvider(consensusConfig.getProvider().getName());
initSetting.setConsensusSettings(consensusSettingsBytes);
} catch (Exception e) {
throw new LedgerInitException("Create default consensus config failed! --" + e.getMessage(), e);
}
return initSetting;
}
use of com.jd.blockchain.contract.jvm.JVMContractRuntimeConfig in project jdchain-core by blockchain-jd-com.
the class OperationDecoratorFactory method decorateLedgerInitOperation.
/**
* decorate LedgerInitOperation object
*
* @param op
* @return
*/
public static Operation decorateLedgerInitOperation(LedgerInitOperation op) {
LedgerInitData ledgerInitData = new LedgerInitData();
ledgerInitData.setConsensusSettings(op.getInitSetting().getConsensusSettings());
ledgerInitData.setCryptoSetting(new CryptoConfigInfo(op.getInitSetting().getCryptoSetting()));
ledgerInitData.setLedgerSeed(op.getInitSetting().getLedgerSeed());
ledgerInitData.setIdentityMode(op.getInitSetting().getIdentityMode());
if (op.getInitSetting().getIdentityMode() == IdentityMode.CA) {
ledgerInitData.setLedgerCertificates(op.getInitSetting().getLedgerCertificates());
}
ledgerInitData.setConsensusProvider(op.getInitSetting().getConsensusProvider());
ledgerInitData.setCreatedTime(op.getInitSetting().getCreatedTime());
ledgerInitData.setLedgerDataStructure(op.getInitSetting().getLedgerDataStructure());
ledgerInitData.setContractRuntimeConfig(new JVMContractRuntimeConfig(op.getInitSetting().getContractRuntimeConfig().getTimeout(), op.getInitSetting().getContractRuntimeConfig().getMaxStackDepth()));
ParticipantNode[] participantNodes = op.getInitSetting().getConsensusParticipants();
if (participantNodes != null && participantNodes.length > 0) {
ParticipantNode[] participants = new ParticipantNode[participantNodes.length];
for (int i = 0; i < participantNodes.length; i++) {
ParticipantNode participantNode = participantNodes[i];
ConsensusParticipantData participant = new ConsensusParticipantData();
participant.setId(participantNode.getId());
participant.setName(participantNode.getName());
participant.setPubKey(participantNode.getPubKey());
participant.setAddress(participantNode.getAddress());
participant.setParticipantState(participantNode.getParticipantNodeState());
participants[i] = participant;
}
GenesisUser[] gus = op.getInitSetting().getGenesisUsers();
if (null == gus || gus.length == 0) {
gus = new GenesisUserConfig[participantNodes.length];
for (int i = 0; i < participantNodes.length; i++) {
gus[i] = new GenesisUserConfig(participantNodes[i].getPubKey(), null, null, null);
}
}
GenesisUser[] genesisUsers = new GenesisUserConfig[gus.length];
for (int i = 0; i < gus.length; i++) {
genesisUsers[i] = new GenesisUserConfig(gus[i]);
}
ledgerInitData.setGenesisUsers(genesisUsers);
ledgerInitData.setConsensusParticipants(participants);
}
return new LedgerInitOpTemplate(ledgerInitData);
}
Aggregations