Solidity-Contract-Patterns icon indicating copy to clipboard operation
Solidity-Contract-Patterns copied to clipboard

Recomendation!

Open idimon4uk opened this issue 7 years ago • 3 comments

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 avatar Jan 31 '18 12:01 idimon4uk

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

idimon4uk avatar Jan 31 '18 12:01 idimon4uk

Thanks for the recco @idimon4uk, Interesting!!

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

aquaflamingo avatar Jan 31 '18 12:01 aquaflamingo

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

idimon4uk avatar Feb 02 '18 16:02 idimon4uk