trustgraph / trustgraph-holochain

Apache License 2.0
24 stars 3 forks source link

Add random number for bucketing to TrustAtom #3

Closed harlantwood closed 2 years ago

harlantwood commented 2 years ago

Feature:

link tag when complete looks like:

Ŧ→sushi[0x00]0.999999999[0x00]892412523[0x00]uhCEk…UFnFF

This feature is to add the random bucket, eg:

892412523

AC:

Impl:

dauphin3 commented 2 years ago

function gen_bucket generates the random bucket string literal which gets input to trust_atom_link_tag, added nul and bucket &str to link_tag_bytes vec

TODO: tests

dauphin3 commented 2 years ago

pseudo random is ok bc with 0-9 there isnt that much variance plus since there are 9 digits for the bucket the probabilities in combination will result in a sufficiently random number for bucket purposes

dauphin3 commented 2 years ago

fn test_gen_bucket() { assert_eq!(gen_bucket().chars().count(), 9); assert!(chars().all(char::is_digit(10)), true); // checks each radix base 10 }

harlantwood commented 2 years ago

fn test_gen_bucket() { assert_eq!(gen_bucket().chars().count(), 9); assert!(chars().all(char::is_digit(10)), true); // checks each radix base 10 }

This seems like the right general direction!