<commit_before>package com.ethercamp.starter.ethereum;

import org.ethereum.core.Block;
import org.ethereum.core.Transaction;
import org.ethereum.core.TransactionInfo;
import org.ethereum.facade.Blockchain;
import org.ethereum.facade.Ethereum;
import org.ethereum.facade.EthereumFactory;
import org.ethereum.mine.BlockMiner;
import org.ethereum.mine.Ethash;
import org.ethereum.mine.MinerListener;
import org.ethereum.util.ByteUtil;
import org.spongycastle.util.encoders.Hex;

import java.util.LinkedList;
import java.util.List;


public class EthereumBean {

    public Ethereum ethereum;
    public BlockMiner blockMiner;

    public void start(){
        this.ethereum = EthereumFactory.createEthereum();
        this.ethereum.addListener(new EthereumListener(ethereum));
    }

    public String getBestBlock(){
        return "" + ethereum.getBlockchain().getBestBlock().getNumber() + "\n"
                + ethereum.getBlockchain().getBestBlock().toString();
    }

    public String getBlockByNumber(int index){
        return ethereum.getBlockchain().getBlockByNumber(index).toString();
    }

    public String getBlockByHash(byte[] hash){
        return ethereum.getBlockchain().getBlockByHash(hash).toString();
    }

    public String getTransactionInfo(byte[] hash){
        TransactionInfo transactionInfo = ((org.ethereum.core.Blockchain)(ethereum.getBlockchain())).getTransactionInfo(hash);
        return transactionInfo.getReceipt().getTransaction().toString() + "\n"
                + transactionInfo.getReceipt().toString();
    }

    public List<Transaction> getTransactionHistory(byte[] receive){
        List<Transaction> transactionList = new LinkedList<>();
        Blockchain blockchain = ethereum.getBlockchain();

        for(long i=blockchain.getBestBlock().getNumber(); i>=0; --i){
            Block block = blockchain.getBlockByNumber(i);
            List<Transaction> blockTxList = block.getTransactionsList();

            for(int j=blockTxList.size()-1; j>=0; --j){
                Transaction tx = blockTxList.get(j);
                if(tx.getReceiveAddress().equals(receive)){
                    transactionList.add(tx);
                }
            }
        }

        return transactionList;
    }

    public List<Transaction> getTransactionHistoryTrack(byte[] receive){
        List<Transaction> transactionList = new LinkedList<>();
        Blockchain blockchain = ethereum.getBlockchain();

        for(long i=blockchain.getBestBlock().getNumber(); i>=0; --i){
            Block block = blockchain.getBlockByNumber(i);
            List<Transaction> blockTxList = block.getTransactionsList();

            for(int j=blockTxList.size()-1; j>=0; --j){
                Transaction tx = blockTxList.get(j);
                if(tx.getReceiveAddress().equals(receive)){
                    transactionList.add(tx);
                    receive = tx.getSender();
                }
            }
        }

        return transactionList;
    }

    public BlockMiner getBlockMiner(){
        return ethereum.getBlockMiner();
    }

    public void startMining(){
        if(blockMiner == null) {

            blockMiner = ethereum.getBlockMiner();
            blockMiner.addListener(new MinerListener() {
                @Override
                public void miningStarted() {
                    System.out.println("=== Miner.miningStarted");
                }

                @Override
                public void miningStopped() {
                    System.out.println("=== Miner.miningStopped");
                }

                @Override
                public void blockMiningStarted(Block block) {<commit_msg>fix issue about how to compare the Java Byte[] array<commit_after>package com.ethercamp.starter.ethereum;

import org.ethereum.core.Block;
import org.ethereum.core.Transaction;
import org.ethereum.core.TransactionInfo;
import org.ethereum.facade.Blockchain;
import org.ethereum.facade.Ethereum;
import org.ethereum.facade.EthereumFactory;
import org.ethereum.mine.BlockMiner;
import org.ethereum.mine.Ethash;
import org.ethereum.mine.MinerListener;
import org.ethereum.util.ByteUtil;
import org.spongycastle.util.encoders.Hex;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;


public class EthereumBean {

    public Ethereum ethereum;
    public BlockMiner blockMiner;

    public void start(){
        this.ethereum = EthereumFactory.createEthereum();
        this.ethereum.addListener(new EthereumListener(ethereum));
    }

    public String getBestBlock(){
        return "" + ethereum.getBlockchain().getBestBlock().getNumber() + "\n"
                + ethereum.getBlockchain().getBestBlock().toString();
    }

    public String getBlockByNumber(int index){
        return ethereum.getBlockchain().getBlockByNumber(index).toString();
    }

    public String getBlockByHash(byte[] hash){
        return ethereum.getBlockchain().getBlockByHash(hash).toString();
    }

    public String getTransactionInfo(byte[] hash){
        TransactionInfo transactionInfo = ((org.ethereum.core.Blockchain)(ethereum.getBlockchain())).getTransactionInfo(hash);
        return transactionInfo.getReceipt().getTransaction().toString() + "\n"
                + transactionInfo.getReceipt().toString();
    }

    public List<Transaction> getTransactionHistory(byte[] receive){
        List<Transaction> transactionList = new LinkedList<>();
        Blockchain blockchain = ethereum.getBlockchain();

        for(long i=blockchain.getBestBlock().getNumber(); i>=0; --i){
            Block block = blockchain.getBlockByNumber(i);
            List<Transaction> blockTxList = block.getTransactionsList();

            for(int j=blockTxList.size()-1; j>=0; --j){
                Transaction tx = blockTxList.get(j);
                if(Arrays.equals(tx.getReceiveAddress(), receive)){
                    transactionList.add(tx);
                }
            }
        }

        return transactionList;
    }

    public List<Transaction> getTransactionHistoryTrack(byte[] receive){
        List<Transaction> transactionList = new LinkedList<>();
        Blockchain blockchain = ethereum.getBlockchain();

        for(long i=blockchain.getBestBlock().getNumber(); i>=0; --i){
            Block block = blockchain.getBlockByNumber(i);
            List<Transaction> blockTxList = block.getTransactionsList();

            for(int j=blockTxList.size()-1; j>=0; --j){
                Transaction tx = blockTxList.get(j);
                if(Arrays.equals(tx.getReceiveAddress(), receive)){
                    transactionList.add(tx);
                    receive = tx.getSender();
                }
            }
        }

        return transactionList;
    }

    public BlockMiner getBlockMiner(){
        return ethereum.getBlockMiner();
    }

    public void startMining(){
        if(blockMiner == null) {

            blockMiner = ethereum.getBlockMiner();
            blockMiner.addListener(new MinerListener() {
                @Override
                public void miningStarted() {
                    System.out.println("=== Miner.miningStarted");
                }

                @Override
                public void miningStopped() {
                    System.out.println("=== Miner.miningStopped");
                }

                @Override
                public void blockMiningStarted(Block block) {
{'fraction_non_alphanumeric': 0.11458333333333333, 'fraction_numerical': 0.0016233766233766235, 'mean_word_length': 2.4971617786187323, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4334161', 'n_tokens_mistral': 2105, 'n_tokens_neox': 1977, 'n_words': 355}