-
Notifications
You must be signed in to change notification settings - Fork 130
[PAN-1339] Send local transactions to new peers #1253
[PAN-1339] Send local transactions to new peers #1253
Conversation
834a9a5
to
9f563b3
Compare
for (Transaction transaction : localTransactions) { | ||
peerTransactionTracker.addToPeerSendQueue(peer, transaction); | ||
} | ||
peerTransactionTracker.markTransactionsAsSeen(peer, localTransactions); |
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 don't think you need to call markTransactionsAsSeen
. Marking seen transactions will be handled by TransactionsMessageSender
.
@@ -101,9 +103,20 @@ public void setUp() { | |||
SyncState syncState = mock(SyncState.class); | |||
when(syncState.isInSync(anyLong())).thenReturn(true); |
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.
Can you add some tests for the new functionality?
223e1e9
to
bfaeec0
Compare
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.
Looks good! Just left one comment to address.
RespondingEthPeer peer = EthProtocolManagerTestUtil.createPeer(ethProtocolManager); | ||
EthPeers ethPeers = ethContext.getEthPeers(); | ||
|
||
ethPeers.registerConnection(peer.getPeerConnection()); |
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.
You shouldn't need to call this or expose this method publicly.
Also, can you update the PR description? |
736eb7d
to
9c2beb6
Compare
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.
LGTM. Just a few little clean ups just to keep things tidy.
@@ -432,9 +450,19 @@ public void shouldAllowTransactionWhenAccountWhitelistControllerIsNotPresent() { | |||
public void shouldRejectRemoteTransactionsWhenNotInSync() { | |||
SyncState syncState = mock(SyncState.class); | |||
when(syncState.isInSync(anyLong())).thenReturn(false); | |||
EthContext ethContext = mock(EthContext.class); | |||
EthPeers ethPeers = mock(EthPeers.class); |
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.
Why can't these mocks be created as fields and just reused? Would save a lot of noise through the tests.
.thenReturn(valid()); | ||
when(transactionValidator.validateForSender( | ||
eq(transactionRemote), nullable(Account.class), eq(true))) | ||
.thenReturn(valid()); |
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.
nit: You could collapse this to one line:
when(transactionValidator.validateForSender(any(Transaction.class), nullable(Account.class), eq(true)).thenReturn(valid());
Set<Transaction> transactionsToSendToPeer = | ||
peerTransactionTracker.claimTransactionsToSendToPeer(peer.getEthPeer()); | ||
|
||
assertThat(transactionsToSendToPeer.size()).isEqualTo(1); |
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 think this can be:
assertThat(transactionsToSendToPeer.size()).isEqualTo(1); | |
assertThat(transactionsToSendToPeer).containsExactly(transactionLocal); |
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.
And then remove the line below that checks the hash.
9c2beb6
to
a000e08
Compare
a53ea47
to
32374dc
Compare
PR description
Method on
TransactionPool
to disseminate local transactions to newly connected peers.Fixed Issue(s)
When a new peer connects, local transactions are sent to it
Remote transactions are not sent to newly connected peers
Event loop threads are not blocked while sending transactions