You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuweni.apache.org by GitBox <gi...@apache.org> on 2021/02/03 15:00:59 UTC

[GitHub] [incubator-tuweni] nfmelendez commented on a change in pull request #194: Add syncing capabilities for mainnet

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



##########
File path: devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthRequestsManager.kt
##########
@@ -30,75 +31,126 @@ import org.apache.tuweni.rlpx.wire.WireConnection
  * Requests manager used to request and check requests of block data
  */
 interface EthRequestsManager {
+
+  /**
+   * Strategy to pick a connection.
+   * @return the connection selection strategy
+   */
+  fun connectionSelectionStrategy(): ConnectionSelectionStrategy
+
   /**
    * Requests a block header
    * @param blockHash the block hash
+   * @param connection the connection to use
    * @return a handle to the completion of the operation
    */
-  fun requestBlockHeader(blockHash: Hash): AsyncCompletion
+  fun requestBlockHeader(
+    blockHash: Hash,
+    connection: WireConnection? = connectionSelectionStrategy().selectConnection()
+  ): AsyncResult<BlockHeader>
+
   /**
    * Requests block headers
    * @param blockHashes the block hashes
+   * @param connection the connection to use
    * @return a handle to the completion of the operation
    */
-  fun requestBlockHeaders(blockHashes: List<Hash>): AsyncCompletion
+  fun requestBlockHeaders(
+    blockHashes: List<Hash>,
+    connection: WireConnection? = connectionSelectionStrategy().selectConnection()
+  ): AsyncResult<List<BlockHeader>>
+
   /**
    * Requests block headers
    * @param blockHash the hash of the block
    * @param maxHeaders the max number of headers to provide
    * @param skip the headers to skip in between each header provided
    * @param reverse whether to provide headers in forward or backwards order
+   * @param connection the connection to use
    * @return a handle to the completion of the operation
    */
-  fun requestBlockHeaders(blockHash: Hash, maxHeaders: Long, skip: Long, reverse: Boolean): AsyncCompletion
+  fun requestBlockHeaders(
+    blockHash: Hash,
+    maxHeaders: Long,
+    skip: Long,
+    reverse: Boolean,
+    connection: WireConnection? = connectionSelectionStrategy().selectConnection()
+  ): AsyncResult<List<BlockHeader>>
+
   /**
    * Requests block headers
    * @param blockNumber the number of the block
    * @param maxHeaders the max number of headers to provide
    * @param skip the headers to skip in between each header provided
    * @param reverse whether to provide headers in forward or backwards order
+   * @param connection the connection to use
    * @return a handle to the completion of the operation
    */
-  fun requestBlockHeaders(blockNumber: Long, maxHeaders: Long, skip: Long, reverse: Boolean): AsyncCompletion
+  fun requestBlockHeaders(
+    blockNumber: Long,
+    maxHeaders: Long,
+    skip: Long,
+    reverse: Boolean,
+    connection: WireConnection? = connectionSelectionStrategy().selectConnection()
+  ): AsyncResult<List<BlockHeader>>
+
   /**
    * Requests block bodies from block hashes
    * @param blockHashes the hashes of the blocks
+   * @param connection the connection to use
    * @return a handle to the completion of the operation
    */
-  fun requestBlockBodies(blockHashes: List<Hash>): AsyncCompletion
+  fun requestBlockBodies(
+    blockHashes: List<Hash>,
+    connection: WireConnection? = connectionSelectionStrategy().selectConnection()
+  ): AsyncResult<List<BlockBody>>
+
   /**
    * Requests a block from block hash
    * @param blockHash the hash of the block
+   * @param connection the connection to use
    * @return a handle to the completion of the operation
    */
-  fun requestBlock(blockHash: Hash): AsyncCompletion
+  fun requestBlock(
+    blockHash: Hash,
+    connection: WireConnection? = connectionSelectionStrategy().selectConnection()
+  ): AsyncResult<Block>
+
   /**
    * Requests transaction receipts
    * @param blockHashes the hashes to request transaction receipts for
+   * @param connection the connection to use
    * @return a handle to the completion of the operation
    */
-  fun requestTransactionReceipts(blockHashes: List<Hash>): AsyncCompletion
+  fun requestTransactionReceipts(
+    blockHashes: List<Hash>,
+    connection: WireConnection? = connectionSelectionStrategy().selectConnection()
+  ): AsyncResult<List<List<TransactionReceipt>>>
+
   /**
    * Checks if a request was made to get block headers
    * @param connection the wire connection sending data
    * @param header the block header just received

Review comment:
       should be  "@param headers" (plural) and i don't know if the sentence should be "@params headers list of block headers just received" or something more specific

##########
File path: devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthRequestsManager.kt
##########
@@ -30,75 +31,126 @@ import org.apache.tuweni.rlpx.wire.WireConnection
  * Requests manager used to request and check requests of block data
  */
 interface EthRequestsManager {
+
+  /**
+   * Strategy to pick a connection.
+   * @return the connection selection strategy
+   */
+  fun connectionSelectionStrategy(): ConnectionSelectionStrategy
+
   /**
    * Requests a block header
    * @param blockHash the block hash
+   * @param connection the connection to use
    * @return a handle to the completion of the operation
    */
-  fun requestBlockHeader(blockHash: Hash): AsyncCompletion
+  fun requestBlockHeader(
+    blockHash: Hash,
+    connection: WireConnection? = connectionSelectionStrategy().selectConnection()
+  ): AsyncResult<BlockHeader>
+
   /**
    * Requests block headers
    * @param blockHashes the block hashes
+   * @param connection the connection to use
    * @return a handle to the completion of the operation
    */
-  fun requestBlockHeaders(blockHashes: List<Hash>): AsyncCompletion
+  fun requestBlockHeaders(
+    blockHashes: List<Hash>,
+    connection: WireConnection? = connectionSelectionStrategy().selectConnection()
+  ): AsyncResult<List<BlockHeader>>
+
   /**
    * Requests block headers
    * @param blockHash the hash of the block
    * @param maxHeaders the max number of headers to provide
    * @param skip the headers to skip in between each header provided
    * @param reverse whether to provide headers in forward or backwards order
+   * @param connection the connection to use
    * @return a handle to the completion of the operation
    */
-  fun requestBlockHeaders(blockHash: Hash, maxHeaders: Long, skip: Long, reverse: Boolean): AsyncCompletion
+  fun requestBlockHeaders(
+    blockHash: Hash,
+    maxHeaders: Long,
+    skip: Long,
+    reverse: Boolean,
+    connection: WireConnection? = connectionSelectionStrategy().selectConnection()
+  ): AsyncResult<List<BlockHeader>>
+
   /**
    * Requests block headers
    * @param blockNumber the number of the block
    * @param maxHeaders the max number of headers to provide
    * @param skip the headers to skip in between each header provided
    * @param reverse whether to provide headers in forward or backwards order
+   * @param connection the connection to use
    * @return a handle to the completion of the operation
    */
-  fun requestBlockHeaders(blockNumber: Long, maxHeaders: Long, skip: Long, reverse: Boolean): AsyncCompletion
+  fun requestBlockHeaders(
+    blockNumber: Long,
+    maxHeaders: Long,
+    skip: Long,
+    reverse: Boolean,
+    connection: WireConnection? = connectionSelectionStrategy().selectConnection()
+  ): AsyncResult<List<BlockHeader>>
+
   /**
    * Requests block bodies from block hashes
    * @param blockHashes the hashes of the blocks
+   * @param connection the connection to use
    * @return a handle to the completion of the operation
    */
-  fun requestBlockBodies(blockHashes: List<Hash>): AsyncCompletion
+  fun requestBlockBodies(
+    blockHashes: List<Hash>,
+    connection: WireConnection? = connectionSelectionStrategy().selectConnection()
+  ): AsyncResult<List<BlockBody>>
+
   /**
    * Requests a block from block hash
    * @param blockHash the hash of the block
+   * @param connection the connection to use
    * @return a handle to the completion of the operation
    */
-  fun requestBlock(blockHash: Hash): AsyncCompletion
+  fun requestBlock(
+    blockHash: Hash,
+    connection: WireConnection? = connectionSelectionStrategy().selectConnection()
+  ): AsyncResult<Block>
+
   /**
    * Requests transaction receipts
    * @param blockHashes the hashes to request transaction receipts for
+   * @param connection the connection to use
    * @return a handle to the completion of the operation
    */
-  fun requestTransactionReceipts(blockHashes: List<Hash>): AsyncCompletion
+  fun requestTransactionReceipts(
+    blockHashes: List<Hash>,
+    connection: WireConnection? = connectionSelectionStrategy().selectConnection()
+  ): AsyncResult<List<List<TransactionReceipt>>>
+
   /**
    * Checks if a request was made to get block headers
    * @param connection the wire connection sending data
    * @param header the block header just received

Review comment:
       sould be  @param headers (plural)




----------------------------------------------------------------
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:
users@infra.apache.org



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