Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Recomendation! #3

Open
idimon4uk opened this issue Jan 31, 2018 · 3 comments
Open

Recomendation! #3

idimon4uk opened this issue Jan 31, 2018 · 3 comments

Comments

@idimon4uk
Copy link

idimon4uk commented Jan 31, 2018

https://github.com/robertsimoes/Solidity-Contract-Patterns/blob/master/IndexedStructMap/IndexedStructMap.sol
If I was u, I would develop update and add as one function, for example using

mapping(uint => address)

and have uint size; and write 2 maps and size in 1 struct;
something like this:

struct eDataStruct {
mapping(address => Entity) entityStructs;
mapping(uint=>address) entityList;
uint size;
}
struct Entity { 
    uint eData; 
    bool exists; 
  } 

@idimon4uk
Copy link
Author

using arrays in smart-contracts it's bad idea )

@aquaflamingo
Copy link
Owner

Thanks for the recco @idimon4uk, Interesting!!

Could you elaborate on why you think array's aren't the best idea?

@idimon4uk
Copy link
Author

it's my own opinion, I had some experience with arrays. it's too easy to update some data using map , and have some problem using arrays, for example 'out of gas'. it's depended from task

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants