Skip to content
This repository has been archived by the owner on Apr 23, 2019. It is now read-only.

Commit

Permalink
Merge pull request #80 from cleishm/coroutine-no-experimental
Browse files Browse the repository at this point in the history
 Move classes using coroutines out of experimental
  • Loading branch information
cleishm committed Nov 2, 2018
2 parents 23ee683 + 05a6d12 commit 09236c0
Show file tree
Hide file tree
Showing 46 changed files with 351 additions and 714 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -9,7 +9,8 @@
.classpath
.externalToolBuilders/
.gradle/
.idea/
.idea/*
!.idea/codeStyles/
.loadpath
.metadata
.prefs
Expand Down
12 changes: 12 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -18,14 +18,13 @@
import net.consensys.cava.bytes.Bytes;
import net.consensys.cava.io.Resources;
import net.consensys.cava.junit.BouncyCastleExtension;
import net.consensys.cava.trie.experimental.MerklePatriciaTrie;
import net.consensys.cava.trie.MerklePatriciaTrie;

import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Stream;

import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -50,7 +49,7 @@ private Bytes readFromString(String value) {
@MethodSource("readAnyOrderTrieTests")
@SuppressWarnings({"unchecked", "rawtypes"})
void testAnyOrderTrieTrees(String name, Map input, String root) throws Exception {
MerklePatriciaTrie<String> trie = new MerklePatriciaTrie<>((Function<String, Bytes>) this::readFromString);
MerklePatriciaTrie<String> trie = MerklePatriciaTrie.create(this::readFromString);
for (Object entry : input.entrySet()) {
Map.Entry keyValue = (Map.Entry) entry;
trie.putAsync(readFromString((String) keyValue.getKey()), (String) keyValue.getValue()).join();
Expand All @@ -62,7 +61,7 @@ void testAnyOrderTrieTrees(String name, Map input, String root) throws Exception
@MethodSource("readTrieTests")
@SuppressWarnings({"unchecked", "rawtypes"})
void testTrieTrees(String name, List input, String root) throws Exception {
MerklePatriciaTrie<String> trie = new MerklePatriciaTrie<>((Function<String, Bytes>) this::readFromString);
MerklePatriciaTrie<String> trie = MerklePatriciaTrie.create(this::readFromString);
for (Object entry : input) {
List keyValue = (List) entry;
trie.putAsync(readFromString((String) keyValue.get(0)), (String) keyValue.get(1)).join();
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
@@ -0,0 +1 @@
kotlin.code.style=official
46 changes: 0 additions & 46 deletions kv/src/main/java/net/consensys/cava/kv/KeyValueStore.java

This file was deleted.

47 changes: 0 additions & 47 deletions kv/src/main/java/net/consensys/cava/kv/LevelDBKeyValueStore.java

This file was deleted.

33 changes: 0 additions & 33 deletions kv/src/main/java/net/consensys/cava/kv/MapDBKeyValueStore.java

This file was deleted.

44 changes: 0 additions & 44 deletions kv/src/main/java/net/consensys/cava/kv/MapKeyValueStore.java

This file was deleted.

75 changes: 0 additions & 75 deletions kv/src/main/java/net/consensys/cava/kv/RedisKeyValueStore.java

This file was deleted.

Expand Up @@ -10,7 +10,7 @@
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package net.consensys.cava.kv.experimental
package net.consensys.cava.kv

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
Expand All @@ -20,13 +20,12 @@ import net.consensys.cava.concurrent.AsyncCompletion
import net.consensys.cava.concurrent.AsyncResult
import net.consensys.cava.concurrent.coroutines.asyncCompletion
import net.consensys.cava.concurrent.coroutines.asyncResult
import java.io.Closeable

/**
* A key-value store.
*
* This interface extends [net.consensys.cava.kv.KeyValueStore], exposing co-routine based access methods.
*/
interface KeyValueStore : net.consensys.cava.kv.KeyValueStore {
interface KeyValueStore : Closeable {

/**
* Retrieves data from the store.
Expand All @@ -43,7 +42,7 @@ interface KeyValueStore : net.consensys.cava.kv.KeyValueStore {
* @return An [AsyncResult] that will complete with the stored content,
* or an empty optional if no content was available.
*/
override fun getAsync(key: Bytes): AsyncResult<Bytes?> = getAsync(Dispatchers.Default, key)
fun getAsync(key: Bytes): AsyncResult<Bytes?> = getAsync(Dispatchers.Default, key)

/**
* Retrieves data from the store.
Expand Down Expand Up @@ -74,7 +73,7 @@ interface KeyValueStore : net.consensys.cava.kv.KeyValueStore {
* @param value The data to store.
* @return An [AsyncCompletion] that will complete when the content is stored.
*/
override fun putAsync(key: Bytes, value: Bytes): AsyncCompletion = putAsync(Dispatchers.Default, key, value)
fun putAsync(key: Bytes, value: Bytes): AsyncCompletion = putAsync(Dispatchers.Default, key, value)

/**
* Puts data into the store.
Expand Down

0 comments on commit 09236c0

Please sign in to comment.