Skip to content

Commit a582393

Browse files
authored
require implemente in setContent function
Requiere allows register a message only one time. If you try to register a message that it is already in the smart contract, the transaccion will fail.
1 parent 36b734f commit a582393

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Smart Contract/blockMask.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ contract BlockMask {
5050
}
5151

5252
function setContent (string memory _url, string memory _msg) public {
53+
bytes32 url = keccak256(abi.encodePacked(_url));
54+
55+
require(storedData[url].registrar == address(0));
5356

5457
userContent[msg.sender].messages.push(_url) - 1;
5558

56-
bytes32 url = keccak256(abi.encodePacked(_url));
57-
5859
storedData[url].hashmsg = keccak256(abi.encodePacked(_msg));
5960
storedData[url].registrar = msg.sender;
6061
storedData[url].creationDate = block.timestamp;
@@ -94,4 +95,4 @@ contract BlockMask {
9495
return userContent[msg.sender].messages.length;
9596
}
9697

97-
}
98+
}

0 commit comments

Comments
 (0)