Skip to content

Conversation

@jtimon
Copy link
Contributor

@jtimon jtimon commented Jun 12, 2018

This should not change behavior in any way.

Separated out of #362

@jtimon jtimon force-pushed the e14-pegin-refactor-template branch 2 times, most recently from c515668 to 16ad95c Compare June 13, 2018 01:31
@jtimon jtimon force-pushed the e14-pegin-refactor-template branch from 16ad95c to 1d31ac6 Compare June 13, 2018 02:59
bool GetAmountFromParentChainPegin(CAmount& amount, const Sidechain::Bitcoin::CTransaction& txBTC, unsigned int nOut)
{
amount = txBTC.vout[nOut].nValue;
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

just return the value? It seem this can't fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The point is to make the interface like 23af084#diff-24efdb00bfbe56b140fb006b562cc70bR2369 which can fail.

@instagibbs
Copy link
Contributor

utACK 20f9fb3

I'd like another set of eyes on this as well.

static bool GetBlockAndTxFromMerkleBlock(uint256& block_hash, uint256& tx_hash, T& merkle_block, const std::vector<unsigned char>& merkle_block_raw)
{
try {
std::vector<uint256> txHashes;
Copy link
Contributor

Choose a reason for hiding this comment

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

might as well re-name the variables to match style in here since we're moving them

return false;
}
// TODO do this before to prevent DoS ?
if (!CheckBitcoinProof(block_hash, merkle_block.header.nBits)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Checks previous are quite cheap. Not worried.

@jtimon jtimon force-pushed the e14-pegin-refactor-template branch from 1d31ac6 to a20986b Compare June 14, 2018 17:29
@jtimon
Copy link
Contributor Author

jtimon commented Jun 14, 2018

Fixed nits

return true;
}

template<typename T>
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious about the use of a template here (vs., say, an inline static function). This isn't a header file and there only appears to be one use of this template/function -- is this a project coding convention or is there some performance/maintenance gain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it is just in preparation for #362

Copy link

Choose a reason for hiding this comment

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

I'm not the biggest fan of adding code for future use into a pull request, it could sit there making no sense for a long time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I did it only because @instagibbs asked. Perhaps I should have done 2 commits but not 2 PRs

@instagibbs
Copy link
Contributor

re-utACK a20986b

@mword
Copy link

mword commented Jun 22, 2018

I built and ran all tests (including qa tests and the peggin.py test) with no errors. I made some comments in #362 that are relevant to #370 I think (362 seemed the better place to make my comments). I got to the point where I understood the code if not the higher level logic that makes these changes necessary (I'm still coming to terms with that).

All in all: tACK

@mword
Copy link

mword commented Jun 26, 2018

ACK

@instagibbs instagibbs merged commit a20986b into ElementsProject:elements-0.14.1 Jun 26, 2018
instagibbs added a commit that referenced this pull request Jun 26, 2018
…emplated

a20986b 2WP: Refactor out GetAmountFromParentChainPegin (Jorge Timón)
2be9cae Refactor: Validation: Make parts of IsValidPeginWitness templated (Jorge Timón)
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.

4 participants