nfmelendez commented on a change in pull request #194:
URL: https://github.com/apache/incubator-tuweni/pull/194#discussion_r569475522



##########
File path: 
eth-client/src/main/kotlin/org/apache/tuweni/ethclient/FromBestBlockSynchronizer.kt
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on 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 org.apache.tuweni.ethclient
+
+import kotlinx.coroutines.asCoroutineDispatcher
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.launch
+import org.apache.tuweni.devp2p.eth.EthClient
+import org.apache.tuweni.eth.repository.BlockchainRepository
+import java.util.concurrent.ExecutorService
+import java.util.concurrent.Executors
+import kotlin.coroutines.CoroutineContext
+
+const val BEST_PEER_DELAY: Long = 5000
+
+class FromBestBlockSynchronizer(
+  executor: ExecutorService = Executors.newFixedThreadPool(1),

Review comment:
       may be use newSingleThreadExecutor  unless you want to reconfigurate 
later
   
   public static ExecutorService newSingleThreadExecutor()
   
   Creates an Executor that uses a single worker thread operating off an 
unbounded queue. (Note however that if this single thread terminates due to a 
failure during execution prior to shutdown, a new one will take its place if 
needed to execute subsequent tasks.) Tasks are guaranteed to execute 
sequentially, and no more than one task will be active at any given time. 
Unlike the otherwise equivalent newFixedThreadPool(1) the returned executor is 
guaranteed not to be reconfigurable to use additional threads.

##########
File path: 
eth-client/src/main/kotlin/org/apache/tuweni/ethclient/Synchronizer.kt
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on 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 org.apache.tuweni.ethclient
+
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.asCoroutineDispatcher
+import kotlinx.coroutines.launch
+import org.apache.tuweni.devp2p.eth.EthClient
+import org.apache.tuweni.eth.BlockHeader
+import org.apache.tuweni.eth.Hash
+import org.apache.tuweni.eth.repository.BlockchainRepository
+import org.slf4j.LoggerFactory
+import java.util.concurrent.ExecutorService
+import java.util.concurrent.Executors
+import kotlin.coroutines.CoroutineContext
+
+val logger = LoggerFactory.getLogger(Synchronizer::class.java)
+
+abstract class Synchronizer(
+  val executor: ExecutorService = Executors.newFixedThreadPool(1),

Review comment:
       may be use newSingleThreadExecutor  unless you want to reconfigurate 
later
   
   public static ExecutorService newSingleThreadExecutor()
   
   Creates an Executor that uses a single worker thread operating off an 
unbounded queue. (Note however that if this single thread terminates due to a 
failure during execution prior to shutdown, a new one will take its place if 
needed to execute subsequent tasks.) Tasks are guaranteed to execute 
sequentially, and no more than one task will be active at any given time. 
Unlike the otherwise equivalent newFixedThreadPool(1) the returned executor is 
guaranteed not to be reconfigurable to use additional threads.

##########
File path: 
eth-client/src/main/kotlin/org/apache/tuweni/ethclient/FromBestBlockSynchronizer.kt
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on 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 org.apache.tuweni.ethclient
+
+import kotlinx.coroutines.asCoroutineDispatcher
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.launch
+import org.apache.tuweni.devp2p.eth.EthClient
+import org.apache.tuweni.eth.repository.BlockchainRepository
+import java.util.concurrent.ExecutorService
+import java.util.concurrent.Executors
+import kotlin.coroutines.CoroutineContext
+
+const val BEST_PEER_DELAY: Long = 5000

Review comment:
       can the parameter be in a config file?

##########
File path: 
eth-client/src/main/kotlin/org/apache/tuweni/ethclient/FromUnknownParentSynchronizer.kt
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on 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 org.apache.tuweni.ethclient
+
+import kotlinx.coroutines.asCoroutineDispatcher
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.launch
+import org.apache.tuweni.devp2p.eth.EthClient
+import org.apache.tuweni.eth.BlockHeader
+import org.apache.tuweni.eth.repository.BlockchainRepository
+import java.util.concurrent.ExecutorService
+import java.util.concurrent.Executors
+import kotlin.coroutines.CoroutineContext
+
+const val DELAY: Long = 1000
+const val HEADER_PARENT_HEADER_REQUEST_SIZE: Long = 64
+
+class FromUnknownParentSynchronizer(
+  executor: ExecutorService = Executors.newFixedThreadPool(1),

Review comment:
       may be use newSingleThreadExecutor  unless you want to reconfigurate 
later
   
   public static ExecutorService newSingleThreadExecutor()
   
   Creates an Executor that uses a single worker thread operating off an 
unbounded queue. (Note however that if this single thread terminates due to a 
failure during execution prior to shutdown, a new one will take its place if 
needed to execute subsequent tasks.) Tasks are guaranteed to execute 
sequentially, and no more than one task will be active at any given time. 
Unlike the otherwise equivalent newFixedThreadPool(1) the returned executor is 
guaranteed not to be reconfigurable to use additional threads.

##########
File path: 
eth-client/src/main/kotlin/org/apache/tuweni/ethclient/PeerStatusEthSynchronizer.kt
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on 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 org.apache.tuweni.ethclient
+
+import kotlinx.coroutines.asCoroutineDispatcher
+import kotlinx.coroutines.launch
+import org.apache.tuweni.devp2p.eth.EthClient
+import org.apache.tuweni.eth.Hash
+import org.apache.tuweni.eth.repository.BlockchainRepository
+import java.util.concurrent.ExecutorService
+import java.util.concurrent.Executors
+import kotlin.coroutines.CoroutineContext
+
+const val HEADER_REQUEST_SIZE = 1024L
+
+/**
+ * Synchronizer responsible for pulling blocks until such time the highest 
known block is met, or close enough.
+ *
+ * Listens to new status messages, and syncs backwards from them.
+ *
+ */
+class PeerStatusEthSynchronizer(
+  executor: ExecutorService = Executors.newFixedThreadPool(1),

Review comment:
       may be use newSingleThreadExecutor  unless you want to reconfigurate 
later
   
   public static ExecutorService newSingleThreadExecutor()
   
   Creates an Executor that uses a single worker thread operating off an 
unbounded queue. (Note however that if this single thread terminates due to a 
failure during execution prior to shutdown, a new one will take its place if 
needed to execute subsequent tasks.) Tasks are guaranteed to execute 
sequentially, and no more than one task will be active at any given time. 
Unlike the otherwise equivalent newFixedThreadPool(1) the returned executor is 
guaranteed not to be reconfigurable to use additional threads.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tuweni.apache.org
For additional commands, e-mail: dev-h...@tuweni.apache.org

Reply via email to