Search in sources :

Example 26 with ChannelEthereumService

use of org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService in project web3sdk by FISCO-BCOS.

the class CallContractTest method main.

public static void main(String[] args) throws Exception {
    try {
        // init the Service
        ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
        Service service = context.getBean(Service.class);
        service.setGroupId(Integer.parseInt(args[0]));
        // run the daemon service
        service.run();
        // init the client keys
        credentials = GenCredential.create();
        logger.info("-----> start test in CallContractTest!");
        ChannelEthereumService channelEthereumService = new ChannelEthereumService();
        channelEthereumService.setTimeout(10 * 1000);
        channelEthereumService.setChannelService(service);
        web3j = Web3j.build(channelEthereumService, Integer.parseInt(args[0]));
        if (args.length == 2) {
            String address = args[1];
            CallContract callContract = new CallContract(credentials, web3j);
            System.out.println("************************ Test call & sendTrandation ************************");
            testSyncCallContract(callContract, address);
            testAsyncCallContract(callContract, address);
            System.out.println("************************ Test decode ************************");
            testDecode(callContract, address);
            System.out.println("Test CallContract successfully.");
        } else {
            System.out.println("Please input group id and contract address.");
        }
    } catch (Exception e) {
        System.out.println(e.getLocalizedMessage());
        System.exit(1);
    }
    System.exit(0);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ChannelEthereumService(org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService) ChannelEthereumService(org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService) Utf8String(org.fisco.bcos.web3j.abi.datatypes.Utf8String)

Example 27 with ChannelEthereumService

use of org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService in project web3sdk by FISCO-BCOS.

the class PerformanceDTTest method initialize.

public void initialize(String groupId) throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
    Service service = context.getBean(Service.class);
    service.setGroupId(Integer.parseInt(groupId));
    service.run();
    ChannelEthereumService channelEthereumService = new ChannelEthereumService();
    channelEthereumService.setChannelService(service);
    Web3AsyncThreadPoolSize.web3AsyncCorePoolSize = 3000;
    Web3AsyncThreadPoolSize.web3AsyncPoolSize = 2000;
    ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(500);
    web3 = Web3j.build(channelEthereumService, 15 * 100, scheduledExecutorService, Integer.parseInt(groupId));
    credentials = GenCredential.create();
    transactionManager = Contract.getTheTransactionManager(web3, credentials);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Service(org.fisco.bcos.channel.client.Service) ChannelEthereumService(org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService) ChannelEthereumService(org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService)

Aggregations

ChannelEthereumService (org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService)27 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)25 ApplicationContext (org.springframework.context.ApplicationContext)24 Service (org.fisco.bcos.channel.client.Service)23 Web3j (org.fisco.bcos.web3j.protocol.Web3j)17 BigInteger (java.math.BigInteger)15 Credentials (org.fisco.bcos.web3j.crypto.Credentials)12 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)11 TransactionReceipt (org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt)10 RateLimiter (com.google.common.util.concurrent.RateLimiter)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)9 Random (java.util.Random)6 StaticGasProvider (org.fisco.bcos.web3j.tx.gas.StaticGasProvider)5 TransactionException (org.fisco.bcos.web3j.protocol.exceptions.TransactionException)4 SecureRandom (java.security.SecureRandom)2 ECKeyPair (org.fisco.bcos.web3j.crypto.ECKeyPair)2 EncryptType (org.fisco.bcos.web3j.crypto.EncryptType)2 DefaultBlockParameter (org.fisco.bcos.web3j.protocol.core.DefaultBlockParameter)2 ContractGasProvider (org.fisco.bcos.web3j.tx.gas.ContractGasProvider)2