dom

package module
v2.0.0-...-270b32b Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

go-dom

A lottery algorithm library based on the Ethereum mainnet in Golang.

1.5+

Usage:

go get gopkg.in/dom.v1

1.5-

go get gopkg.in/go-dom/lottery.v1

Example usage:

package main

import (
	"fmt"

	"gopkg.in/dom.v1"
)

func main() {
	user := []int64{
		124875175,
		12848475,
		15768612,
		432867286,
		3268742,
		262274327,
		27923727382,
		23672472472,
		72472472,
	}
	client, err := dom.NewClient().SetUrl("https://apikey.eth.rpc.rivet.cloud/").SetDebug().Dial()
	if err != nil {
		panic(err)
	}
	defer client.Close()

	session, err := client.NewSession(&lottery.Session{
		PrizeNum: 2,
		UserID:   user,
	})
	if err != nil {
		panic(err)
	}

	data, err := session.Do()
	if err != nil {
		panic(err)
	}

	fmt.Println(data)
}

TODO

License

This software is distributed under GNU Affero General Public License v3.0 license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBroke

type DBroke[E []T, T string | int64] struct {
	// contains filtered or unexported fields
}

func NewInt64

func NewInt64() *DBroke[[]int64, int64]

func NewString

func NewString() *DBroke[[]string, string]

func (*DBroke[E, T]) AddPrize

func (b *DBroke[E, T]) AddPrize(data string) *DBroke[E, T]

func (*DBroke[E, T]) AddUser

func (b *DBroke[E, T]) AddUser(data T) *DBroke[E, T]

func (*DBroke[E, T]) Do

func (b *DBroke[E, T]) Do() ([]WinnerPrizePair[T], bool)

func (*DBroke[E, T]) ExportData

func (b *DBroke[E, T]) ExportData() *LotteryData[E, T]

func (*DBroke[E, T]) NewLotteryID

func (b *DBroke[E, T]) NewLotteryID()

func (*DBroke[E, T]) SetBlock

func (b *DBroke[E, T]) SetBlock(data string) *DBroke[E, T]

func (*DBroke[E, T]) SetLotteryID

func (b *DBroke[E, T]) SetLotteryID(data string) *DBroke[E, T]

func (*DBroke[E, T]) SetPrizes

func (b *DBroke[E, T]) SetPrizes(data []string) *DBroke[E, T]

func (*DBroke[E, T]) SetUsers

func (b *DBroke[E, T]) SetUsers(data E) *DBroke[E, T]

type LotteryData

type LotteryData[E []T, T string | int64] struct {
	LotteryID string
	UserIDs   E
	PrizeList []string
	BlockHash string
}

func (LotteryData[E, T]) DrawLottery

func (data LotteryData[E, T]) DrawLottery() []WinnerPrizePair[T]

type WinnerPrizePair

type WinnerPrizePair[T string | int64] struct {
	Winner T
	Prize  string
}

Jump to

Keyboard shortcuts

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