Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add consensus level decentralized post pinning mechanism to core. #50

Closed
wants to merge 13 commits into from

Conversation

bluepartyhat
Copy link
Contributor

No description provided.

@bluepartyhat bluepartyhat requested a review from a team as a code owner June 30, 2021 03:25
Copy link
Member

@lazynina lazynina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see feedback

lib/block_view.go Outdated Show resolved Hide resolved
lib/block_view.go Outdated Show resolved Hide resolved
lib/block_view.go Outdated Show resolved Hide resolved
lib/block_view.go Outdated Show resolved Hide resolved
lib/block_view.go Outdated Show resolved Hide resolved
lib/block_view.go Outdated Show resolved Hide resolved
lib/block_view.go Outdated Show resolved Hide resolved
lib/block_view.go Outdated Show resolved Hide resolved
lib/block_view.go Outdated Show resolved Hide resolved
lib/block_view.go Show resolved Hide resolved
@maebeam maebeam linked an issue Jul 7, 2021 that may be closed by this pull request
@KrassensteinBitClout
Copy link

Is this a global feature or will each node be able to have their own pinned posts? I see this is written to Core so I assume it's global.

@lazynina
Copy link
Member

lazynina commented Jul 9, 2021

Is this a global feature or will each node be able to have their own pinned posts? I see this is written to Core so I assume it's global.

This feature allows users to pin posts to their own profile and storing the the fact that the post is pinned will live on the blockchain. So this is a "global" or what I generally think of as a "protocol-level" feature.

This is distinct from posts that are pinned to the global feed. Those will only ever be at the node-level. Each node operator will have the ability to pin posts to their global feed.

Hope that answers your question.

IsPinned bool

// Indicator if a post is pinned to the global feed.
IsGlobalPinned bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. I don't think we want anyone to have the ability to pin to the global feed do we?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just the admin ability to pin to global feed that already exists. It was renamed in this PR.

isPinned := false
if _, hasPinned := extraData[IsPinnedPostKey]; hasPinned && blockHeight > PinnedPostTrackingUpdateBlockHeight {
isPinned = true
delete(extraData, IsPinnedPostKey)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we modify the extraData here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to why we delete the reclout keys from the extra data map - it saves space in the DB for each PostEntry as we don't need the keys in the PostEntry's PostExtraData map since we explicitly extract it to the IsPinned attribute.

@@ -4341,6 +4435,17 @@ func (bav *UtxoView) _connectSubmitPost(
}
}

// We set/delete the pin entry mappings depending on the previous and current state of the post.
if hidingPostEntry {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof... complicated...

@@ -276,6 +276,21 @@ type RecloutEntry struct {
isDeleted bool
}

// PinEntry stores the timestamp and state of a PostEntry.
// It's used in the UtxoView to keep track of pinned posts not yet in the database.
type PinEntry struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High-level thoughts after reading through.

It would be good to understand what the value of a PinEntry is. My view on pinned posts is we'd implement them the exact same way as we implement IsHidden on posts, which is brain-dead simple and doesn't even require any change to the disconnect logic.

Then, to get an index of the pinned posts, we can modify PutPostEntryMappings and DeletePostEntryMappings in db_utils.go to simply update a separate little index of <PublicKey, Timestamp> for the pinned posts. We could even include another field in addition to IsPinned on the PostEntry, which is PinTimestamp, which can allow the user to order the pinned posts on their profile by pinning them in a different order. This would also require no changes to the disconnect logic I think.

I may be missing the reason why PinEntry is required, and if that's the case please let me know!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the reason @bluepartyhat added the PinEntry due to the complications that would arise in DBPutPostEntryMappingsWithTxn. Unlike isHidden, isPinned results in different indexing. So when we flush to the DB, we need to know the previous pin status of the PostEntry (which is not retained on the PostEntry) so we can delete it in DBDeletePostEntryMappingsWithTxn and can then be correctly re-added in DBPutPostEntryMappingsWithTxn. I think adding the complication there would probably be preferable to adding the PinEntry, but let's chat about this since the indexing is odd.

@lazynina lazynina closed this Jan 25, 2023
@lazynina lazynina deleted the bph/pinned-posts branch January 25, 2023 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for pinned posts
4 participants