[][src]Trait frame_support::traits::Randomness

pub trait Randomness<Output> {
    pub fn random(subject: &[u8]) -> Output;

    pub fn random_seed() -> Output { ... }

Required methods

pub fn random(subject: &[u8]) -> Output

Get a "random" value

Being a deterministic blockchain, real randomness is difficult to come by. This gives you something that approximates it. At best, this will be randomness which was hard to predict a long time ago, but that has become easy to predict recently.

subject is a context identifier and allows you to get a different result to other callers of this function; use it like random(&b"my context"[..]).

Loading content...

Provided methods

pub fn random_seed() -> Output

Get the basic random seed.

In general you won't want to use this, but rather Self::random which allows you to give a subject for the random result and whose value will be independently low-influence random from any other such seeds.

Loading content...


impl<Output: Decode + Default> Randomness<Output> for TestRandomness[src]

Loading content...