Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/sparkname.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace spark {
struct CSparkNameTxData
{
public:
static const uint16_t CURRENT_VERSION = 1;
static const uint16_t CURRENT_VERSION = 2;

public:
uint16_t nVersion{CURRENT_VERSION}; // version
Expand All @@ -27,6 +27,8 @@ struct CSparkNameTxData
std::string additionalInfo;
// failsafe if the hash of the transaction data is can't be converted to a scalar for proof creation/verification
uint32_t hashFailsafe{0};
// Registration-only; add transfer fields if mobile starts creating Spark Name transfers.
uint8_t operationType{0};

ADD_SERIALIZE_METHODS;

Expand All @@ -41,6 +43,10 @@ struct CSparkNameTxData
READWRITE(sparkNameValidityBlocks);
READWRITE(additionalInfo);
READWRITE(hashFailsafe);
if (nVersion >= 2)
{
READWRITE(operationType);
}
}
};

Expand Down
2 changes: 2 additions & 0 deletions tests/spark_name_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ BOOST_AUTO_TEST_CASE(spark_names)
BOOST_CHECK_EQUAL(decodedData.sparkAddress, sparkNameData.sparkAddress);
BOOST_CHECK_EQUAL(decodedData.sparkNameValidityBlocks, sparkNameData.sparkNameValidityBlocks);
BOOST_CHECK_EQUAL(decodedData.additionalInfo, sparkNameData.additionalInfo);
BOOST_CHECK_EQUAL(decodedData.nVersion, spark::CSparkNameTxData::CURRENT_VERSION);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid ODR-using CURRENT_VERSION in the test

When the spark_name_tests target is built, BOOST_CHECK_EQUAL binds both operands by reference, so passing CSparkNameTxData::CURRENT_VERSION here ODR-uses the header-only static const member. Because the class does not provide an out-of-class definition for that member and it is not inline constexpr, this added assertion can make the test binary fail to link with an undefined reference; compare against a cast/local value or make the constant inline/constexpr.

Useful? React with 👍 / 👎.

BOOST_CHECK_EQUAL((int)decodedData.operationType, 0);
BOOST_CHECK(!decodedData.addressOwnershipProof.empty());

spark::OwnershipProof deserializedOwnershipProof;
Expand Down