本文整理汇总了Java中org.ethereum.util.ByteUtil.merge方法的典型用法代码示例。如果您正苦于以下问题:Java ByteUtil.merge方法的具体用法?Java ByteUtil.merge怎么用?Java ByteUtil.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ethereum.util.ByteUtil
的用法示例。
在下文中一共展示了ByteUtil.merge方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeList
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public byte[] encodeList(List l) {
byte[][] elems;
if (elementType.isDynamicType()) {
elems = new byte[l.size() * 2 + 1][];
elems[0] = IntType.encodeInt(l.size());
int offset = l.size() * 32;
for (int i = 0; i < l.size(); i++) {
elems[i + 1] = IntType.encodeInt(offset);
byte[] encoded = elementType.encode(l.get(i));
elems[l.size() + i + 1] = encoded;
offset += 32 * ((encoded.length - 1) / 32 + 1);
}
} else {
elems = new byte[l.size() + 1][];
elems[0] = IntType.encodeInt(l.size());
for (int i = 0; i < l.size(); i++) {
elems[i + 1] = elementType.encode(l.get(i));
}
}
return ByteUtil.merge(elems);
}
示例2: encode
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public byte[] encode(Object value) {
if (!(value instanceof byte[])) {
throw new RuntimeException("byte[] value expected for type 'bytes'");
}
byte[] bb = (byte[]) value;
byte[] ret = new byte[((bb.length - 1) / 32 + 1) * 32]; // padding 32 bytes
System.arraycopy(bb, 0, ret, 0, bb.length);
return ByteUtil.merge(IntType.encodeInt(bb.length), ret);
}
示例3: encodeArguments
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public byte[] encodeArguments(Param[] params, Object ... args) {
if (args.length > params.length) {
throw new RuntimeException("Too many arguments: " + args.length + " > " + params.length);
}
int staticSize = 0;
int dynamicCnt = 0;
// calculating static size and number of dynamic params
for (int i = 0; i < args.length; i++) {
Param param = params[i];
if (param.type.isDynamicType()) {
dynamicCnt++;
}
staticSize += param.type.getFixedSize();
}
byte[][] bb = new byte[args.length + dynamicCnt][];
int curDynamicPtr = staticSize;
int curDynamicCnt = 0;
for (int i = 0; i < args.length; i++) {
if (params[i].type.isDynamicType()) {
byte[] dynBB = params[i].type.encode(args[i]);
bb[i] = IntType.encodeInt(curDynamicPtr);
bb[args.length + curDynamicCnt] = dynBB;
curDynamicCnt++;
curDynamicPtr += dynBB.length;
} else {
bb[i] = params[i].type.encode(args[i]);
}
}
return ByteUtil.merge(bb);
}
示例4: encode
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public byte[] encode(Object value) {
if (!(value instanceof byte[])) throw new RuntimeException("byte[] value expected for type 'bytes'");
byte[] bb = (byte[]) value;
byte[] ret = new byte[((bb.length - 1) / 32 + 1) * 32]; // padding 32 bytes
System.arraycopy(bb, 0, ret, 0, bb.length);
return ByteUtil.merge(IntType.encodeInt(bb.length), ret);
}
示例5: toByteArray
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public byte[] toByteArray() {
final byte fixedV = this.v >= 27
? (byte) (this.v - 27)
:this.v;
return ByteUtil.merge(
ByteUtil.bigIntegerToBytes(this.r),
ByteUtil.bigIntegerToBytes(this.s),
new byte[]{fixedV});
}
示例6: convertArgs
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
private Object[] convertArgs(Object[] args) {
Object[] ret = new Object[args.length];
for (int i = 0; i < args.length; i++) {
if (args[i] instanceof SolidityFunction) {
SolidityFunction f = (SolidityFunction) args[i];
ret[i] = ByteUtil.merge(f.getContract().getAddress(), f.getInterface().encodeSignature());
} else {
ret[i] = args[i];
}
}
return ret;
}
示例7: encodeArguments
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public byte[] encodeArguments(Object ... args) {
if (args.length > inputs.length) throw new RuntimeException("Too many arguments: " + args.length + " > " + inputs.length);
int staticSize = 0;
int dynamicCnt = 0;
// calculating static size and number of dynamic params
for (int i = 0; i < args.length; i++) {
Param param = inputs[i];
if (param.type.isDynamicType()) {
dynamicCnt++;
}
staticSize += param.type.getFixedSize();
}
byte[][] bb = new byte[args.length + dynamicCnt][];
int curDynamicPtr = staticSize;
int curDynamicCnt = 0;
for (int i = 0; i < args.length; i++) {
if (inputs[i].type.isDynamicType()) {
byte[] dynBB = inputs[i].type.encode(args[i]);
bb[i] = SolidityType.IntType.encodeInt(curDynamicPtr);
bb[args.length + curDynamicCnt] = dynBB;
curDynamicCnt++;
curDynamicPtr += dynBB.length;
} else {
bb[i] = inputs[i].type.encode(args[i]);
}
}
return ByteUtil.merge(bb);
}
示例8: encode
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public byte[] encode(Object ... args) {
return ByteUtil.merge(encodeSignature(), encodeArguments(args));
}
示例9: encodeCount
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
/**
* Composes value and counter into backing Source value
*/
protected byte[] encodeCount(byte[] val, int count) {
return ByteUtil.merge(RLP.encodeInt(count), val);
}
示例10: encode
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public byte[] encode(Object... args) {
return ByteUtil.merge(encodeSignature(), encodeArguments(args));
}