Skip to content

Commit

Permalink
chore: Revert PR 25: Remove the debugNow hack. See the PR (#143)
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Thompson <[email protected]>
  • Loading branch information
jefft0 authored Dec 9, 2024
1 parent f52694e commit 76fdc09
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
15 changes: 1 addition & 14 deletions realm/post.gno
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"gno.land/p/moul/txlink"
)

var debugNowOffset time.Duration

//----------------------------------------
// Post

Expand Down Expand Up @@ -62,7 +60,7 @@ func newPost(userPosts *UserPosts, id PostID, creator std.Address, body string,
parentID: parentID,
repostUser: repostUser,
reactions: avl.NewTree(),
createdAt: debugNow(),
createdAt: time.Now(),
}
}

Expand Down Expand Up @@ -322,14 +320,3 @@ func getPosts(posts avl.Tree, startIndex int, endIndex int) string {
json += "]}"
return json
}

// Until the problem explained in https://github.com/gnolang/gno/issues/1509
// is solved, we need post timestamps to be different on reload. This
// calls Time.Now() and adds an offset which increases by one minute on each call.
// Therefore, in "normal" operation (before reload) the times are close to the
// expected value. After reload, all times will be the time of reload, increasing by
// one minute each, which is not ideal but at least they are different and in order.
func debugNow() time.Time {
debugNowOffset += time.Minute
return time.Now().Add(debugNowOffset)
}
2 changes: 1 addition & 1 deletion realm/userposts.gno
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (userPosts *UserPosts) Follow(followedAddr std.Address) PostID {
followedUserPosts := getUserPosts(followedAddr)
if followedUserPosts != nil {
userPosts.following.Set(followedAddr.String(), &FollowingInfo{
startedFollowingAt: debugNow(),
startedFollowingAt: time.Now(),
startedPostsCtr: PostID(postsCtr), // Ignore past messages.
})
followedUserPosts.followers.Set(userPosts.userAddr.String(), "")
Expand Down

0 comments on commit 76fdc09

Please sign in to comment.