New answers tagged

1

Interval tree is what you need to efficiently handle intervals. A simple implementation of interval tree in Solidity is provided below. Please note, it's not a balanced implementation, so in worst case it can degrade to a linked list (when you add intervals to it in ascending or descending order). It supports overlapping intervals, and search() can easily be ...


2

What you are searching for is a mapping of mapping. I created the following smart contract that I think achieve what you described. // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.8.0; contract myContract { mapping (address => mapping (uint => uint)) public payments; mapping (address => uint) public lastPayment; ...


1

The problem is that mappings can only live in storage. When you define PoolStruct memory pool;, the mapping member cannot be created in memory, and therefore the memory struct should be treated as if the mapping member never existed (for solidity < 0.7.0). Starting from solidity 0.7.0, the line PoolStruct memory pool will produce an error saying that ...


Top 50 recent answers are included