-
-
Notifications
You must be signed in to change notification settings - Fork 354
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
Refactor Public Transaction Creation #1348
base: master
Are you sure you want to change the base?
Changes from 18 commits
0aca3d7
d8e6161
855a7ca
3dc4003
0190c0d
56cbcba
4dd7e2c
47e3638
957a021
e9ca351
d5e10cd
ce3bf31
08f2642
ea6326d
beb1597
bfda395
6904736
fbea637
f603de6
3423301
11e8a40
988f1c6
ae24627
f65c3e8
bd31b27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,9 +75,6 @@ class CInstantSendDb | |
class CInstantSendManager : public CRecoveredSigsListener | ||
{ | ||
private: | ||
CCriticalSection cs; | ||
CInstantSendDb db; | ||
|
||
std::thread workThread; | ||
CThreadInterrupt workInterrupt; | ||
|
||
|
@@ -112,6 +109,9 @@ class CInstantSendManager : public CRecoveredSigsListener | |
std::unordered_set<uint256, StaticSaltedHasher> pendingRetryTxs; | ||
std::atomic_bool isNewInstantSendEnabled{false}; | ||
|
||
CCriticalSection cs; | ||
CInstantSendDb db; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the only way to implement the test? Wallet changes can certainly be done with an extra member function. |
||
public: | ||
CInstantSendManager(CDBWrapper& _llmqDb); | ||
~CInstantSendManager(); | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -217,6 +217,16 @@ unsigned int CScript::GetSigOpCount(const CScript& scriptSig) const | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return subscript.GetSigOpCount(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bool CScript::IsPayToPublicKey() const { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (size() != 35) return false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
opcodetype opcode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const_iterator pc = begin(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GetOp(pc, opcode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GetOp(pc, opcode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return opcode == OP_CHECKSIG; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+220
to
+228
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correctness and Logic: Verify initial opcode. The method correctly identifies a subset of pay-to-public-key scripts but does not account for the initial opcodes that push the public key onto the stack. A more robust check would involve verifying that the script starts with an appropriate push operation followed by bool CScript::IsPayToPublicKey() const {
if (size() != 35) return false;
opcodetype opcode;
const_iterator pc = begin();
+ // Expect the script to start with a push operation of the public key (33 bytes) followed by OP_CHECKSIG
+ if (!GetOp(pc, opcode) || opcode != OP_PUSHDATA1) return false;
GetOp(pc, opcode);
return opcode == OP_CHECKSIG;
} Committable suggestion
Suggested change
Performance: Directly access relevant opcodes. The method iterates through the script opcodes without checking the first opcode directly. Since the script format for a pay-to-public-key is relatively fixed, directly accessing the relevant opcodes could improve readability and performance. bool CScript::IsPayToPublicKey() const {
if (size() != 35) return false;
opcodetype opcode;
const_iterator pc = begin();
if (!GetOp(pc, opcode) || opcode != OP_PUSHDATA1) return false;
return GetOp(pc, opcode) && opcode == OP_CHECKSIG;
} Committable suggestion
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a valid suggestion:
Second suggestion about optimization is not that valid. Any compiler will optimize this. @psolstice I can change the code an submit or we can keep what we have. . But depends on your final decision. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bool CScript::IsNormalPaymentScript() const | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if(this->size() != 25) return false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Moving
CCriticalSection cs
andCInstantSendDb db
from private to public sections inCInstantSendManager
introduces potential risks related to encapsulation and data integrity. Public members can be modified from outside the class, which could lead to race conditions or inconsistent states. Consider using getter methods or friend classes to maintain encapsulation and protect the integrity of these members.