pegnet

package
v0.0.0-...-271626f Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PegnetdSyncVersion is an indicator of the version of pegnetd
	// at each height synced. This version number can differ from the tagged
	// version, and is likely only to be updated at hard forks. It is used to
	// detect if a pegnetd was updated late, and therefore has an invalid state.
	//
	// Each fork should increment this number by at least 1
	PegnetdSyncVersion = 1
)

Functions

This section is empty.

Types

type BlockSync

type BlockSync struct {
	Synced uint32
}

type PEGPricingPhase

type PEGPricingPhase int
const (
	PEGPriceIsZero     PEGPricingPhase // PEG == 0
	PEGPriceIsEquation                 // PEG == MarketCap / Peg Supply
	PEGPriceIsFloating                 // PEG == ExchRate
)

type Pegnet

type Pegnet struct {
	Config *viper.Viper

	// This is the sqlite db to store state
	DB *sql.DB
}

func New

func New(conf *viper.Viper) *Pegnet

func (*Pegnet) Init

func (p *Pegnet) Init() error

func (*Pegnet) InsertGradeBlock

func (p *Pegnet) InsertGradeBlock(tx *sql.Tx, eblock *factom.EBlock, graded grader.GradedBlock) error

func (*Pegnet) InsertRates

func (p *Pegnet) InsertRates(tx *sql.Tx, height uint32, rates []opr.AssetUint, phase PEGPricingPhase) error

InsertRates adds all asset rates as rows, computing the rate for PEG if necessary

func (*Pegnet) InsertSynced

func (p *Pegnet) InsertSynced(tx *sql.Tx, bs *BlockSync) error

func (Pegnet) MarkHeightSynced

func (p Pegnet) MarkHeightSynced(tx QueryAble, height uint32) error

func (*Pegnet) SelectIssuances

func (p *Pegnet) SelectIssuances() (map[fat2.PTicker]uint64, error)

func (*Pegnet) SelectPreviousWinners

func (p *Pegnet) SelectPreviousWinners(ctx context.Context, height uint32) ([]string, error)

func (Pegnet) SelectSynced

func (Pegnet) SelectSynced(ctx context.Context, tx QueryAble) (*BlockSync, error)

type QueryAble

type QueryAble interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	Prepare(query string) (*sql.Stmt, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

QueryAble is so we can swap db and tx interactions

Jump to

Keyboard shortcuts

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