Skip to content

Conversation

IgorDurovic
Copy link

The code is passing the basic tests I created so I think it's ready for review. I tried cleaning up a little but there's still some refactoring I plan on doing. Also, I'm not positive that all the necessary height checks for the hard fork were put in. Besides that, all that's left to do is tweak the fee heuristic.

if (fJustCheck)
return true;

//TODO: LOG ERRORS OR TERMINATE METHOD AND RETURN ERROR?
Copy link
Collaborator

Choose a reason for hiding this comment

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

We probably also want this code only to be activated if the height is above the voting height.

src/main.cpp Outdated
vector <CTransaction> vOrderedProposalTransactions;
proposalManager.GetDeterministicOrdering(pindexPrev->hashProofOfStake, vProposalTransactions,
vOrderedProposalTransactions);
for (CTransaction txProposal: vOrderedProposalTransactions) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

any reason this shouldn't be const ref?

src/main.cpp Outdated
}

vector <CTransaction> vOrderedProposalTransactions;
proposalManager.GetDeterministicOrdering(pindexPrev->hashProofOfStake, vProposalTransactions,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this method returns a bool, lets handle the case that it returns false.

src/main.cpp Outdated
// If the maximum fee provided by the proposal creator is less than the required fee
// then create an unaccepted proposal refund
if (nRequiredFee > proposal.GetMaxFee()) {
proposalManager.AddRefundToCoinBase(proposal, nRequiredFee, nTxFee, false, txCoinBase);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets handle the case that this method returns false.

Also we could simplify the scoping doing something like:

bool fProposalAccepted = nRequiredFee > proposal.GetMaxFee();
proposalManager.AddRefundToCoinBase(proposal, nRequiredFee, nTxFee, fProposalAccepted, txCoinBase);

CScript scriptProposal = tx.vout[0].scriptPubKey;
vchProposal.insert(vchProposal.end(), scriptProposal.begin() + 6, scriptProposal.end());

vchProposal.insert(vchProposal.end(), scriptProposal.begin() + (scriptProposal.size() > 0x04c ? 7 : 6), scriptProposal.end());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Replace the magic numbers with typedefs or #define macro.

bool CVoteProposalManager::GetAcceptedTxProposals(const CTransaction& txCoinBase, const std::vector<CTransaction>& vOrderedTxProposals,
std::vector<CTransaction>& vAcceptedTxProposals)
{
if (!txCoinBase.IsCoinBase()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We will need to add more logic to IsCoinBase() so that these transactions are still seen as coinbase.

Copy link
Author

Choose a reason for hiding this comment

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

What additional logic is needed?
IsCoinBase() just checks -> (vin.size() == 1 && vin[0].prevout.IsNull() && vout.size() >= 1);
By this logic I think refund transactions will still be seen as coinbase transactions.

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.

2 participants