random

package
v0.0.0-...-f705c6e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package random describes the usage and scope of random numbers on IRISHub. This feature is currently in beta and please assess the risk yourself before using.

[More Details](https://www.junjie-bianjie.org/docs/features/random.html)

As a quick start:

baseTx := sdk.BaseTx{
	From: "test1",
	Gas:  20000,
	Memo: "test",
	Mode: sdk.Commit,
}

var memory = make(map[string]string, 1)
var signal = make(chan int, 0)
request := rpc.RandomRequest{
	BlockInterval: 2,
	Callback: func(reqID, randomNum string, err sdk.Error) {
		require.NoError(rts.T(), err)
		require.NoError(rts.T(), err)
		memory[reqID] = randomNum
		signal <- 1
	},
	Oracle: false,
}

reqID, err := rts.Random().Request(request, baseTx)
require.NoError(rts.T(), err)
memory[reqID] = ""
<-signal
require.NotEmpty(rts.T(), memory[reqID])

Index

Constants

View Source
const (
	ModuleName = "random"
)

Variables

This section is empty.

Functions

func Create

func Create(ac sdk.BaseClient) rpc.Random

Types

type MsgRequestRand

type MsgRequestRand struct {
	Consumer      sdk.AccAddress `json:"consumer"`        // request address
	BlockInterval uint64         `json:"block_interval"`  // block interval after which the requested random number will be generated
	Oracle        bool           `json:"oracle"`          // oracle method
	ServiceFeeCap sdk.Coins      `json:"service_fee_cap"` // service fee cap
}

MsgRequestRand represents a msg for requesting a random number

func (MsgRequestRand) GetSignBytes

func (msg MsgRequestRand) GetSignBytes() []byte

Implements Msg.

func (MsgRequestRand) GetSigners

func (msg MsgRequestRand) GetSigners() []sdk.AccAddress

Implements Msg.

func (MsgRequestRand) Route

func (msg MsgRequestRand) Route() string

func (MsgRequestRand) Type

func (msg MsgRequestRand) Type() string

Implements Msg.

func (MsgRequestRand) ValidateBasic

func (msg MsgRequestRand) ValidateBasic() error

Implements Msg.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL