本文整理汇总了Java中org.ethereum.util.ByteUtil.byteArrayToInt方法的典型用法代码示例。如果您正苦于以下问题:Java ByteUtil.byteArrayToInt方法的具体用法?Java ByteUtil.byteArrayToInt怎么用?Java ByteUtil.byteArrayToInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ethereum.util.ByteUtil
的用法示例。
在下文中一共展示了ByteUtil.byteArrayToInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
private void parse() {
RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0);
peers = new LinkedHashSet<>();
for (int i = 1; i < paramsList.size(); ++i) {
RLPList peerParams = (RLPList) paramsList.get(i);
byte[] ipBytes = peerParams.get(0).getRLPData();
byte[] portBytes = peerParams.get(1).getRLPData();
byte[] peerIdRaw = peerParams.get(2).getRLPData();
try {
int peerPort = ByteUtil.byteArrayToInt(portBytes);
InetAddress address = InetAddress.getByAddress(ipBytes);
String peerId = peerIdRaw == null ? "" : Hex.toHexString(peerIdRaw);
Peer peer = new Peer(address, peerPort, peerId);
peers.add(peer);
} catch (UnknownHostException e) {
throw new RuntimeException("Malformed ip", e);
}
}
this.parsed = true;
}
示例2: parse
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public void parse(byte[] data) {
RLPList dataList = (RLPList) RLP.decode2OneItem(data, 0);
RLPList fromList = (RLPList) dataList.get(1);
byte[] ipF = fromList.get(0).getRLPData();
this.fromHost = bytesToIp(ipF);
this.fromPort = ByteUtil.byteArrayToInt(fromList.get(1).getRLPData());
RLPList toList = (RLPList) dataList.get(2);
byte[] ipT = toList.get(0).getRLPData();
this.toHost = bytesToIp(ipT);
this.toPort = ByteUtil.byteArrayToInt(toList.get(1).getRLPData());
RLPItem expires = (RLPItem) dataList.get(3);
this.expires = ByteUtil.byteArrayToLong(expires.getRLPData());
this.version = ByteUtil.byteArrayToInt(dataList.get(0).getRLPData());
}
示例3: parse
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public final void parse(byte[] data) {
RLPList dataList = (RLPList) RLP.decode2OneItem(data, 0);
RLPList fromList = (RLPList) dataList.get(1);
RLPItem chk = (RLPItem) dataList.get(2);
byte[] ipB = fromList.get(0).getRLPData();
this.host = new String(ipB, Charset.forName("UTF-8"));
this.port = ByteUtil.byteArrayToInt(fromList.get(1).getRLPData());
this.messageId = new String(chk.getRLPData(), Charset.forName("UTF-8"));
}
示例4: parse
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public final void parse(byte[] data) {
RLPList dataList = (RLPList) RLP.decode2OneItem(data, 0);
RLPList fromList = (RLPList) dataList.get(1);
byte[] ipB = fromList.get(0).getRLPData();
this.host = new String(ipB, Charset.forName("UTF-8"));
this.port = ByteUtil.byteArrayToInt(fromList.get(1).getRLPData());
RLPItem chk = (RLPItem) dataList.get(2);
this.messageId = new String(chk.getRLPData(), Charset.forName("UTF-8"));
}
示例5: parse
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
protected void parse() {
RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0);
this.protocolVersion = paramsList.get(0).getRLPData()[0];
byte[] networkIdBytes = paramsList.get(1).getRLPData();
this.networkId = networkIdBytes == null ? 0 : ByteUtil.byteArrayToInt(networkIdBytes);
byte[] diff = paramsList.get(2).getRLPData();
this.totalDifficulty = (diff == null) ? ZERO_BYTE_ARRAY : diff;
this.bestHash = paramsList.get(3).getRLPData();
this.genesisHash = paramsList.get(4).getRLPData();
parsed = true;
}
示例6: decode
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
static AuthInitiateMessageV4 decode(byte[] wire) {
AuthInitiateMessageV4 message = new AuthInitiateMessageV4();
RLPList params = (RLPList) RLP.decode2OneItem(wire, 0);
byte[] signatureBytes = params.get(0).getRLPData();
int offset = 0;
byte[] r = new byte[32];
byte[] s = new byte[32];
System.arraycopy(signatureBytes, offset, r, 0, 32);
offset += 32;
System.arraycopy(signatureBytes, offset, s, 0, 32);
offset += 32;
int v = signatureBytes[offset] + 27;
message.signature = ECKey.ECDSASignature.fromComponents(r, s, (byte)v);
byte[] publicKeyBytes = params.get(1).getRLPData();
byte[] bytes = new byte[65];
System.arraycopy(publicKeyBytes, 0, bytes, 1, 64);
bytes[0] = 0x04; // uncompressed
message.publicKey = ECKey.CURVE.getCurve().decodePoint(bytes);
message.nonce = params.get(2).getRLPData();
byte[] versionBytes = params.get(3).getRLPData();
message.version = ByteUtil.byteArrayToInt(versionBytes);
return message;
}
示例7: parse
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
private void parse() {
RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0);
byte[] p2pVersionBytes = paramsList.get(0).getRLPData();
this.p2pVersion = p2pVersionBytes != null ? p2pVersionBytes[0] : 0;
byte[] clientIdBytes = paramsList.get(1).getRLPData();
this.clientId = new String(clientIdBytes != null ? clientIdBytes : EMPTY_BYTE_ARRAY);
RLPList capabilityList = (RLPList) paramsList.get(2);
this.capabilities = new ArrayList<>();
for (Object aCapabilityList : capabilityList) {
RLPElement capId = ((RLPList) aCapabilityList).get(0);
RLPElement capVersion = ((RLPList) aCapabilityList).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 = paramsList.get(3).getRLPData();
this.listenPort = ByteUtil.byteArrayToInt(peerPortBytes);
byte[] peerIdBytes = paramsList.get(4).getRLPData();
this.peerId = Hex.toHexString(peerIdBytes);
this.parsed = true;
}
示例8: deserialize
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public static ProgramPrecompile deserialize(byte[] stream) {
RLPList l = (RLPList) RLP.decode2(stream).get(0);
int ver = ByteUtil.byteArrayToInt(l.get(0).getRLPData());
if (ver != version) return null;
ProgramPrecompile ret = new ProgramPrecompile();
for (int i = 1; i < l.size(); i++) {
ret.jumpdest.add(ByteUtil.byteArrayToInt(l.get(i).getRLPData()));
}
return ret;
}
示例9: size
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public synchronized int size() {
if (size < 0) {
byte[] sizeBB = src.getSource().get(SIZE_KEY);
size = sizeBB == null ? 0 : ByteUtil.byteArrayToInt(sizeBB);
}
return size;
}
示例10: parse
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
static PeerAddress parse(RLPList l) {
PeerAddress ret = new PeerAddress();
ret.ip = l.get(0).getRLPData();
ret.port = ByteUtil.byteArrayToInt(l.get(1).getRLPData());
ret.id = l.get(2).getRLPData();
return ret;
}
示例11: parse
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
protected synchronized void parse() {
if (parsed) return;
RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0);
this.protocolVersion = paramsList.get(0).getRLPData()[0];
byte[] networkIdBytes = paramsList.get(1).getRLPData();
this.networkId = networkIdBytes == null ? 0 : ByteUtil.byteArrayToInt(networkIdBytes);
byte[] diff = paramsList.get(2).getRLPData();
this.totalDifficulty = (diff == null) ? ByteUtil.ZERO_BYTE_ARRAY : diff;
this.bestHash = paramsList.get(3).getRLPData();
this.genesisHash = paramsList.get(4).getRLPData();
parsed = true;
}
示例12: decode
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
static AuthResponseMessageV4 decode(byte[] wire) {
AuthResponseMessageV4 message = new AuthResponseMessageV4();
RLPList params = (RLPList) RLP.decode2OneItem(wire, 0);
byte[] pubKeyBytes = params.get(0).getRLPData();
byte[] bytes = new byte[65];
System.arraycopy(pubKeyBytes, 0, bytes, 1, 64);
bytes[0] = 0x04; // uncompressed
message.ephemeralPublicKey = ECKey.CURVE.getCurve().decodePoint(bytes);
message.nonce = params.get(1).getRLPData();
byte[] versionBytes = params.get(2).getRLPData();
message.version = ByteUtil.byteArrayToInt(versionBytes);
return message;
}
示例13: decodeCount
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
/**
* Extracts counter from the backing Source counter + value byte array
*/
protected int decodeCount(byte[] srcVal) {
return srcVal == null ? 0 : ByteUtil.byteArrayToInt((byte[]) RLP.decode(srcVal, 0).getDecoded());
}
示例14: rlpDecodeInt
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public static int rlpDecodeInt(RLPElement elem) {
byte[] b = elem.getRLPData();
if (b == null) return 0;
return ByteUtil.byteArrayToInt(b);
}
示例15: hashCode
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public int hashCode() {
return ByteUtil.byteArrayToInt(getSender()) + ByteUtil.byteArrayToInt(transaction.getNonce());
}