This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
[PAN-2850] Create a transaction pool configuration object #1615
Merged
AbdelStark
merged 3 commits into
PegaSysEng:master
from
AbdelStark:feature/pan-2850-tx-pool-config-object
Jun 27, 2019
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...in/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionPoolConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright 2019 ConsenSys AG. | ||
* | ||
* Licensed 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 tech.pegasys.pantheon.ethereum.eth.transactions; | ||
|
||
import java.util.Objects; | ||
|
||
public class TransactionPoolConfiguration { | ||
|
||
private final int txPoolMaxSize; | ||
private final int pendingTxRetentionPeriod; | ||
private final int txMessageKeepAliveSeconds; | ||
|
||
public TransactionPoolConfiguration( | ||
final int txPoolMaxSize, | ||
final int pendingTxRetentionPeriod, | ||
final int txMessageKeepAliveSeconds) { | ||
this.txPoolMaxSize = txPoolMaxSize; | ||
this.pendingTxRetentionPeriod = pendingTxRetentionPeriod; | ||
this.txMessageKeepAliveSeconds = txMessageKeepAliveSeconds; | ||
} | ||
|
||
public int getTxPoolMaxSize() { | ||
return txPoolMaxSize; | ||
} | ||
|
||
public int getPendingTxRetentionPeriod() { | ||
return pendingTxRetentionPeriod; | ||
} | ||
|
||
public int getTxMessageKeepAliveSeconds() { | ||
return txMessageKeepAliveSeconds; | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
final TransactionPoolConfiguration that = (TransactionPoolConfiguration) o; | ||
return txPoolMaxSize == that.txPoolMaxSize | ||
&& Objects.equals(pendingTxRetentionPeriod, that.pendingTxRetentionPeriod) | ||
&& Objects.equals(txMessageKeepAliveSeconds, that.txMessageKeepAliveSeconds); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(txPoolMaxSize, pendingTxRetentionPeriod, txMessageKeepAliveSeconds); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "TransactionPoolConfiguration{" | ||
+ "txPoolMaxSize=" | ||
+ txPoolMaxSize | ||
+ ", pendingTxRetentionPeriod=" | ||
+ pendingTxRetentionPeriod | ||
+ ", txMessageKeepAliveSeconds=" | ||
+ txMessageKeepAliveSeconds | ||
+ '}'; | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder { | ||
private int txPoolMaxSize = PendingTransactions.MAX_PENDING_TRANSACTIONS; | ||
private int pendingTxRetentionPeriod = PendingTransactions.DEFAULT_TX_RETENTION_HOURS; | ||
private int txMessageKeepAliveSeconds = TransactionPool.DEFAULT_TX_MSG_KEEP_ALIVE; | ||
|
||
public Builder txPoolMaxSize(final int txPoolMaxSize) { | ||
this.txPoolMaxSize = txPoolMaxSize; | ||
return this; | ||
} | ||
|
||
public Builder pendingTxRetentionPeriod(final int pendingTxRetentionPeriod) { | ||
this.pendingTxRetentionPeriod = pendingTxRetentionPeriod; | ||
return this; | ||
} | ||
|
||
public Builder txMessageKeepAliveSeconds(final int txMessageKeepAliveSeconds) { | ||
this.txMessageKeepAliveSeconds = txMessageKeepAliveSeconds; | ||
return this; | ||
} | ||
|
||
public TransactionPoolConfiguration build() { | ||
return new TransactionPoolConfiguration( | ||
txPoolMaxSize, pendingTxRetentionPeriod, txMessageKeepAliveSeconds); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Discussion) What about folding
minTransactionGasPrice
intoTransactionPoolConfiguration
? Or maybe theTransactionPool
also gets access toMiningParams
so that we don't end up duplicating data on 2 different config objects?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the second approach where TransactionPool also gets access to MiningParams
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the
PantheonControllerBuilder
passes theminTransactionPrice
to the transactionPool from theMiningParams
SInce it uses only one parameter from the MiningParams i don't think we need to give it access to the whole object now. What do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷♀ Just feels odd to have a config object and then have an additional dangling option. But there's some weirdness with all 3 options really (as is + my 2 alternative suggestions). I think I'm leaning towards passing in the
MiningParams
- it makes it more explicit that the transactionPool's behavior is modified by the mining configuration. But I'll leave it up to you.