models

package module
v0.0.0-...-db5413b Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const PRV_ID = "0000000000000000000000000000000000000000000000000000000000000004"
View Source
const TimeStampFormat = "2006-01-02 15:04:05 MST"

Variables

View Source
var BIG_COINS = COINS{
	COIN{Name: "PRV", ID: PRV_ID, Dec: 1e-09},
	COIN{Name: "ETH", ID: "ffd8d42dc40a8d166ea4848baf8b5f6e912ad79875f4373070b59392b1756c8f", Dec: 1e-09},
	COIN{Name: "XMR", ID: "c01e7dc1d1aba995c19b257412340b057f8ad1482ccb6a9bb0adce61afbf05d4", Dec: 1e-09},
	COIN{Name: "USDT", ID: "716fd1009e2a1669caacc36891e707bfdf02590f96ebd897548e8963c95ebac0", Dec: 1e-06},
	COIN{Name: "USDC", ID: "1ff2da446abfebea3ba30385e2ca99b0f0bbeda5c6371f4c23c939672b429a42", Dec: 1e-06},
	COIN{Name: "BTC", ID: "b832e5d3b1f01a4f0623f7fe91d6673461e1f5d37d91fe78c5c2e6183ff39696", Dec: 1e-09},
	COIN{Name: "BUSD", ID: "9e1142557e63fd20dee7f3c9524ffe0aa41198c494aa8d36447d12e85f0ddce7", Dec: 1e-06},
	COIN{Name: "BNB", ID: "b2655152784e8639fa19521a7035f331eea1f1e911b2f3200a507ebb4554387b", Dec: 1e-09},
	COIN{Name: "DAI", ID: "3f89c75324b46f13c7b036871060e641d996a24c09b3065835cb1d38b799d6c1", Dec: 1e-09},
	COIN{Name: "SAI", ID: "d240c61c6066fed0535df9302f1be9f5c9728ef6d01ce88d525c4f6ff9d65a56", Dec: 1e-06},
	COIN{Name: "TUSD", ID: "8c3a61e77061265aaefa1e7160abfe343c2189278dd224bb7da6e7edc6a1d4db", Dec: 1e-06},
	COIN{Name: "TOMO", ID: "a0a22d131bbfdc892938542f0dbe1a7f2f48e16bc46bf1c5404319335dc1f0df", Dec: 1e-06},
	COIN{Name: "LINK", ID: "e0926da2436adc42e65ca174e590c7b17040cd0b7bdf35982f0dd7fc067f6bcf", Dec: 1e-06},
	COIN{Name: "BAT", ID: "1fe75e9afa01b85126370a1583c7af9f1a5731625ef076ece396fcc6584c2b44", Dec: 1e-06},
	COIN{Name: "BAND", ID: "2dda855fb4660225882d11136a64ad80effbddfa18a168f78924629b8664a6b3", Dec: 1e-06},
	COIN{Name: "ZRX", ID: "de395b1914718702687b477703bdd36e52119033a9037bb28f6b33a3d0c2f867", Dec: 1e-06},
	COIN{Name: "FTM", ID: "d09ad0af0a34ea3e13b772ef9918b71793a18c79b2b75aec42c53b69537029fe", Dec: 1e-06},
	COIN{Name: "ZIL", ID: "880ea0787f6c1555e59e3958a595086b7802fc7a38276bcd80d4525606557fbc", Dec: 1e-06},
	COIN{Name: "MCO", ID: "caaf286e889a8e0cee122f434d3770385a0fd92d27fcee737405b73c45b4f05f", Dec: 1e-06},
	COIN{Name: "GUSD", ID: "465b0f709844be95d97e1f5c484e79c6c1ac51d28de2a68020e7313d34f644fe", Dec: 1e-06},
	COIN{Name: "PAX", ID: "4a790f603aa2e7afe8b354e63758bb187a4724293d6057a46859c81b7bd0e9fb", Dec: 1e-06},
	COIN{Name: "KCS", ID: "513467653e06af73cd2b2874dd4af948f11f1c6f2689e994c055fd6934349e05", Dec: 1e-06},
	COIN{Name: "OMG", ID: "249ca174b4dce58ea6e1f8eda6e6f74ab6a3de4e4913c4f50c15101001bb467b", Dec: 1e-06},
}

Functions

func CheckIfPresent

func CheckIfPresent(pubkey string, arr *[]TPubKey) bool

func GetBeaconBestStateDetail

func GetBeaconBestStateDetail(reqUrl string, bbsd *BBSD) error

func GetBlockChainInfo

func GetBlockChainInfo(reqUrl string, bci *BCI) error

func GetMinerRewardFromMiningKey

func GetMinerRewardFromMiningKey(reqUrl string, key string, mrmfk *MRFMK) error

func GetTSString

func GetTSString(ts int64) string

func GetTSTime

func GetTSTime(ts int64) time.Time

func GetTsMonthLimitsFromTm

func GetTsMonthLimitsFromTm(tm time.Time) (int64, int64)

Returns the timestamps from begin of month to begin of next month of the Time passed

func GetTsMonthLimitsFromTs

func GetTsMonthLimitsFromTs(timestamp int64) (int64, int64)

Returns the timestamps from begin of month to begin of next month of the TimeStamp passed

func MakeTSFromString

func MakeTSFromString(t string) (int64, error)

func MakeTSFromTime

func MakeTSFromTime(t time.Time) int64

Types

type BBSD

type BBSD struct {
	Id      int
	Result  TBeaconStateResult
	Error   string
	Params  []string
	Method  string
	Jsonrpc string
}

type BCI

type BCI struct {
	Id      int
	Result  TBlochChainInfo
	Error   string
	Params  []string
	Method  string
	Jsonrpc string
}

type COIN

type COIN struct {
	Name string
	ID   string
	Dec  float64
}

type COINS

type COINS []COIN

func (*COINS) GetCoinByName

func (coins *COINS) GetCoinByName(name string) COIN

func (*COINS) GetFloat64Val

func (coins *COINS) GetFloat64Val(name string, valint int64) float64

func (*COINS) GetNameByID

func (coins *COINS) GetNameByID(id string) string

type ChatKey

type ChatKey struct {
	ChatID   int64
	KeyAlias string
	PubKey   string
}

type ChatUser

type ChatUser struct {
	ChatID    int64
	Name      string
	NameAsked bool
	Notify    bool
}

type Cmd

type Cmd struct {
	Cmd   string
	Descr string
}

type DBnode

type DBnode struct {
	DB *sql.DB
}

func NewDB

func NewDB(driverName, dataSourceName string) (*DBnode, error)

func (*DBnode) AddLotteryTickets

func (db *DBnode) AddLotteryTickets(ts int64, pubkey string) ([]LotteryKey, error)

add Lottery tickets for the pubkey on every lottery this pubkey belongs with current timestamp and returns slice of LotteryKeys (or err) parameters: ts the TimeStamp, pubkey involved

func (*DBnode) ChangeNotify

func (db *DBnode) ChangeNotify(ChatID int64) bool

Cambia Notify per ChatID (ritorna il Notify impostato oppure false se non riesce)

func (*DBnode) CreateTablesIfNotExists

func (db *DBnode) CreateTablesIfNotExists() error

func (*DBnode) CreateUserByChatID

func (db *DBnode) CreateUserByChatID(chatID int64) (*ChatUser, error)

Crea un utente vuoto

func (*DBnode) DelChatKey

func (db *DBnode) DelChatKey(chatID int64, keyAlias string) error

Elimina ChatKey con chiave `ChatID`+`KeyAlias`

func (*DBnode) DelNode

func (db *DBnode) DelNode(unid int64) error

Elimina UrlNode con chiave `UNId`

func (*DBnode) GetChatKey

func (db *DBnode) GetChatKey(chatID int64, keyAlias string) (*ChatKey, error)

Recupera una Chiave della Chat dati ChatID e KeyAlias

func (*DBnode) GetChatKeyFromPub

func (db *DBnode) GetChatKeyFromPub(chatID int64, pubkey string) (*ChatKey, error)

Recupera una Chiave della Chat dati ChatID e PubKey

func (*DBnode) GetChatKeys

func (db *DBnode) GetChatKeys(chatID int64, limit, offset int) (*[]ChatKey, error)

Recupera lista chiavi per ChatID

func (*DBnode) GetChatKeysByPubKey

func (db *DBnode) GetChatKeysByPubKey(pubkey string, limit, offset int) (*[]ChatKey, error)

Recupera lista chiavi Chat per PubKey

func (*DBnode) GetFionaText

func (db *DBnode) GetFionaText() string

func (*DBnode) GetLotteries

func (db *DBnode) GetLotteries() ([]Lottery, error)

returns the slice of all Lotteries (or err)

func (*DBnode) GetLotteryByKey

func (db *DBnode) GetLotteryByKey(loid int64) Lottery

returns Lottery by the given loid

func (*DBnode) GetLotteryChatIDS

func (db *DBnode) GetLotteryChatIDS(loid int64) ([]LotteryChat, error)

returns the slice of LotteryChat (or err) for the given LotteryID (LOId)

func (*DBnode) GetLotteryExtract

func (db *DBnode) GetLotteryExtract(loid int64, tm time.Time) (int, error)

Returns the number of next extraction to do from a set of tickets given LOId and timestamp of the requested month returns err if problems

func (*DBnode) GetLotteryExtraction

func (db *DBnode) GetLotteryExtraction(loid, timestamp int64) (LotteryExtraction, error)

return the lottery extraction given LOId and Timestamp or error

func (*DBnode) GetLotteryIDS

func (db *DBnode) GetLotteryIDS(chatid int64) ([]LotteryChat, error)

returns the slice of LotteryChat (or err) for the given ChatID

func (*DBnode) GetLotteryKeyByKey

func (db *DBnode) GetLotteryKeyByKey(loid int64, pubkey string) LotteryKey

returns LotteryKey by the given loid,pubkey

func (*DBnode) GetLotteryKeysByPuKey

func (db *DBnode) GetLotteryKeysByPuKey(pubkey string) ([]LotteryKey, error)

returns the slice of LotteryKey (or err) for the given pubkey

func (*DBnode) GetLotteryTickets

func (db *DBnode) GetLotteryTickets(loid int64, tm time.Time, extract int64) ([]LotteryTicket, error)

list Lottery tickets by month of timestamp for a LOId with extract passed if extract=-1 returns all and returns slice of LotteryTickets (or err)

func (*DBnode) GetMiningKey

func (db *DBnode) GetMiningKey(pubkey string) (*MiningKey, error)

Recupera una MiningKey

func (*DBnode) GetMiningKeys

func (db *DBnode) GetMiningKeys(limit, offset int) (*[]MiningKey, error)

Recupera lista chiavi mining

func (*DBnode) GetNotify

func (db *DBnode) GetNotify(ChatID int64) bool

Torna Notify boolean per ChatID

func (*DBnode) GetRingraziamentoText

func (db *DBnode) GetRingraziamentoText() string

func (*DBnode) GetUrlNode

func (db *DBnode) GetUrlNode(chatID int64, NodeName string) (*UrlNode, error)

Recupera un Nodo della Chat

func (*DBnode) GetUrlNodes

func (db *DBnode) GetUrlNodes(chatID int64, limit, offset int) (*[]UrlNode, error)

Recupera lista nodi per ChatID

func (*DBnode) GetUserByChatID

func (db *DBnode) GetUserByChatID(chatID int64) (*ChatUser, error)

Recupera un record utente o lo crea vuoto se non esiste

func (*DBnode) GetUsersList

func (db *DBnode) GetUsersList(limit, offset int) (*[]ChatUser, error)

Recupera lista utenti

func (*DBnode) NotifyAllLotteryUsersTicket

func (db *DBnode) NotifyAllLotteryUsersTicket(ts int64, lotterykeys []LotteryKey, callback LotteryUserTicketNotifierFunc) error

Calls the LotteryUserTicketNotifierFunc for all the ChatUsers that knows that ChatKey

func (*DBnode) ReplaceLotteryExtraction

func (db *DBnode) ReplaceLotteryExtraction(lotteryextraction LotteryExtraction) error

Deletes the lottery extraction of the same month if exists and save the one passed returns error if problems

func (*DBnode) UpdateChatKey

func (db *DBnode) UpdateChatKey(chatKey *ChatKey) error

Aggiorna/crea ChatKey con chiave `ChatID`+`KeyAlias`

func (*DBnode) UpdateLotteryTicketWinner

func (db *DBnode) UpdateLotteryTicketWinner(ticket LotteryTicket) error

save the field Extracted of the ticket if there isn't another for the same lottery. Returns err if problems

func (*DBnode) UpdateMiningKey

func (db *DBnode) UpdateMiningKey(miningkey *MiningKey, callback StatusChangeNotifierFunc) error

Aggiorna/crea MiningKey con chiave `PubKey`

func (*DBnode) UpdateUrlNode

func (db *DBnode) UpdateUrlNode(urlnode *UrlNode) error

Aggiorna/crea UrlNode con chiave `ChatID`+`NodeName`

func (*DBnode) UpdateUser

func (db *DBnode) UpdateUser(user *ChatUser) error

Aggiorna utente

type Env

type Env struct {
	DBFILE               string
	Db                   *DBnode
	TOKEN                string
	TGTOKEN              string
	API                  string
	BOT_NAME             string
	BOT_CMDS             []Cmd
	DEFAULT_NODE_URL     string
	DEFAULT_FULLNODE_URL string
}

func NewEnv

func NewEnv() *Env

func (*Env) GetSendMessageUrl

func (env *Env) GetSendMessageUrl() string

func (*Env) NotifyTicket

func (env *Env) NotifyTicket(loid, ts int64, chatuser *ChatUser, chatkey *ChatKey) error

func (*Env) PrintBOT_CMDS

func (env *Env) PrintBOT_CMDS() string

func (*Env) RemoveCmd

func (env *Env) RemoveCmd(text string) string

ritorna la stringa dopo aver rimosso il comando o comando@nomebot

func (*Env) SayErr

func (env *Env) SayErr(chatID int64, err error) error

func (*Env) SayText

func (env *Env) SayText(chatID int64, text string) error

func (*Env) StatusChanged

func (env *Env) StatusChanged(miningkey *MiningKey, oldstat string, oldprv int64) error

func (*Env) StrCmd

func (env *Env) StrCmd(text string) string

ritorna il comando,se presente, e senza @nomebot tutto minuscolo. Altrimenti stringa vuota

type Lottery

type Lottery struct {
	LOId               int64
	ChatID             int64
	LotteryName        string
	LotteryDescription string
}

type LotteryChat

type LotteryChat struct {
	LOId   int64
	ChatID int64
}

type LotteryExtraction

type LotteryExtraction struct {
	LOId      int64
	Timestamp int64
	Nonce     int64
	BTCBlock  int64
}

type LotteryKey

type LotteryKey struct {
	LOId         int64
	PubKey       string
	DefaultAlias string
}

type LotteryTicket

type LotteryTicket struct {
	LOId      int64
	PubKey    string
	Timestamp int64
	Extracted int64
}

type LotteryUserTicketNotifierFunc

type LotteryUserTicketNotifierFunc func(loid, ts int64, chatuser *ChatUser, chatkey *ChatKey) error //Signals addition of a new ticket of a key in Users of the Lottery

type MRFMK

type MRFMK struct {
	Id      int
	Result  TMinerReward
	Error   string
	Params  []string
	Method  string
	Jsonrpc string
}

type MiningKey

type MiningKey struct {
	PubKey      string
	LastStatus  string
	LastPRV     int64
	IsAutoStake bool
	Bls         string
	Dsa         string
}

type StatusChangeNotifierFunc

type StatusChangeNotifierFunc func(miningkey *MiningKey, oldstatus string, oldprv int64) error

type TBeaconStateResult

type TBeaconStateResult struct {
	BestBlockHash                          string
	PreviousBestBlockHash                  string
	BestShardHash                          map[string]string
	BestShardHeight                        map[string]int
	Epoch                                  int
	BeaconHeight                           int
	BeaconProposerIndex                    int
	BeaconCommittee                        []TPubKey
	BeaconPendingValidator                 []TPubKey
	CandidateShardWaitingForCurrentRandom  []TPubKey
	CandidateBeaconWaitingForCurrentRandom []TPubKey
	CandidateShardWaitingForNextRandom     []TPubKey
	CandidateBeaconWaitingForNextRandom    []TPubKey
	RewardReceiver                         interface{}
	ShardCommittee                         map[string][]TPubKey
	ShardPendingValidator                  map[string][]TPubKey
	AutoStaking                            []TPubKeyAuto
	CurrentRandomNumber                    int
	CurrentRandomTimeStamp                 int
	IsGetRandomNumber                      bool
	MaxBeaconCommitteeSize                 int
	MinBeaconCommitteeSize                 int
	MaxShardCommitteeSize                  int
	MinShardCommitteeSize                  int
	ActiveShards                           int
	LastCrossShardState                    interface{}
	ShardHandle                            interface{}
}

type TBestBlock

type TBestBlock struct {
	Height              int64
	Hash                string
	TotalTxs            int64
	BlockProducer       string
	ValidationData      interface{}
	Epoch               int64
	Time                int64
	RemainingBlockEpoch int
	EpochBlock          int
}

type TBlochChainInfo

type TBlochChainInfo struct {
	ChainName    string
	BestBlocks   map[string]TBestBlock
	ActiveShards int
}

type TMinerReward

type TMinerReward map[string]int64

func (*TMinerReward) GetNameValuePair

func (mr *TMinerReward) GetNameValuePair(nameid string) (string, int64)

func (*TMinerReward) GetPRV

func (mr *TMinerReward) GetPRV() int64

func (*TMinerReward) GetValueIDs

func (mr *TMinerReward) GetValueIDs() []string

func (*TMinerReward) GetValueNames

func (mr *TMinerReward) GetValueNames() []string

type TMiningPubKey

type TMiningPubKey struct {
	Bls string
	Dsa string
}

type TPubKey

type TPubKey struct {
	IncPubKey    string
	MiningPubKey TMiningPubKey
}

type TPubKeyAuto

type TPubKeyAuto struct {
	IncPubKey    string
	MiningPubKey TMiningPubKey
	IsAutoStake  bool
}

func CheckAutoStake

func CheckAutoStake(pubkey string, arr *[]TPubKeyAuto) (bool, *TPubKeyAuto)

ritorna vero se trovato in AutoStake=true più la completa TPubKeyAuto

type TPubKeyInfo

type TPubKeyInfo struct {
	IncPubKey    string
	MiningPubKey TMiningPubKey
	IsAutoStake  bool
	PRV          int64
}

func GetPubKeyStatus

func GetPubKeyStatus(bbsd *BBSD, pubkey string) (string, *TPubKeyInfo)

ritorna status più puntatore a TPubKeyInfo se trovata attiva

type UrlNode

type UrlNode struct {
	UNId     int64
	ChatID   int64
	NodeName string
	NodeURL  string
}

Jump to

Keyboard shortcuts

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