pkg

package
v0.0.0-...-216fe0a Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoundsCount = 10
	RoundLength = 1000
)
View Source
const (
	FractalMin   = 50
	FractalMax   = 200
	FractalPrize = 5
)
View Source
const (
	VerificationMin = 21
	VerificationMax = 21
)
View Source
const (
	KeySize = 2048
)

Variables

View Source
var (
	BadBehavior = 0.1
)

Functions

This section is empty.

Types

type BehaviorType

type BehaviorType int
const (
	Normal BehaviorType = iota
	RandomVote
	BadVote
)

type CoinTable

type CoinTable struct {
	ID     string  `json:"id"`
	Amount float64 `json:"amount"`
	Status Status  `json:"status"`
	Type   uint    `json:"type"`
	Next   string  `json:"next"`
	Prev   string  `json:"prev"`
	Owner  string  `json:"owner"`

	CooperationID string
}

type CooperationTable

type CooperationTable struct {
	ID       string  `json:"id"`
	Weight   float64 `json:"weight"`
	Next     string  `json:"next"`
	Prev     string  `json:"prev"`
	Investor string  `json:"investor"`

	UnusedCoins [][]string `json:"-"`
	CoinIDs     []string
	FractalID   string
	IsValid     bool
	Rounds      int
}

type FractalRing

type FractalRing struct {
	ID               string             `json:"id"`
	CooperationRings []CooperationTable `json:"cooperation_rings"`
	VerificationTeam []string           `json:"verification_team"`

	SoloRings []string `json:"-"`
	IsValid   bool
}

type Status

type Status int
const (
	Run Status = iota
	Blocked
	Expired
)

type Trader

type Trader struct {
	ID        string         `json:"id"`
	Account   float64        `json:"account"`
	Wallet    string         `json:"wallet"`
	PublicKey *rsa.PublicKey `json:"public_key"`

	Data *TraderData `json:"-"`
}

func CreateTrader

func CreateTrader(traderType BehaviorType, account float64, wallet string, coinTypeCount uint) *Trader

func (*Trader) CheckForRings

func (t *Trader) CheckForRings() *FractalRing

func (*Trader) CreateCoin

func (t *Trader) CreateCoin(amount float64, coinType uint) *CoinTable

func (*Trader) ExpireRing

func (t *Trader) ExpireRing(ring CooperationTable)

func (*Trader) InformFractalRing

func (t *Trader) InformFractalRing(fractal FractalRing) error

func (*Trader) PayRing

func (t *Trader) PayRing(ring CooperationTable)

func (*Trader) RemoveFractalRing

func (t *Trader) RemoveFractalRing(fractalID string)

func (*Trader) SaveCoin

func (t *Trader) SaveCoin(coin CoinTable) error

func (*Trader) SaveTrader

func (t *Trader) SaveTrader(trader Trader) error

func (*Trader) SubmitRing

func (t *Trader) SubmitRing(ring *FractalRing) error

func (*Trader) UpdateBalance

func (t *Trader) UpdateBalance(traderID string, amount float64) error

func (*Trader) UpdateCoin

func (t *Trader) UpdateCoin(coin CoinTable) error

func (*Trader) Vote

func (t *Trader) Vote() error

type TraderData

type TraderData struct {
	TraderType    BehaviorType
	CoinTypeCount uint
	Ticker        *time.Ticker
	PrivateKey    *rsa.PrivateKey
	Traders       map[string]Trader
	Coins         map[string]CoinTable
	Cooperations  map[string]CooperationTable
}

Jump to

Keyboard shortcuts

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