Comments (4)
I agree. Using an array will lead to DOS attack.
from stakingtoken.
@swtrse position of item inside array is not fixed. When item is deleted, the last element is swapped with item to be deleted index and the last element is removed/pop.
https://github.com/HQ20/StakingToken/blob/master/contracts/StakingToken.sol#L136
from stakingtoken.
Thanks, that clears it up for this specific implementation. That helps too but what I wanted to know is if there is something possible like a queue where you push new elements on the end and pop old elements of the front. I do not have an concrete implementation in mind but I want to get a feeling for the underlying concepts.
So for example if I generate an array in C and fill the array with values. I can take it for granted that the order of the items is always the same for the lifetime of the array. However in an distributed environment this has not to be the case and I was wondering if the order of elements will be the same for each distributed client or if each client can hold a different order of array elements because an array is not ordered per se and order should not matter at least most of the times..
from stakingtoken.
Main issue is when someone wants to removeStake(). Instead of swapping, we can just make the value as 0.
Then we can maintain the index position, new users will be pushed at the end as usual.
Downside is that the array will keep growing.
from stakingtoken.
Related Issues (9)
- Error: Could not find openzeppelin-solidity/contracts/Ownable.sol from any sources; HOT 2
- How to use it?
- createStake, removeStake: Use contract address itself to store the staked balance
- Internal functions
- Security & Code audit
- Warning: SPDX license identifier not provided in source file. HOT 1
- SyntaxError: Invalid pragma "^" HOT 1
- Update Staking for current token HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stakingtoken.