Package org.ethereum.net.client

Examples of org.ethereum.net.client.Capability


            RLPElement capVersion = ((RLPList)capabilityList.get(i)).get(1);
           
            String name = new String(capId.getRLPData());
            byte version = capVersion.getRLPData() == null ? 0 : capVersion.getRLPData()[0];
           
            Capability cap = new Capability(name, version);
      this.capabilities.add(cap);
    }

    byte[] peerPortBytes = ((RLPItem) paramsList.get(4)).getRLPData();
    this.listenPort = ByteUtil.byteArrayToInt(peerPortBytes);
View Full Code Here


    byte[] command = RLP.encodeByte(HELLO.asByte());
    byte[] p2pVersion = RLP.encodeByte(this.p2pVersion);
    byte[] clientId = RLP.encodeString(this.clientId);
    byte[][] capabilities = new byte[this.capabilities.size()][];
    for (int i = 0; i < this.capabilities.size(); i++) {
      Capability capability = this.capabilities.get(i);
      capabilities[i] = RLP.encodeList(
                    RLP.encodeElement(capability.getName().getBytes()),
                    RLP.encodeElement(new byte[] {capability.getVersion() }));
    }
    byte[] capabilityList = RLP.encodeList(capabilities);
    byte[] peerPort = RLP.encodeInt(this.listenPort);
    byte[] peerId = RLP.encodeElement(Hex.decode(this.peerId));
View Full Code Here

  private static HelloMessage generateHelloMessage() {
    String helloAnnouncement = buildHelloAnnouncement();
    byte p2pVersion = P2pHandler.VERSION;
    List<Capability> capabilities = Arrays.asList(
        new Capability(Capability.ETH, EthHandler.VERSION),
        new Capability(Capability.SHH, ShhHandler.VERSION));
    int listenPort = SystemProperties.CONFIG.listenPort();

    return new HelloMessage(p2pVersion, helloAnnouncement,
        capabilities, listenPort, PEER_ID);
  }
View Full Code Here

    public void test4(){

        P2pHandler p2pHandler = new P2pHandler();

    List<Capability> capabilities = Arrays.asList(
        new Capability(Capability.ETH, EthHandler.VERSION),
        new Capability(Capability.SHH, ShhHandler.VERSION));
        p2pHandler.adaptMessageIds(capabilities);

        Assert.assertEquals(0x10 + 0, EthMessageCodes.STATUS.asByte());
        Assert.assertEquals(0x10 + 1, EthMessageCodes.GET_TRANSACTIONS.asByte());
        Assert.assertEquals(0x10 + 2, EthMessageCodes.TRANSACTIONS.asByte());
View Full Code Here

    public void test5(){

        P2pHandler p2pHandler = new P2pHandler();

    List<Capability> capabilities = Arrays.asList(
        new Capability(Capability.SHH, ShhHandler.VERSION),
        new Capability(Capability.ETH, EthHandler.VERSION));
        p2pHandler.adaptMessageIds(capabilities);

        Assert.assertEquals(0x10 + 0, EthMessageCodes.STATUS.asByte());
        Assert.assertEquals(0x10 + 1, EthMessageCodes.GET_TRANSACTIONS.asByte());
        Assert.assertEquals(0x10 + 2, EthMessageCodes.TRANSACTIONS.asByte());
View Full Code Here

TOP

Related Classes of org.ethereum.net.client.Capability

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.