Package org.ethereum.core

Examples of org.ethereum.core.Block


        if (chain.isEmpty()) {
            add(block);
            return true;
        }

        Block lastBlock = chain.get(chain.size() - 1);
        if (lastBlock.isParentOf(block)){
            add(block);
            return true;
        }
        return false;
    }
View Full Code Here


    RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0);

    blocks = new ArrayList<>();
    for (int i = 1; i < paramsList.size(); ++i) {
      RLPList rlpData = ((RLPList) paramsList.get(i));
      Block blockData = new Block(rlpData.getRLPData());
      blocks.add(blockData);
    }
    parsed = true;
  }
View Full Code Here

    public List<byte[]> getListOfHashesStartFrom(byte[] hash, int qty) {

        List<byte[]> hashes = new ArrayList<>();

        // find block number of that block hash
        Block block = getBlockByHash(hash);
        if (block == null) return hashes;

        List<byte[]> result = sessionFactory.getCurrentSession().
                createQuery("from BlockVO.hash where number >= :number").
                setParameter("number", block.getNumber()).
                setMaxResults(qty).list();

        for (byte[] h : result){
            hashes.add(h);
        }
View Full Code Here

                createQuery("from BlockVO where number = :number").setParameter("number", bestNumber) .list();

        if (result.isEmpty()) return null;
        BlockVO vo = (BlockVO)result.get(0);

        return new Block(vo.rlp);
    }
View Full Code Here

                P(0)
                B()
                B32(sha3(B(42)))
              )
         */
      Block genesis = Genesis.getInstance();
        logger.info("genesis hash: [{}]", Hex.toHexString(genesis.getHash()));
        logger.info("genesis rlp: [{}]", Hex.toHexString(genesis.getEncoded()));
        assertEquals(PoC7_GENESIS_HEX_HASH, Hex.toHexString(genesis.getHash()));
      assertEquals(PoC7_GENESIS_HEX_RLP_ENCODED, Hex.toHexString(genesis.getEncoded()));
    }
View Full Code Here

        List<BlockVO> result = sessionFactory.getCurrentSession().
                createQuery("from BlockVO").list();

        ArrayList<Block> blocks = new ArrayList<>();
        for (BlockVO blockVO : (List<BlockVO>)result){
            blocks.add(new Block(blockVO.getRlp()));
        }

        return blocks;
    }
View Full Code Here

    }
   
    @Test /* block without transactions - block#32 in PoC5 cpp-chain */
    public void testEmptyBlock() {
        byte[] payload = Hex.decode(block_32);
        Block blockData = new Block(payload);
        logger.info(blockData.toString());
    }
View Full Code Here

    @Test /* block with single balance transfer transaction - block#17 in PoC5 cpp-chain */
    @Ignore
    public void testSingleBalanceTransfer() {
        byte[] payload = Hex.decode(block_17); // todo: find out an uptodate block wire
        Block blockData = new Block(payload);
        logger.info(blockData.toString());
    }
View Full Code Here

    }

    @Test /* large block with 5 transactions -block#1 in PoC5 cpp-chain */
    public void testBlockWithContractCreation() {
        byte[] payload = Hex.decode(PoC7_GENESIS_HEX_RLP_ENCODED);
        Block block = new Block(payload);
        logger.info(block.toString());
    }
View Full Code Here

        BlocksMessage blocksMessage = new BlocksMessage(payload);
        List<Block> list = blocksMessage.getBlocks();
        logger.info(blocksMessage.toString());

        Block block = list.get(0);
        assertEquals(38, block.getTransactionsList().size());
        assertEquals(22783, block.getNumber());
        assertEquals("a6fa4bbd52734c654ce0f8420eecfc7b81fa23dd427829d40ee8a119039fba1a",
                Hex.toHexString(block.getHash()));
        assertEquals("54fb8d2f4641518b8ef6919fe2489e9ab85e811d32d1e95338c286779393cc06",
                Hex.toHexString(block.getStateRoot()));
    }
View Full Code Here

TOP

Related Classes of org.ethereum.core.Block

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.