Commit missing MockDB changes
This commit is contained in:
parent
6c90111ea0
commit
132fab65de
|
@ -1,6 +1,8 @@
|
||||||
package org.ethereum.trie;
|
package org.ethereum.trie;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.iq80.leveldb.DB;
|
import org.iq80.leveldb.DB;
|
||||||
import org.iq80.leveldb.DBException;
|
import org.iq80.leveldb.DBException;
|
||||||
|
@ -13,11 +15,11 @@ import org.iq80.leveldb.WriteOptions;
|
||||||
|
|
||||||
public class MockDB implements DB {
|
public class MockDB implements DB {
|
||||||
|
|
||||||
private int addedItems;
|
Map<byte[], byte[]> storage = new HashMap<byte[], byte[]>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
// TODO Auto-generated method stub
|
storage.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,7 +35,7 @@ public class MockDB implements DB {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(byte[] arg0) throws DBException {
|
public void delete(byte[] arg0) throws DBException {
|
||||||
// TODO Auto-generated method stub
|
storage.remove(arg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,8 +47,7 @@ public class MockDB implements DB {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] get(byte[] arg0) throws DBException {
|
public byte[] get(byte[] arg0) throws DBException {
|
||||||
// TODO Auto-generated method stub
|
return storage.get(arg0);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -86,9 +87,8 @@ public class MockDB implements DB {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(byte[] arg0, byte[] arg1) throws DBException {
|
public void put(byte[] key, byte[] value) throws DBException {
|
||||||
// TODO Auto-generated method stub
|
storage.put(key, value);
|
||||||
addedItems++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -126,6 +126,6 @@ public class MockDB implements DB {
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public int getAddedItems() {
|
public int getAddedItems() {
|
||||||
return addedItems;
|
return storage.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue