-
Notifications
You must be signed in to change notification settings - Fork 649
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
Refactored wallet.cpp file because was too big (issue #950) #1413
Conversation
7e5f9cf
to
8249db6
Compare
Ironically, this change led my compiler to memory exhaustion. Previous builds were close, this build pushed it over the edge. 7 processors, 16GB RAM, 6GB Swap. Recompiling with fewer processors got it to compile. cli_test and chain_test ran without errors. Now reviewing the code. |
@jmjatlanta Thank you very much ! |
@jmjatlanta FYI if you will try to start |
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.
Need to move 1 method, and looking for comments from others.
@@ -79,163 +80,27 @@ | |||
# include <sys/stat.h> | |||
#endif | |||
|
|||
#include "wallet_account.cpp" |
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.
Need to be careful here. If make
compiles these as objects (i.e. cmake tells it to), linkers will not be able to link.
This is certainly a way to fix the issue reported, and the precompiler will do its job. But I wonder if this is the best way to fix it. Honestly, I would break these into separate classes (ACID principle), but that would require a larger effort. Perhaps @abitmore or @pmconrad or @oxarbitrage have ideas on how it could be done.
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.
Thanks ! My solution requires minor changes just to separate different logical parts in different files like for example database.cpp
implementation.
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.
Good, but then please also use the same mechanism as used for database.cpp: https://github.com/bitshares/bitshares-core/blob/master/libraries/chain/CMakeLists.txt#L11-L30 (can use the same constant).
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.
ok sure ! Thanks !
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.
Done
Bumped |
I've added mechanism as used for |
Have you tested disabling the unity build? It doesn't compile for me. |
This is a PITA to review. |
ok sure ! sorry ! Thanks ! |
I've tested with unity build enabled only and all compiled well enough without any errors detected. |
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.
Still working on the implementation/*cpp
files.
return my->broadcast_transaction(tx); | ||
} | ||
|
||
signed_transaction wallet_api::sign_transaction(signed_transaction tx, bool broadcast /* = 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.
Please move to general.
return fc::to_hex(fc::raw::pack(tx)); | ||
} | ||
|
||
pair<transaction_id_type,signed_transaction> wallet_api::broadcast_transaction(signed_transaction tx) |
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.
Please move to general.
return my->remove_builder_transaction(handle); | ||
} | ||
|
||
string wallet_api::serialize_transaction( signed_transaction tx )const |
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.
Please move to general.
libraries/wallet/wallet_trading.cpp
Outdated
return my->cancel_order(order_id, broadcast); | ||
} | ||
|
||
signed_transaction wallet_api::global_settle_asset(string symbol, |
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.
Please move to asset.
@@ -0,0 +1,524 @@ | |||
/* |
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.
Please rename to wallet_stealth.cpp
libraries/wallet/wallet_account.cpp
Outdated
return my->upgrade_account(name,broadcast); | ||
} | ||
|
||
fc::ecc::private_key wallet_api::derive_private_key(const std::string& prefix_string, int sequence_number) const |
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.
Please move to general.
libraries/wallet/wallet_account.cpp
Outdated
return my->_remote_db->get_full_accounts({name_or_id}, false)[name_or_id]; | ||
} | ||
|
||
vector<limit_order_object> wallet_api::get_account_limit_orders( |
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.
Please move to trading.
libraries/wallet/wallet_general.cpp
Outdated
return graphene::wallet::utility::suggest_brain_key(); | ||
} | ||
|
||
vector<brain_key_info> utility::derive_owner_keys_from_brain_key(string brain_key, int number_of_desired_keys) |
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.
IMO this utility method belongs into the _impl file.
libraries/wallet/wallet_general.cpp
Outdated
return results; | ||
} | ||
|
||
brain_key_info utility::suggest_brain_key() |
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.
IMO this utility method belongs into the _impl file.
* THE SOFTWARE. | ||
*/ | ||
|
||
#include "implementation/wallet_transaction_builder_impl.cpp" |
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.
IMO including .cpp
files from other .cpp
doesn't really fulfill the goal of #950.
Yes, the individual files get smaller, but they are not independent. An IDE must load all included files as well to provide auto-completion for example, so splitting and including doesn't reduce memory requirements. Same for the compiler.
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 see you have already partially made this separation. Perhaps it is sufficient to remove these includes and compile the *_impl separately.
I have switched to using it by default in my setup, as my impression is that it speeds up the build. Especially when modifying only one of the .cpp files. No need to add a specific test IMO. Once it's set up correctly it should continue to work. |
ok, thanks ! soon will make new commits with improvements ... |
…on to wallet_general.cpp
all improvements done already, also thinking and trying to optimize more compilation memory and time |
still thinking about more optimizing build time and memory, is it possible to extend estimation for this optimization @ryanRfox ? or maybe should I open another new issue for this optimization task ? PS: #950 was intended to reduce file size towards smaller files with code, but not to optimize memory and time compilation Thanks ! |
created new issue for deeper |
Confirmed that as of f321f43 code was only moved around. No functional changes. |
Thank you very much ! Really appreciate all core team's time and efforts ! Thanks ! |
can we merge it ? so I can start working on #1432 based on this merge. |
Guys what should we do with this PR ? Look please when you will have time. |
This branch has conflicts that must be resolved. |
Closing in favor of #2013. |
This PR for #950 issue wallet.cpp file too big