本文整理汇总了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;
}
示例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());
}
示例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()));
}
示例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()));
}
示例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
}
}
}
示例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;
}
示例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());
}
示例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()));
}
示例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()));
}
示例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");
}
}
示例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();
}
示例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;
}
}
}
示例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()));
}
}
}
示例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());
}
}
示例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");
}
}