trustgraph / trustgraph-holochain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add random number for bucketing to TrustAtom

harlantwood opened this issue · comments

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:

  • 9 digits total
  • tests

Impl:

  • use hkd rand bytes (integer 0-255) function, convert to integers (0-9) -- so we get two integers from each byte
commented

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

commented

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

commented

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

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!