Skip to content
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

Module Registry removeModule() function #244

Merged
merged 8 commits into from
Sep 6, 2018
Merged

Conversation

thegostep
Copy link

Please double check logic for dealing with array index 0. My approach has been to set index 0 of the array to the 0x0 address and prevent from removing, the side effect is that getting the list of module factories will always include the 0x0 address.

@pabloruiz55
Copy link
Contributor

@thegostep why not just skip the whole re-ordering code block if array length is == 1?

@@ -20,6 +20,8 @@ contract ModuleRegistry is IModuleRegistry, Pausable, RegistryUpdater, ReclaimTo
mapping (address => address[]) public reputation;
// Mapping contain the list of addresses of Module factory for a particular type
mapping (uint8 => address[]) public moduleList;
// Mapping to store the index of the moduleFacorty in the moduleList
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo => moduleFactory

require(moduleFactory.getType() != 0, "Factory type should not equal to 0");
registry[_moduleFactory] = moduleFactory.getType();
moduleList[moduleFactory.getType()].push(_moduleFactory);
uint8 kind = moduleFactory.getType();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of "kind" use "type"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type is a reserved keyword documentation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, moduleFactoryType or _type, don't want to be introducing different names.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay fixing

@thegostep
Copy link
Author

thegostep commented Sep 3, 2018

the check on line 99 does the same implicit check as 'array length is == 1'

edit:
I miss-understood. What you are referring to is that there is no need to re-order if removing the last element in the array.

I can add a check if (index == last) and delete without re-ordering. I don't think it makes a big difference from a gas perspective.

@pabloruiz55
Copy link
Contributor

In response to this:

Please double check logic for dealing with array index 0. My approach has been to set index 0 of the array to the 0x0 address and prevent from removing, the side effect is that getting the list of module factories will always include the 0x0 address.

I meant instead of adding an item to index 0, change the logic so if there's only one item you don't re-order but just remove that item.

@pabloruiz55
Copy link
Contributor

Looks good to me now. @adamdossa please review.

@pabloruiz55 pabloruiz55 merged commit 1978211 into development-1.5.0 Sep 6, 2018
@satyamakgec satyamakgec deleted the unverify branch October 30, 2019 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants