Package org.ethereum.db

Examples of org.ethereum.db.ByteArrayWrapper


        for (int i = 0; i < size; ++i) {

            String keyS = keys[i].toString();
            String valS =  store.get(keys[i]).toString();

            ByteArrayWrapper key;
            boolean hexVal = Pattern.matches("0[xX][0-9a-fA-F]+", keyS);
            if (hexVal) {
                key = new ByteArrayWrapper(Hex.decode(keyS.substring(2)));
            } else {
              byte[] data;
                if (keyS != null && keyS.length() > 2)
                    data    = Hex.decode(keyS);
                else
                    data   = ByteUtil.EMPTY_BYTE_ARRAY;
                key = new ByteArrayWrapper(data);
            }

            ByteArrayWrapper value;
            hexVal = Pattern.matches("0[xX][0-9a-fA-F]+", valS);
            if (hexVal) {
                value = new ByteArrayWrapper(Hex.decode(valS.substring(2)));
            } else {
                byte[] data = ByteUtil.bigIntegerToBytes(new BigInteger(valS));
                value = new ByteArrayWrapper(data);
            }
            storage.put(key, value);
        }
    }
View Full Code Here


        String expectedNonce  = "01";
        String expectedBalance = "0de0b6b3a763ff6c";
        String expectedCode    = "6000600060006000604a3360c85c03f1";

        ByteArrayWrapper expectedKey1 = new ByteArrayWrapper(Hex.decode("ffaa"));
        ByteArrayWrapper expectedKey2 = new ByteArrayWrapper(Hex.decode("ffab"));

        ByteArrayWrapper expectedVal1 = new ByteArrayWrapper(Hex.decode("c8"));
        ByteArrayWrapper expectedVal2 = new ByteArrayWrapper(Hex.decode("b2b2b2"));

        JSONParser parser = new JSONParser();
        String accountString = "{'balance':999999999999999852,'nonce':1," +
                "'code':'0x6000600060006000604a3360c85c03f1'," +
                "'storage':{'0xffaa' : '0xc8', '0xffab' : '0xb2b2b2'}}";
View Full Code Here

                byte[] keyBytes = Hex.decode(key.toString());
                AccountState accountState =
                        new AccountState(keyBytes, (JSONObjectpreJSON.get(key));

                pre.put(new ByteArrayWrapper(keyBytes), accountState);
            }

            for (Object key : postJSON.keySet()){

                byte[] keyBytes = Hex.decode(key.toString());
                AccountState accountState =
                        new AccountState(keyBytes, (JSONObjectpostJSON.get(key));

                post.put(new ByteArrayWrapper(keyBytes), accountState);
            }

            for (int i = 0; i < callCreates.size(); ++i){

                CallCreate cc = new CallCreate((JSONObject)callCreates.get(i));
View Full Code Here

  public Object put(Object o) {
    Value value = new Value(o);
    byte[] enc = value.encode();
    if (enc.length >= 32) {
      byte[] sha = HashUtil.sha3(enc);
      this.nodes.put(new ByteArrayWrapper(sha), new Node(value, true));
      this.isDirty = true;
      return sha;
    }
    return value;
  }
View Full Code Here

    }
    return value;
  }

  public Value get(byte[] key) {
    ByteArrayWrapper keyObj = new ByteArrayWrapper(key);
    // First check if the key is the cache
    if (this.nodes.get(keyObj) != null) {
      return this.nodes.get(keyObj).getValue();
    }
View Full Code Here

    return value;
  }

  public void delete(byte[] key) {
    ByteArrayWrapper keyObj = new ByteArrayWrapper(key);
    this.nodes.remove(keyObj);

        if (db == null) return;
    this.db.delete(key);
  }
View Full Code Here

    }

    @Override
    public byte[] get(byte[] arg0) throws DBException {

        return storage.get(new ByteArrayWrapper(arg0));
    }
View Full Code Here

    }

    @Override
    public void put(byte[] key, byte[] value) throws DBException {

        storage.put(new ByteArrayWrapper(key), value);
    }
View Full Code Here

    byte[] test1 = Hex.decode(block);
    byte[] test2 = Hex.decode(block);
    byte[] test3 = Hex.decode("4ff8bad7758c65b25e2191308227d2c0");
    byte[] test4 = Hex.decode("");
   
    wrapper1 = new ByteArrayWrapper(test1);
    wrapper2 = new ByteArrayWrapper(test2);
    wrapper3 = new ByteArrayWrapper(test3);
    wrapper4 = new ByteArrayWrapper(test4);
  }
View Full Code Here

    public void add(Block block){
        logger.info("adding block to alt chain block.hash: [{}] ", block.getShortHash());
        totalDifficulty = totalDifficulty.add(block.getCumulativeDifficulty());
        logger.info("total difficulty on alt chain is: [{}] ", totalDifficulty);
        chain.add(block);
        index.put(new ByteArrayWrapper(block.getHash()), block);
    }
View Full Code Here

TOP

Related Classes of org.ethereum.db.ByteArrayWrapper

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.