You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.
Hey There
I found some ways of optimization for your code that I thought I could share with you.
No looping is ever needed for this contract:
- For deleting an heir part you could set their weight to zero and then swap the indexes of deleted heir with last heir in heirAddress[] and then decrementing length of array
- For calculating total weight count you could have defined an integer that kept the sum of weights and changed it's value with addHeir()changeHeirWeight() and removeHeir() functions
Also I'm not sure about this one but I think the division of heirs[getHeirsAddress(i)] / total will result in integer instead of floating point and I don't think that is what you want.
Apart from these there is possible re-entracy attack opportunity in your code. I advise you to replace claim with a new function that each person could withdraw they're share and then before you transfer the amount ,set their weight to 0.
The text was updated successfully, but these errors were encountered:
Hey! Thanks for taking the time to review my code. This was done purely as a learning project and quite a while ago, so I'm sure it's full of issues and vulnerabilities.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hey There
I found some ways of optimization for your code that I thought I could share with you.
No looping is ever needed for this contract:
- For deleting an heir part you could set their weight to zero and then swap the indexes of deleted heir with last heir in
heirAddress[]
and then decrementing length of array- For calculating total weight count you could have defined an integer that kept the sum of weights and changed it's value with
addHeir()
changeHeirWeight()
andremoveHeir()
functionsAlso I'm not sure about this one but I think the division of
heirs[getHeirsAddress(i)] / total
will result in integer instead of floating point and I don't think that is what you want.Apart from these there is possible re-entracy attack opportunity in your code. I advise you to replace claim with a new function that each person could withdraw they're share and then before you transfer the amount ,set their weight to 0.
The text was updated successfully, but these errors were encountered: