Git Product home page Git Product logo

Comments (4)

SKFrozenCloud avatar SKFrozenCloud commented on August 17, 2024

I agree. Using an array will lead to DOS attack.

from stakingtoken.

jaglinux avatar jaglinux commented on August 17, 2024

@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.

swtrse avatar swtrse commented on August 17, 2024

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.

jaglinux avatar jaglinux commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.