当前位置: 首页>>代码示例>>Java>>正文


Java EthVersion类代码示例

本文整理汇总了Java中org.ethereum.net.eth.EthVersion的典型用法代码示例。如果您正苦于以下问题:Java EthVersion类的具体用法?Java EthVersion怎么用?Java EthVersion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EthVersion类属于org.ethereum.net.eth包,在下文中一共展示了EthVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: activateEth

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
public void activateEth(ChannelHandlerContext ctx, EthVersion version) {
    EthHandler handler = ethHandlerFactory.create(version);
    MessageFactory messageFactory = createEthMessageFactory(version);
    messageCodec.setEthVersion(version);
    messageCodec.setEthMessageFactory(messageFactory);

    logger.info("Eth{} [ address = {} | id = {} ]", handler.getVersion(), inetSocketAddress, getPeerIdShort());

    ctx.pipeline().addLast(Capability.RSK, handler);

    handler.setMsgQueue(msgQueue);
    handler.setChannel(this);
    handler.setPeerDiscoveryMode(discoveryMode);

    handler.activate();

    eth = handler;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:19,代码来源:Channel.java

示例2: test2

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
@Test
public void test2() {

    //Init
    byte version = 2;
    String clientStr = "Ethereum(++)/v0.7.9/Release/Linux/g++";
    List<Capability> capabilities = Arrays.asList(
            new Capability(Capability.RSK, EthVersion.UPPER),
            new Capability(Capability.P2P, P2pHandler.VERSION));
    int listenPort = 992;
    String peerId = "1fbf1e41f08078918c9f7b6734594ee56d7f538614f602c71194db0a1af5a";

    HelloMessage helloMessage = new HelloMessage(version, clientStr, capabilities, listenPort, peerId);
    logger.info(helloMessage.toString());

    assertEquals(P2pMessageCodes.HELLO, helloMessage.getCommand());
    assertEquals(version, helloMessage.getP2PVersion());
    assertEquals(clientStr, helloMessage.getClientId());
    assertEquals(2, helloMessage.getCapabilities().size());
    assertEquals(listenPort, helloMessage.getListenPort());
    assertEquals(peerId, helloMessage.getPeerId());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:23,代码来源:HelloMessageTest.java

示例3: test4

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
@Test
public void test4() {

    List<Capability> capabilities = Arrays.asList(
            new Capability(Capability.RSK, EthVersion.V62.getCode()));

    messageCodesResolver.init(capabilities);

    assertEquals(0x10 + 0, messageCodesResolver.withEthOffset(EthMessageCodes.STATUS.asByte()));
    assertEquals(0x10 + 1, messageCodesResolver.withEthOffset(EthMessageCodes.NEW_BLOCK_HASHES.asByte()));
    assertEquals(0x10 + 2, messageCodesResolver.withEthOffset(EthMessageCodes.TRANSACTIONS.asByte()));
    assertEquals(0x10 + 3, messageCodesResolver.withEthOffset(EthMessageCodes.GET_BLOCK_HEADERS.asByte()));
    assertEquals(0x10 + 4, messageCodesResolver.withEthOffset(EthMessageCodes.BLOCK_HEADERS.asByte()));
    assertEquals(0x10 + 5, messageCodesResolver.withEthOffset(EthMessageCodes.GET_BLOCK_BODIES.asByte()));
    assertEquals(0x10 + 6, messageCodesResolver.withEthOffset(EthMessageCodes.BLOCK_BODIES.asByte()));
    assertEquals(0x10 + 7, messageCodesResolver.withEthOffset(EthMessageCodes.NEW_BLOCK.asByte()));

}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:19,代码来源:AdaptiveMessageIdsTest.java

示例4: test5

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
@Test // Capabilities should be read in alphabetical order
public void test5() {

    List<Capability> capabilities = Arrays.asList(
            new Capability(Capability.RSK, EthVersion.V62.getCode()));

    messageCodesResolver.init(capabilities);

    assertEquals(0x10 + 0, messageCodesResolver.withEthOffset(EthMessageCodes.STATUS.asByte()));
    assertEquals(0x10 + 1, messageCodesResolver.withEthOffset(EthMessageCodes.NEW_BLOCK_HASHES.asByte()));
    assertEquals(0x10 + 2, messageCodesResolver.withEthOffset(EthMessageCodes.TRANSACTIONS.asByte()));
    assertEquals(0x10 + 3, messageCodesResolver.withEthOffset(EthMessageCodes.GET_BLOCK_HEADERS.asByte()));
    assertEquals(0x10 + 4, messageCodesResolver.withEthOffset(EthMessageCodes.BLOCK_HEADERS.asByte()));
    assertEquals(0x10 + 5, messageCodesResolver.withEthOffset(EthMessageCodes.GET_BLOCK_BODIES.asByte()));
    assertEquals(0x10 + 6, messageCodesResolver.withEthOffset(EthMessageCodes.BLOCK_BODIES.asByte()));
    assertEquals(0x10 + 7, messageCodesResolver.withEthOffset(EthMessageCodes.NEW_BLOCK.asByte()));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:18,代码来源:AdaptiveMessageIdsTest.java

示例5: init

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
public void init(List<Capability> caps) {
    Collections.sort(caps);
    int offset = P2pMessageCodes.USER.asByte() + 1;

    for (Capability capability : caps) {
        if (capability.getName().equals(Capability.ETH)) {
            setEthOffset(offset);
            EthVersion v = fromCode(capability.getVersion());
            offset += EthMessageCodes.values(v).length;
        }

        if (capability.getName().equals(Capability.SHH)) {
            setShhOffset(offset);
            offset += ShhMessageCodes.values().length;
        }

        if (capability.getName().equals(Capability.BZZ)) {
            setBzzOffset(offset);
            offset += BzzMessageCodes.values().length + 4;
            // FIXME: for some reason Go left 4 codes between BZZ and ETH message codes
        }
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:24,代码来源:MessageCodesResolver.java

示例6: activateEth

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
public void activateEth(ChannelHandlerContext ctx, EthVersion version) {
    EthHandler handler = ethHandlerFactory.create(version);
    MessageFactory messageFactory = createEthMessageFactory(version);
    messageCodec.setEthVersion(version);
    messageCodec.setEthMessageFactory(messageFactory);

    logger.debug("Eth{} [ address = {} | id = {} ]", handler.getVersion(), inetSocketAddress, getPeerIdShort());

    ctx.pipeline().addLast(Capability.ETH, handler);

    handler.setMsgQueue(msgQueue);
    handler.setChannel(this);
    handler.setPeerDiscoveryMode(discoveryMode);

    handler.activate();

    eth = handler;
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:19,代码来源:Channel.java

示例7: test2

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
@Test
public void test2() {

    //Init
    byte version = 2;
    String clientStr = "Ethereum(++)/v0.7.9/Release/Linux/g++";
    List<Capability> capabilities = Arrays.asList(
            new Capability(Capability.ETH, EthVersion.UPPER),
            new Capability(Capability.SHH, ShhHandler.VERSION),
            new Capability(Capability.P2P, P2pHandler.VERSION));
    int listenPort = 992;
    String peerId = "1fbf1e41f08078918c9f7b6734594ee56d7f538614f602c71194db0a1af5a";

    HelloMessage helloMessage = new HelloMessage(version, clientStr, capabilities, listenPort, peerId);
    logger.info(helloMessage.toString());

    assertEquals(P2pMessageCodes.HELLO, helloMessage.getCommand());
    assertEquals(version, helloMessage.getP2PVersion());
    assertEquals(clientStr, helloMessage.getClientId());
    assertEquals(3, helloMessage.getCapabilities().size());
    assertEquals(listenPort, helloMessage.getListenPort());
    assertEquals(peerId, helloMessage.getPeerId());
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:24,代码来源:HelloMessageTest.java

示例8: test4

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
@Test
public void test4() {

    List<Capability> capabilities = Arrays.asList(
            new Capability(Capability.ETH, EthVersion.V62.getCode()),
            new Capability(Capability.SHH, ShhHandler.VERSION));

    messageCodesResolver.init(capabilities);

    assertEquals(0x10 + 0, messageCodesResolver.withEthOffset(EthMessageCodes.STATUS.asByte()));
    assertEquals(0x10 + 1, messageCodesResolver.withEthOffset(EthMessageCodes.NEW_BLOCK_HASHES.asByte()));
    assertEquals(0x10 + 2, messageCodesResolver.withEthOffset(EthMessageCodes.TRANSACTIONS.asByte()));
    assertEquals(0x10 + 3, messageCodesResolver.withEthOffset(EthMessageCodes.GET_BLOCK_HEADERS.asByte()));
    assertEquals(0x10 + 4, messageCodesResolver.withEthOffset(EthMessageCodes.BLOCK_HEADERS.asByte()));
    assertEquals(0x10 + 5, messageCodesResolver.withEthOffset(EthMessageCodes.GET_BLOCK_BODIES.asByte()));
    assertEquals(0x10 + 6, messageCodesResolver.withEthOffset(EthMessageCodes.BLOCK_BODIES.asByte()));
    assertEquals(0x10 + 7, messageCodesResolver.withEthOffset(EthMessageCodes.NEW_BLOCK.asByte()));

    assertEquals(0x18 + 0, messageCodesResolver.withShhOffset(ShhMessageCodes.STATUS.asByte()));
    assertEquals(0x18 + 1, messageCodesResolver.withShhOffset(ShhMessageCodes.MESSAGE.asByte()));
    assertEquals(0x18 + 2, messageCodesResolver.withShhOffset(ShhMessageCodes.FILTER.asByte()));
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:23,代码来源:AdaptiveMessageIdsTest.java

示例9: test5

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
@Test // Capabilities should be read in alphabetical order
public void test5() {

    List<Capability> capabilities = Arrays.asList(
            new Capability(Capability.SHH, ShhHandler.VERSION),
            new Capability(Capability.ETH, EthVersion.V62.getCode()));

    messageCodesResolver.init(capabilities);

    assertEquals(0x10 + 0, messageCodesResolver.withEthOffset(EthMessageCodes.STATUS.asByte()));
    assertEquals(0x10 + 1, messageCodesResolver.withEthOffset(EthMessageCodes.NEW_BLOCK_HASHES.asByte()));
    assertEquals(0x10 + 2, messageCodesResolver.withEthOffset(EthMessageCodes.TRANSACTIONS.asByte()));
    assertEquals(0x10 + 3, messageCodesResolver.withEthOffset(EthMessageCodes.GET_BLOCK_HEADERS.asByte()));
    assertEquals(0x10 + 4, messageCodesResolver.withEthOffset(EthMessageCodes.BLOCK_HEADERS.asByte()));
    assertEquals(0x10 + 5, messageCodesResolver.withEthOffset(EthMessageCodes.GET_BLOCK_BODIES.asByte()));
    assertEquals(0x10 + 6, messageCodesResolver.withEthOffset(EthMessageCodes.BLOCK_BODIES.asByte()));
    assertEquals(0x10 + 7, messageCodesResolver.withEthOffset(EthMessageCodes.NEW_BLOCK.asByte()));

    assertEquals(0x18 + 0, messageCodesResolver.withShhOffset(ShhMessageCodes.STATUS.asByte()));
    assertEquals(0x18 + 1, messageCodesResolver.withShhOffset(ShhMessageCodes.MESSAGE.asByte()));
    assertEquals(0x18 + 2, messageCodesResolver.withShhOffset(ShhMessageCodes.FILTER.asByte()));
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:23,代码来源:AdaptiveMessageIdsTest.java

示例10: create

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
@Override
public EthHandler create(EthVersion version) {
    switch (version) {
        case V62:
            return rskWireProtocolFactory.newInstance();

        default:    throw new IllegalArgumentException("Eth " + version + " is not supported");
    }
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:10,代码来源:EthHandlerFactoryImpl.java

示例11: EthHandler

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
protected EthHandler(Blockchain blockchain, SystemProperties config, CompositeEthereumListener ethereumListener, EthVersion version) {
    this.ethereumListener = ethereumListener;
    this.version = version;
    maxHashesAsk = config.maxHashesAsk();
    bestBlock = blockchain.getBestBlock();
    ethereumListener.addListener(listener);
    // when sync enabled we delay transactions processing until sync is complete
    processTransactions = !config.isSyncEnabled();
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:10,代码来源:EthHandler.java

示例12: init

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
public void init(List<Capability> caps) {
    Collections.sort(caps);
    int offset = P2pMessageCodes.USER.asByte() + 1;

    for (Capability capability : caps) {
        if (capability.getName().equals(Capability.RSK)) {
            setEthOffset(offset);
            EthVersion v = fromCode(capability.getVersion());
            offset += EthMessageCodes.values(v).length;
        }

    }
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:14,代码来源:MessageCodesResolver.java

示例13: init

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
@PostConstruct
private void init() {
    if (config.syncVersion() != null) {
        EthVersion eth = fromCode(config.syncVersion());
        if (eth != null) {
            allCaps.add(new Capability(RSK, eth.getCode()));
        }
    } else {
        for (EthVersion v : EthVersion.supported()) {
            allCaps.add(new Capability(RSK, v.getCode()));
        }
    }
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:14,代码来源:ConfigCapabilitiesImpl.java

示例14: initConfig

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
/**
 * Method to be called right after the config is instantiated.
 * Effectively is called before any other bean is initialized
 */
private void initConfig(SystemProperties config) {
    logger.info("Running {},  core version: {}-{}", config.genesisInfo(), config.projectVersion(), config.projectVersionModifier());
    BuildInfo.printInfo();

    databaseVersionHandler.process(config);

    if (logger.isInfoEnabled()) {
        StringBuilder versions = new StringBuilder();
        for (EthVersion v : EthVersion.supported()) {
            versions.append(v.getCode()).append(", ");
        }
        versions.delete(versions.length() - 2, versions.length());
        logger.info("capability eth version: [{}]", versions);
    }
    logger.info("capability shh version: [{}]", ShhHandler.VERSION);
    logger.info("capability bzz version: [{}]", BzzHandler.VERSION);

    // forcing loading blockchain config
    config.getBlockchainConfig();

    // forcing loading genesis to fail fast in case of error
    config.getGenesis();

    // forcing reading private key or generating it in database directory
    config.nodeId();

    if (logger.isDebugEnabled()) {
        logger.debug("Blockchain config {}", config.getBlockchainConfig().toString());
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:35,代码来源:Initializer.java

示例15: create

import org.ethereum.net.eth.EthVersion; //导入依赖的package包/类
@Override
public EthHandler create(EthVersion version) {
    switch (version) {
        case V62:   return (EthHandler) ctx.getBean("Eth62");
        case V63:   return (EthHandler) ctx.getBean("Eth63");
        default:    throw new IllegalArgumentException("Eth " + version + " is not supported");
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:9,代码来源:EthHandlerFactoryImpl.java


注:本文中的org.ethereum.net.eth.EthVersion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。