-
Notifications
You must be signed in to change notification settings - Fork 20
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
Referral transaction support #10
Conversation
RPC call to set referee
leaves[s] = block.vref[s]->GetHash(); | ||
} | ||
for (size_t s = 0; s < block.m_vRef.size(); s++) { | ||
leaves[block.vtx.size() + s] = block.m_vRef[s]->GetHash(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woops!
src/net_processing.cpp
Outdated
@@ -3072,6 +3090,19 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr | |||
} | |||
pto->vInventoryBlockToSend.clear(); | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put this bit in its own function. this one is big enough.
src/net_processing.cpp
Outdated
|
||
// Add referrals | ||
for (const uint256& hash : pto->setInventoryReferralToSend) { | ||
vInv.push_back(CInv(MSG_REFERRAL, hash)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this only place vInv is pushed to? might want >= below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't get it
nVersion{Referral::CURRENT_VERSION}, | ||
previousReferral{}, | ||
scriptSig{}, | ||
code{GetRandHash()} {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we going to support non rand codes in future? then this makes sense. otherwise code can be hash of the referral itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hash of the referral is not random. it's just a hash of referral object. in case we use the same referral as previousReferral
we can get the same hash. on the other hand scriptSig
can help here as we likely would use unique pubkey for signing. but not sure yet how signature works.
the second point is that we can use hash of generated random code to store it in the blockchain to make it opaque for outsiders.
src/protocol.cpp
Outdated
@@ -71,6 +73,8 @@ const static std::string allNetMessageTypes[] = { | |||
NetMsgType::CMPCTBLOCK, | |||
NetMsgType::GETBLOCKTXN, | |||
NetMsgType::BLOCKTXN, | |||
// Merit messages go below | |||
NetMsgType::REF, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indenting...
src/protocol.h
Outdated
@@ -329,6 +342,7 @@ enum GetDataMsg | |||
// The following can only occur in getdata. Invs always use TX or BLOCK. | |||
MSG_FILTERED_BLOCK = 3, //!< Defined in BIP37 | |||
MSG_CMPCT_BLOCK = 4, //!< Defined in BIP152 | |||
MSG_REFERRAL = 5, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indenting
@@ -84,6 +84,10 @@ enum RPCErrorCode | |||
RPC_WALLET_ALREADY_UNLOCKED = -17, //!< Wallet is already unlocked | |||
RPC_WALLET_NOT_FOUND = -18, //!< Invalid wallet specified | |||
RPC_WALLET_NOT_SPECIFIED = -19, //!< No wallet specified (error when there are multiple wallets loaded) | |||
|
|||
// Referral engine errors | |||
RPC_REFERRER_IS_SET = -100, //!< Wallet already has referal code and referrer set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why huge jump in num?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intention was to start using 'blocks' of error codes like it is done in HTTP:
0xx - for wallet
1xx - for referral engine
It's a bit easier to find a free number or to find the error by number.
src/validation.cpp
Outdated
LOCK(mempool.cs); | ||
auto map = &mempoolReferral.mapRTx; | ||
|
||
for(auto it = map->begin(); it != map->end(); ++it ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for(const auto& p : map)
... p.second
src/wallet/wallet.cpp
Outdated
|
||
bool SendReferralTx(CConnman *connman) { | ||
ReferralRef referral = MakeReferralRef(MutableReferral()); | ||
ReferralTx rtx(referral); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indenting
c521b3ac6 Merge #11: fixup define checks. Cleans up some oopses from #5. 8b1cd3753 fixup define checks. Cleans up some oopses from #5. 6b1508d6d Merge #6: Fixes typo fceb80542 Merge #10: Clean up compile-time warnings (gcc 7.1) 0ec2a343f Clean up compile-time warnings (gcc 7.1) d4c268a35 Merge #5: Move helper functions out of sse4.2 object 8d4eb0847 Add HasAcceleratedCRC32C to port_win.h 77cfbfd25 crc32: move helper functions out of port_posix_sse.cc 4c1e9e016 silence compiler warnings about uninitialized variables 495316485 Merge #2: Prefer std::atomic over MemoryBarrier 2953978ef Fixes typo f134284a1 Merge #1: Merge upstream LevelDB 1.20 ba8a445fd Prefer std::atomic over MemoryBarrier git-subtree-dir: src/leveldb git-subtree-split: c521b3ac654cfbe009c575eacf7e5a6e189bb5bb
No description provided.