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

Applying Rust changes to add tags #3

Open
wants to merge 10 commits into
base: vic-changes2
Choose a base branch
from

Conversation

vleipnik
Copy link

@vleipnik vleipnik commented May 29, 2024

Rust TODOs

  • Make value optional in the rust code db access functions (it's optional in JS)
  • Convert u8 key portion of the tags that was due to reaction types to a hash (reuse blake3_20 in utils.js)

TS Missing Implementations

  • Hubble HTTP endpoints (apps/hubble/src/rpc/httpServer.ts)
  • Hubble RPC endpoints (apps/hubble/src/rpc/server.ts)

TS Missing Tests

  • Hubble service tests (apps/hubble/src/rpc/test/reactionService.test.ts)

@@ -6,7 +6,7 @@ use db::RocksDB;
use ed25519_dalek::{Signature, Signer, SigningKey, VerifyingKey, EXPANDED_SECRET_KEY_LENGTH};
Copy link
Author

Choose a reason for hiding this comment

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

This file exposes mappings of Rust addon-functions to external JS code.

@@ -73,6 +73,9 @@ pub enum RootPrefix {

/* Used to index fname username proofs by fid */
FNameUserNameProofByFid = 27,

/* Used to index tags by target */
Copy link
Author

Choose a reason for hiding this comment

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

These pre and post-fixes are used to generate keys in the RocksDB key-value pairs

@@ -8,6 +8,7 @@ pub use self::user_data_store::*;
pub use self::username_proof_store::*;
pub use self::utils::*;
pub use self::verification_store::*;
pub use self::tag_store::*;
Copy link
Author

Choose a reason for hiding this comment

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

mod.rs is the module definition for the Store module, basically, like an index.js

@@ -472,6 +472,57 @@ export const rsGetReactionsByTarget = async (
return await lib.getReactionsByTarget.call(store, targetCastIdBytes, targetUrl, type, pageOptions);
};

/** Tags **/
Copy link
Author

Choose a reason for hiding this comment

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

Wrapper around the Rust DB functions, used by JS functions in Hubble.

@@ -101,6 +101,10 @@ export enum UserPostfix {
UsernameProofMessage = 7,

// Add new message types here

/* Tag */
Copy link
Author

Choose a reason for hiding this comment

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

Note that this needs to be exactly duplicated in the message.rs file in the Rust addon

@@ -78,6 +78,9 @@ export enum RootPrefix {

/* Used to index fname username proofs by fid */
FNameUserNameProofByFid = 27,

/* Used to index reactions by target */
TagsByTarget = 28,
Copy link
Author

@vleipnik vleipnik May 29, 2024

Choose a reason for hiding this comment

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

Note that this needs to be exactly duplicated in the message.rs file in the Rust addon

@@ -113,6 +113,10 @@ export const typeToSetPostfix = (type: MessageType): UserMessagePostfix => {
return UserPostfix.LinkCompactStateMessage;
}

if (type === MessageType.TAG_ADD || type === MessageType.TAG_REMOVE) {
Copy link
Author

Choose a reason for hiding this comment

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

typeToSetPostfix is a utility map for deriving postfix from type in JS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant