Search in sources :

Example 1 with BftsmartClientConfig

use of com.jd.blockchain.consensus.bftsmart.client.BftsmartClientConfig in project jdchain-core by blockchain-jd-com.

the class ProxyClientTest method proxyClientSend.

public void proxyClientSend(BftsmartNodeServer nodeServer) {
    BftsmartClientIncomingConfig clientIncomingConfig = new BftsmartClientIncomingConfig();
    BlockchainKeypair keyPair = BlockchainKeyGenerator.getInstance().generate();
    clientIncomingConfig.setPubKey(keyPair.getPubKey());
    clientIncomingConfig.setSessionCredential(new BftsmartSessionCredentialConfig(0, 10, System.currentTimeMillis()));
    clientIncomingConfig.setViewSettings(nodeServer.getConsensusSetting());
    clientIncomingConfig.setTomConfig(BinarySerializeUtils.serialize(nodeServer.getTomConfig()));
    clientIncomingConfig.setTopology(BinarySerializeUtils.serialize(nodeServer.getTopology()));
    BftsmartClientConfig clientSettings = new BftsmartClientConfig(clientIncomingConfig);
    BftsmartConsensusClient consensusClient = new BftsmartConsensusClient(clientSettings);
    bytes = new byte[1024];
    BftsmartMessageService messageService = (BftsmartMessageService) consensusClient.getMessageService();
    for (int j = 0; j < number; j++) {
        txSendPools.execute(() -> {
            random.nextBytes(bytes);
            messageService.sendOrdered(bytes);
        });
    }
}
Also used : BftsmartMessageService(com.jd.blockchain.consensus.bftsmart.client.BftsmartMessageService) BftsmartConsensusClient(com.jd.blockchain.consensus.bftsmart.client.BftsmartConsensusClient) BftsmartClientIncomingConfig(com.jd.blockchain.consensus.bftsmart.BftsmartClientIncomingConfig) BlockchainKeypair(com.jd.blockchain.ledger.BlockchainKeypair) BftsmartSessionCredentialConfig(com.jd.blockchain.consensus.bftsmart.client.BftsmartSessionCredentialConfig) BftsmartClientConfig(com.jd.blockchain.consensus.bftsmart.client.BftsmartClientConfig)

Aggregations

BftsmartClientIncomingConfig (com.jd.blockchain.consensus.bftsmart.BftsmartClientIncomingConfig)1 BftsmartClientConfig (com.jd.blockchain.consensus.bftsmart.client.BftsmartClientConfig)1 BftsmartConsensusClient (com.jd.blockchain.consensus.bftsmart.client.BftsmartConsensusClient)1 BftsmartMessageService (com.jd.blockchain.consensus.bftsmart.client.BftsmartMessageService)1 BftsmartSessionCredentialConfig (com.jd.blockchain.consensus.bftsmart.client.BftsmartSessionCredentialConfig)1 BlockchainKeypair (com.jd.blockchain.ledger.BlockchainKeypair)1