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


Java ByteUtil.merge方法代码示例

本文整理汇总了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);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:24,代码来源:SolidityType.java

示例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);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:12,代码来源:SolidityType.java

示例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);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:34,代码来源:CallTransaction.java

示例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);
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:10,代码来源:SolidityType.java

示例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});
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:11,代码来源:ECKey.java

示例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;
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:13,代码来源:StandaloneBlockchain.java

示例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);
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:32,代码来源:CallTransaction.java

示例8: encode

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public byte[] encode(Object ... args) {
    return ByteUtil.merge(encodeSignature(), encodeArguments(args));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:4,代码来源:CallTransaction.java

示例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);
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:7,代码来源:CountingBytesSource.java

示例10: encode

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public byte[] encode(Object... args) {
    return ByteUtil.merge(encodeSignature(), encodeArguments(args));
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:4,代码来源:Abi.java


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