-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Refactoring send.rs by introducing transfer trait #3728
Conversation
I personally don't think this is a huge increase in readability, since there's just more indirection in figuring out what's going on. |
But do you think though that it's a bit more readable? |
It simplify things a bit for new folks who want to read about what's going on in send.rs. @casey Some more Context on why I went ahead with this refactor: I wanted to implement the Even Split command for rune where I can split 10k of runes into 100 each, send.rs was a big and going through that code with different branches was lots of to-and-fro. If it had been like this, understanding what's going through would be much less time consuming for new contributors and can start checking in more features like split command quickly. |
I feel that even if it adds a bit more readability and simplicity, there is no harm in checking in to main branch since all unit tests are passing, unless it adds more complexity, which I don't think so. |
We were a way past "Rule Of Three" and the refactoring was a due in my opinion. Currently, there are 5 sends. |
To be clear: I closed this PR because I think it's a net negative and makes the code harder to read. The rule of three is about deduplication. The PR is net +107 lines of code, and replaces a match statement which calls three different functions, with a trait with five different implementations. It is not deduplicating anything. I think it's much worse and more complicated. |
This bug was fixed with a change to
Having six functions in a file is fine.
It's super readable, but reading it doesn't tell you anything about what it does. |
but does # of lines code really matter in such cases? # of lines of code would increases if a piece of code is moved to different files with new imports, new functions definitions, empty lines tends to add to net # of loc.
The function wasn't moved to another place as is, only just implementation was moved. The
It's true that It wouldn't have helped finding that bug, but while writing the new "send rune" implementation itself, it would have enforced the author to use postage (due to trait contract for |
Motivation
Catching bugs early for example:
Code Quality
splitting rune
orsend to many
can have its own transfer trait implementation without bloating send.rs file.sending_inscription
boolean can be moved out of thecreate_unsigned_send_satpoint_transaction
method and to its trait implementation (not a big deal but just a bit cleaner code)