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

Add BlockChain<T>.UnstageTransactions() #223

Merged
merged 1 commit into from
Apr 29, 2019

Conversation

earlbread
Copy link
Contributor

This patch adds BlockChain<T>.UnstageTransactions() method.

@codecov
Copy link

codecov bot commented Apr 29, 2019

Codecov Report

Merging #223 into master will decrease coverage by 0.21%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #223      +/-   ##
==========================================
- Coverage   84.08%   83.87%   -0.22%     
==========================================
  Files          75       75              
  Lines        3488     3492       +4     
==========================================
- Hits         2933     2929       -4     
- Misses        555      563       +8
Impacted Files Coverage Δ
Libplanet/Blockchain/BlockChain.cs 98.04% <100%> (+0.02%) ⬆️
Libplanet/Net/Swarm.cs 79.68% <0%> (-0.9%) ⬇️

@dahlia
Copy link
Contributor

dahlia commented Apr 29, 2019

What would this method be used for?

@earlbread
Copy link
Contributor Author

What would this method be used for?

We need this method to avoid duplicate rewards in games.

@dahlia
Copy link
Contributor

dahlia commented Apr 29, 2019

Could you rebase this on the current master?

@earlbread
Copy link
Contributor Author

I rebased this on the master branch. @dahlia

@earlbread earlbread force-pushed the unstage-transactions branch 3 times, most recently from 2b79a7b to c300520 Compare April 29, 2019 10:31
@earlbread
Copy link
Contributor Author

I rebased again. Could you please review again? @dahlia @longfin

foreach (Transaction<T> tx in transactions)
{
Transactions.Remove(tx.Id);
}
Copy link
Contributor

@dahlia dahlia Apr 29, 2019

Choose a reason for hiding this comment

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

@longfin Should we remove these transactions from pool as well?

This could break things, for example:

Block<Action> b = Block<Action>.Mine(..., transactions: txs);
blockChain.Append(b);
blockChain.UnstageTransactions(txs);
Block<Action> b2 = blockChain.Blocks[b.blockHash];  // This will crash.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it can be problem. and, I think that UnstageTransactions() should remove only staged transactions, not mined transaction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. So should we make like BlockChain<T>.UnstageTransactionIds() instead of BlockChain<T>.UnstageTransactions()?

Copy link
Contributor

Choose a reason for hiding this comment

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

The current name looks better to me, because it exposes less implementation details.

@earlbread
Copy link
Contributor Author

I made BlockChain<T>.UnstageTransactionIds() method remove only staged transactions, not mined transaction. Please take a look. @dahlia @longfin

@earlbread earlbread merged commit dd95b02 into planetarium:master Apr 29, 2019
@earlbread earlbread deleted the unstage-transactions branch April 29, 2019 23:59
limebell pushed a commit to limebell/libplanet that referenced this pull request Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants