Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the way how TxCompletion<TPeer, TAction> fetch transaction from other peers #1704

Merged

Conversation

limebell
Copy link
Member

Previously TxCompletion<TPeer, TAction>.RequestTxsFromPeerAsync() is maintained maximum 1 task for each peer to fetch transactions from. It caused a bug where fetching does not working even received a new TxIds from other peer.

This PR force to spawn TxCompletion<TPeer, TAction>.RequestTxsFromPeerAsync() task every time new TxIds are received.

@limebell limebell added the bug Something isn't working label Jan 11, 2022
@limebell limebell self-assigned this Jan 11, 2022
}));

var validTxs = new List<Transaction<TAction>>();
IImmutableSet<TxId> stagedTxIds = _blockChain.GetStagedTransactionIds();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BlockChain<T>.StageTransaction() should do the job of filtering so no additional filtering is necessary at this point. See #1648.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, then again, we can't count validTxs if we don't do the filtering here. I'll create an issue for this.

Copy link
Member Author

@limebell limebell Jan 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you mean L158 to L176 is not required and just

                foreach (var tx in txs)
                {
                    try
                    {
                        _blockChain.StageTransaction(tx);
                    }
                    catch (InvalidTxException ite)
                    {
                        const string msg = "Received transaction from {Peer} with id {TxId} " +
                                  "will not be staged since it is invalid.";
                        _logger.Error(ite, msg, peer, tx.Id);
                    }
                }

will do the work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll deal with this in #1705.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IStagePolicy is designed not to throw any Exception so yes, I think it should be fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yeah, since broadcasting is tied to validTxs, I think it should be left as it is for now.

longfin
longfin previously approved these changes Jan 11, 2022
Copy link
Contributor

@greymistcube greymistcube left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think suggested logging related changes should suffice for now.

limebell and others added 2 commits January 11, 2022 11:40
Co-authored-by: Say Cheong <greymistcube@gmail.com>
@limebell limebell merged commit 48a4a49 into planetarium:0.25-maintenance Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants