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


Java ByteUtil.byteArrayToLong方法代码示例

本文整理汇总了Java中org.ethereum.util.ByteUtil.byteArrayToLong方法的典型用法代码示例。如果您正苦于以下问题:Java ByteUtil.byteArrayToLong方法的具体用法?Java ByteUtil.byteArrayToLong怎么用?Java ByteUtil.byteArrayToLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ethereum.util.ByteUtil的用法示例。


在下文中一共展示了ByteUtil.byteArrayToLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TransactionReceiptDTO

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public  TransactionReceiptDTO(Block block, TransactionInfo txInfo){
    TransactionReceipt receipt = txInfo.getReceipt();

    transactionHash = toJsonHex(receipt.getTransaction().getHash());
    transactionIndex = txInfo.getIndex();
    cumulativeGasUsed = ByteUtil.byteArrayToLong(receipt.getCumulativeGas());
    gasUsed = ByteUtil.byteArrayToLong(receipt.getGasUsed());
    if (receipt.getTransaction().getContractAddress() != null)
        contractAddress = toJsonHex(receipt.getTransaction().getContractAddress());
    logs = new JsonRpc.LogFilterElement[receipt.getLogInfoList().size()];
    if (block != null) {
        blockNumber = block.getNumber();
        blockHash = toJsonHex(txInfo.getBlockHash());
        for (int i = 0; i < logs.length; i++) {
            LogInfo logInfo = receipt.getLogInfoList().get(i);
            logs[i] = new JsonRpc.LogFilterElement(logInfo, block, txInfo.getIndex(),
                    txInfo.getReceipt().getTransaction(), i);
        }
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:21,代码来源:TransactionReceiptDTO.java

示例2: decode

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
protected void decode() {
    RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0);

    peers = new ArrayList<>();
    RLPList addrs = (RLPList) paramsList.get(0);
    for (RLPElement a : addrs) {
        peers.add(PeerAddress.parse((RLPList) a));
    }
    timeout = ByteUtil.byteArrayToLong(paramsList.get(1).getRLPData());;
    if (paramsList.size() > 2) {
        key = new Key(paramsList.get(2).getRLPData());
    }
    if (paramsList.size() > 3) {
        id = ByteUtil.byteArrayToLong(paramsList.get(3).getRLPData());;
    }

    parsed = true;
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:20,代码来源:BzzPeersMessage.java

示例3: decode

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
protected void decode() {
    RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0);

    key = new Key(paramsList.get(0).getRLPData());

    if (paramsList.size() > 1) {
        id = ByteUtil.byteArrayToLong(paramsList.get(1).getRLPData());
    }
    if (paramsList.size() > 2) {
        maxSize = ByteUtil.byteArrayToLong(paramsList.get(2).getRLPData());
    }
    if (paramsList.size() > 3) {
        maxPeers = ByteUtil.byteArrayToLong(paramsList.get(3).getRLPData());
    }
    if (paramsList.size() > 4) {
        timeout = ByteUtil.byteArrayToLong(paramsList.get(3).getRLPData());
    }

    parsed = true;
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:22,代码来源:BzzRetrieveReqMessage.java

示例4: decode

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
protected void decode() {
    RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0);

    key = new Key(paramsList.get(0).getRLPData());
    data = paramsList.get(1).getRLPData();

    if (paramsList.size() > 2) {
        id = ByteUtil.byteArrayToLong(paramsList.get(2).getRLPData());
    }
    if (paramsList.size() > 3) {
        metadata = paramsList.get(2).getRLPData();
    }

    parsed = true;
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:17,代码来源:BzzStoreReqMessage.java

示例5: parse

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public void parse(byte[] data) {
    RLPList list = (RLPList) RLP.decode2OneItem(data, 0);

    RLPList nodesRLP = (RLPList) list.get(0);
    RLPItem expires = (RLPItem) list.get(1);

    nodes = new ArrayList<>();

    for (int i = 0; i < nodesRLP.size(); ++i) {
        RLPList nodeRLP = (RLPList) nodesRLP.get(i);
        Node node = new Node(nodeRLP.getRLPData());
        nodes.add(node);
    }
    this.expires = ByteUtil.byteArrayToLong(expires.getRLPData());
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:17,代码来源:NeighborsMessage.java

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

示例7: TransactionSortedSet

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public TransactionSortedSet() {
    super((tx1, tx2) -> {
        long nonceDiff = ByteUtil.byteArrayToLong(tx1.getNonce()) -
                ByteUtil.byteArrayToLong(tx2.getNonce());
        if (nonceDiff != 0) {
            return nonceDiff > 0 ? 1 : -1;
        }
        return FastByteComparisons.compareTo(tx1.getHash(), 0, 32, tx2.getHash(), 0, 32);
    });
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:11,代码来源:PendingStateImpl.java

示例8: onTransaction

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public void onTransaction(Transaction tx) {
    if (idx == -1) {
        idx = window.length - 1;
        filled = true;
        lastVal = 0;  // recalculate only 'sometimes'
    }
    window[idx--] = ByteUtil.byteArrayToLong(tx.getGasPrice());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:9,代码来源:GasPriceTracker.java

示例9: parse

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public void parse(byte[] data) {

    RLPList list = (RLPList) RLP.decode2OneItem(data, 0);

    RLPItem target = (RLPItem) list.get(0);
    RLPItem expires = (RLPItem) list.get(1);

    this.target = target.getRLPData();
    this.expires = ByteUtil.byteArrayToLong(expires.getRLPData());
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:12,代码来源:FindNodeMessage.java

示例10: parse

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public void parse(byte[] data) {
    RLPList list = (RLPList) RLP.decode2OneItem(data, 0);

    this.token = list.get(0).getRLPData();
    RLPItem expires = (RLPItem) list.get(1);
    this.expires = ByteUtil.byteArrayToLong(expires.getRLPData());
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:9,代码来源:PongMessage.java

示例11: onBlock

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public void onBlock(Block block, List<TransactionReceipt> receipts) {
    bestBlock = block;
    txCount += receipts.size();
    for (TransactionReceipt receipt : receipts) {
        gasSpent += ByteUtil.byteArrayToLong(receipt.getGasUsed());
    }
    if (syncComplete) {
        logger.info("New block: " + block.getShortDescr());
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:12,代码来源:BasicSample.java

示例12: TransactionSortedSet

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public TransactionSortedSet() {
    super(new Comparator<Transaction>() {

        @Override
        public int compare(Transaction tx1, Transaction tx2) {
            long nonceDiff = ByteUtil.byteArrayToLong(tx1.getNonce()) -
                    ByteUtil.byteArrayToLong(tx2.getNonce());
            if (nonceDiff != 0) {
                return nonceDiff > 0 ? 1 : -1;
            }
            return FastByteComparisons.compareTo(tx1.getHash(), 0, 32, tx2.getHash(), 0, 32);
        }
    });
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:15,代码来源:PendingStateImpl.java

示例13: blockInfo

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
static String blockInfo(Block b) {
    boolean ours = Hex.toHexString(b.getExtraData()).startsWith("cccccccccc");
    String txs = "Tx[";
    for (Transaction tx : b.getTransactionsList()) {
        txs += ByteUtil.byteArrayToLong(tx.getNonce()) + ", ";
    }
    txs = txs.substring(0, txs.length() - 2) + "]";
    return (ours ? "##" : "  ") + b.getShortDescr() + " " + txs;
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:10,代码来源:MinerTest.java

示例14: generalInvoke

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
private ProgramInvoke generalInvoke(Transaction tx, int txindex, Repository repository, BlockStore blockStore) {

        /***         ADDRESS op       ***/
        // YP: Get address of currently executing account.
        byte[] address = tx.isContractCreation() ? tx.getContractAddress().getBytes() : tx.getReceiveAddress().getBytes();

        /***         ORIGIN op       ***/
        // YP: This is the sender of original transaction; it is never a contract.
        byte[] origin = tx.getSender().getBytes();

        /***         CALLER op       ***/
        // YP: This is the address of the account that is directly responsible for this execution.
        byte[] caller = tx.getSender().getBytes();

        /***         BALANCE op       ***/
        byte[] balance = repository.getBalance(address).toByteArray();

        /***         GASPRICE op       ***/
        byte[] gasPrice = tx.getGasPrice();

        /*** GAS op ***/
        byte[] gas = tx.getGasLimit();

        /***        CALLVALUE op      ***/
        byte[] callValue = tx.getValue() == null ? new byte[]{0} : tx.getValue();

        /***     CALLDATALOAD  op   ***/
        /***     CALLDATACOPY  op   ***/
        /***     CALLDATASIZE  op   ***/
        byte[] data = tx.isContractCreation() ? ByteUtil.EMPTY_BYTE_ARRAY :( tx.getData() == null ? ByteUtil.EMPTY_BYTE_ARRAY : tx.getData() );
//        byte[] data =  tx.getData() == null ? ByteUtil.EMPTY_BYTE_ARRAY : tx.getData() ;

        /***    PREVHASH  op  ***/
        byte[] lastHash = env.getPreviousHash();

        /***   COINBASE  op ***/
        byte[] coinbase = env.getCurrentCoinbase();

        /*** TIMESTAMP  op  ***/
        long timestamp = ByteUtil.byteArrayToLong(env.getCurrentTimestamp());

        /*** NUMBER  op  ***/
        long number = ByteUtil.byteArrayToLong(env.getCurrentNumber());

        /*** DIFFICULTY  op  ***/
        byte[] difficulty = env.getCurrentDifficulty();

        /*** GASLIMIT op ***/
        byte[] gaslimit = env.getCurrentGasLimit();

        return new ProgramInvokeImpl(address, origin, caller, balance,
                gasPrice, gas, callValue, data, lastHash, coinbase,
                timestamp, number, txindex, difficulty, gaslimit, repository, blockStore);
    }
 
开发者ID:rsksmart,项目名称:rskj,代码行数:55,代码来源:TestProgramInvokeFactory.java

示例15: getBlockResult

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public BlockResult getBlockResult(Block b, boolean fullTx) {
    if (b==null)
        return null;
    boolean isPending = ByteUtil.byteArrayToLong(b.getNonce()) == 0;
    BlockResult br = new BlockResult();
    br.number = isPending ? null : TypeConverter.toJsonHex(b.getNumber());
    br.hash = isPending ? null : TypeConverter.toJsonHex(b.getHash());
    br.parentHash = TypeConverter.toJsonHex(b.getParentHash());
    br.nonce = isPending ? null : TypeConverter.toJsonHex(b.getNonce());
    br.sha3Uncles= TypeConverter.toJsonHex(b.getUnclesHash());
    br.logsBloom = isPending ? null : TypeConverter.toJsonHex(b.getLogBloom());
    br.transactionsRoot =TypeConverter.toJsonHex(b.getTxTrieRoot());
    br.stateRoot = TypeConverter.toJsonHex(b.getStateRoot());
    br.receiptsRoot =TypeConverter.toJsonHex(b.getReceiptsRoot());
    br.miner = isPending ? null : TypeConverter.toJsonHex(b.getCoinbase());
    br.difficulty = TypeConverter.toJsonHex(b.getDifficulty());
    br.totalDifficulty = TypeConverter.toJsonHex(blockchain.getTotalDifficulty());
    if (b.getExtraData() != null)
        br.extraData =TypeConverter.toJsonHex(b.getExtraData());
    br.size = TypeConverter.toJsonHex(b.getEncoded().length);
    br.gasLimit =TypeConverter.toJsonHex(b.getGasLimit());
    br.gasUsed =TypeConverter.toJsonHex(b.getGasUsed());
    br.timestamp =TypeConverter.toJsonHex(b.getTimestamp());

    List<Object> txes = new ArrayList<>();
    if (fullTx) {
        for (int i = 0; i < b.getTransactionsList().size(); i++) {
            txes.add(new TransactionResultDTO(b, i, b.getTransactionsList().get(i)));
        }
    } else {
        for (Transaction tx : b.getTransactionsList()) {
            txes.add(toJsonHex(tx.getHash()));
        }
    }
    br.transactions = txes.toArray();

    List<String> ul = new ArrayList<>();
    for (BlockHeader header : b.getUncleList()) {
        ul.add(toJsonHex(header.getHash()));
    }
    br.uncles = ul.toArray(new String[ul.size()]);

    return br;
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:45,代码来源:JsonRpcImpl.java


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