step 2: add NewPost event
This commit is contained in:
parent
393b39d973
commit
7de9fa3898
|
@ -10,13 +10,22 @@ contract DReddit {
|
||||||
|
|
||||||
Post [] public posts;
|
Post [] public posts;
|
||||||
|
|
||||||
|
event NewPost(
|
||||||
|
uint indexed postId,
|
||||||
|
address owner,
|
||||||
|
bytes description
|
||||||
|
);
|
||||||
|
|
||||||
function createPost(bytes memory _description) public {
|
function createPost(bytes memory _description) public {
|
||||||
uint postId = posts.length++;
|
uint postId = posts.length++;
|
||||||
|
|
||||||
posts[postId] = Post({
|
posts[postId] = Post({
|
||||||
creationDate: block.timestamp,
|
creationDate: block.timestamp,
|
||||||
description: _description,
|
description: _description,
|
||||||
owner: msg.sender
|
owner: msg.sender
|
||||||
});
|
});
|
||||||
|
|
||||||
|
emit NewPost(postId, msg.sender, _description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue