Compiled an "Auction contract" and got a warning regarding high gas requirements. Means: cannot run it. Below the lines with comments and that lines I included (//Part 1 Task n Line n).
// CANNOT BE EXECUTED !!! GAS REQUIREMENTS HIGH
function bid(uint _itemId, uint _count) public payable{
//Part 1 Task 4. Implement the three conditions below.
// 4.1 If the number of tokens remaining with the bidder is < count of tokens bid, revert
// 4.2 If there are no tokens remaining with the bidder, revert.
// 4.3 If the id of the item for which bid is placed, is greater than 2, revert.
// Hint: "tokenDetails[msg.sender].remainingTokens" gives the details of the number of tokens remaining with the bidder.
if (tokenDetails[msg.sender].remainingTokens < _count) return; //Part 1 Task 4 – line 1
if (_itemId > 2) return; //Part 1 Task 4 – line 2
//Part 1 Task 5. Decrement the remainingTokens by the number of tokens bid
// Hint. "tokenDetails[msg.sender].remainingTokens" should be decremented by "_count".
(tokenDetails[msg.sender].remainingTokens - _count); //Part 1 Task 5 – 1 line
bidders[tokenDetails[msg.sender].personId].remainingTokens= tokenDetails[msg.sender].remainingTokens; //updating the same balance in bidders map.
Item storage bidItem = items[_itemId];
for(uint i=0; i<_count;i++) {
bidItem.itemTokens.push(tokenDetails[msg.sender].personId);
}
}
Anybody who can help?