common

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const DEBUG = 5
View Source
const HTTPTimeout = 8 * time.Second

HTTPTimeout timeout used in HTTP connections between nodes

View Source
const SHORT = 4
View Source
const VERBOSE = 6
View Source
const VideoProfileIDBytes = 4
View Source
const VideoProfileIDSize = 8

Variables

View Source
var (
	ErrParseBigInt = fmt.Errorf("failed to parse big integer")
	ErrProfile     = fmt.Errorf("failed to parse profile")
)
View Source
var ErrDBTooNew = errors.New("DB Too New")
View Source
var LivepeerDBVersion = 1
View Source
var RandomIDGenerator = func(length uint) string {
	x := make([]byte, length, length)
	for i := 0; i < len(x); i++ {
		x[i] = byte(rand.Uint32())
	}
	return hex.EncodeToString(x)
}

RandomIDGenerator generates random hexadecimal string of specified length defined as variable for unit tests

View Source
var VideoProfileByteLookup = makeVideoProfileByteMap()
View Source
var VideoProfileNameLookup = map[string]string{
	"a7ac137a": "P720p60fps16x9",
	"49d54ea9": "P720p30fps16x9",
	"e4a64019": "P720p25fps16x9",
	"79332fe7": "P720p30fps4x3",
	"5ecf4b52": "P576p30fps16x9",
	"8b1843d6": "P576p25fps16x9",
	"93c717e7": "P360p30fps16x9",
	"7cd40fc7": "P360p25fps16x9",
	"b60382a0": "P360p30fps4x3",
	"c0a6517a": "P240p30fps16x9",
	"1301a7d0": "P240p25fps16x9",
	"d435c53a": "P240p30fps4x3",
	"fca40bf9": "P144p30fps16x9",
	"03f01d1f": "P144p25fps16x9",
}

Functions

func BytesToVideoProfile added in v0.5.0

func BytesToVideoProfile(txData []byte) ([]ffmpeg.VideoProfile, error)

func GenErrRegex added in v0.5.0

func GenErrRegex(errStrings []string) *regexp.Regexp

GenErrRegex generates a regexp `(err1)|(err2)|(err3)` given a list of error strings [err1, err2, err3]

func GetConnectionAddr added in v0.5.0

func GetConnectionAddr(ctx context.Context) string

func MaxUint256OrFatal added in v0.5.0

func MaxUint256OrFatal(t *testing.T) *big.Int

func ParseBigInt added in v0.3.3

func ParseBigInt(num string) (*big.Int, error)

func PriceToFixed added in v0.5.0

func PriceToFixed(price *big.Rat) (int64, error)

PriceToFixed converts a big.Rat into a fixed point number represented as int64 using a scaleFactor of 1000 resulting in max decimal places of 3

func ProfilesNames added in v0.5.0

func ProfilesNames(profiles []ffmpeg.VideoProfile) string

func ProfilesToHex added in v0.5.0

func ProfilesToHex(profiles []ffmpeg.VideoProfile) string

func ProfilesToTranscodeOpts added in v0.3.3

func ProfilesToTranscodeOpts(profiles []ffmpeg.VideoProfile) []byte

func RandName added in v0.5.0

func RandName() string

RandName generates random hexadecimal string

func Retry

func Retry(attempts int, sleep time.Duration, fn func() error) error

func TxDataToVideoProfile added in v0.3.3

func TxDataToVideoProfile(txData string) ([]ffmpeg.VideoProfile, error)

func WaitAssert

func WaitAssert(t *testing.T, waitTime time.Duration, condition func() bool, msg string)

func WaitUntil

func WaitUntil(waitTime time.Duration, condition func() bool)

Types

type Broadcaster added in v0.5.1

type Broadcaster interface {
	Address() ethcommon.Address
	Sign([]byte) ([]byte, error)
}

type DB added in v0.3.3

type DB struct {
	// contains filtered or unexported fields
}

DB is an initialized DB driver with prepared statements

func InitDB added in v0.3.3

func InitDB(dbPath string) (*DB, error)

func TempDB added in v0.3.3

func TempDB(t *testing.T) (*DB, *sql.DB, error)

func (*DB) ChainID added in v0.5.0

func (db *DB) ChainID() (*big.Int, error)

func (*DB) Close added in v0.3.3

func (db *DB) Close()

func (*DB) DeleteMiniHeader added in v0.5.0

func (db *DB) DeleteMiniHeader(hash ethcommon.Hash) error

DeleteMiniHeader deletes a MiniHeader from the DB and takes in the blockhash of the block to be deleted as an argument

func (*DB) DeleteUnbondingLock added in v0.5.0

func (db *DB) DeleteUnbondingLock(id *big.Int, delegator ethcommon.Address) error

DeleteUnbondingLock deletes an unbonding lock from the DB with the given ID and delegator address. This method will return nil for non-existent unbonding locks

func (*DB) FindAllMiniHeadersSortedByNumber added in v0.5.0

func (db *DB) FindAllMiniHeadersSortedByNumber() ([]*blockwatch.MiniHeader, error)

FindAllMiniHeadersSortedByNumber returns all MiniHeaders in the DB sorting in descending order by block number

func (*DB) FindLatestMiniHeader added in v0.5.0

func (db *DB) FindLatestMiniHeader() (*blockwatch.MiniHeader, error)

FindLatestMiniHeader returns the MiniHeader with the highest blocknumber in the DB

func (*DB) InsertMiniHeader added in v0.5.0

func (db *DB) InsertMiniHeader(header *blockwatch.MiniHeader) error

InsertMiniHeader inserts a MiniHeader into the database

func (*DB) InsertUnbondingLock added in v0.3.3

func (db *DB) InsertUnbondingLock(id *big.Int, delegator ethcommon.Address, amount, withdrawRound *big.Int) error

func (*DB) LastSeenBlock added in v0.3.3

func (db *DB) LastSeenBlock() (*big.Int, error)

LastSeenBlock returns the last block number stored by the DB

func (*DB) LoadWinningTickets added in v0.5.0

func (db *DB) LoadWinningTickets(sessionIDs []string) (tickets []*pm.Ticket, sigs [][]byte, recipientRands []*big.Int, err error)

func (*DB) OrchCount added in v0.5.1

func (db *DB) OrchCount(filter *DBOrchFilter) (int, error)

func (*DB) SelectOrchs added in v0.5.0

func (db *DB) SelectOrchs(filter *DBOrchFilter) ([]*DBOrch, error)

func (*DB) SetChainID added in v0.5.0

func (db *DB) SetChainID(id *big.Int) error

func (*DB) StoreWinningTicket added in v0.5.0

func (db *DB) StoreWinningTicket(sessionID string, ticket *pm.Ticket, sig []byte, recipientRand *big.Int) error

func (*DB) UnbondingLockIDs added in v0.3.3

func (db *DB) UnbondingLockIDs() ([]*big.Int, error)

func (*DB) UnbondingLocks added in v0.3.3

func (db *DB) UnbondingLocks(currentRound *big.Int) ([]*DBUnbondingLock, error)

func (*DB) UpdateOrch added in v0.5.0

func (db *DB) UpdateOrch(orch *DBOrch) error

func (*DB) UseUnbondingLock added in v0.3.3

func (db *DB) UseUnbondingLock(id *big.Int, delegator ethcommon.Address, usedBlock *big.Int) error

UseUnbondingLock sets an unbonding lock in the DB as used by setting the lock's used block. If usedBlock is nil this method will set the lock's used block to NULL

type DBOrch added in v0.5.0

type DBOrch struct {
	ServiceURI        string
	EthereumAddr      string
	PricePerPixel     int64
	ActivationRound   int64
	DeactivationRound int64
}

DBOrch is the type binding for a row result from the orchestrators table

func NewDBOrch added in v0.5.0

func NewDBOrch(ethereumAddr string, serviceURI string, pricePerPixel int64, activationRound int64, deactivationRound int64) *DBOrch

type DBOrchFilter added in v0.5.0

type DBOrchFilter struct {
	MaxPrice     *big.Rat
	CurrentRound *big.Int
}

DBOrchFilter is an object used to attach a filter to a selectOrch query

type DBUnbondingLock added in v0.3.3

type DBUnbondingLock struct {
	ID            int64
	Delegator     ethcommon.Address
	Amount        *big.Int
	WithdrawRound int64
}

DBOrch is the type binding for a row result from the unbondingLocks table

type OrchestratorPool added in v0.5.1

type OrchestratorPool interface {
	GetURLs() []*url.URL
	GetOrchestrators(int) ([]*net.OrchestratorInfo, error)
	Size() int
}

type OrchestratorStore added in v0.5.1

type OrchestratorStore interface {
	OrchCount(filter *DBOrchFilter) (int, error)
	SelectOrchs(filter *DBOrchFilter) ([]*DBOrch, error)
	UpdateOrch(orch *DBOrch) error
}

type StubServerStream added in v0.5.0

type StubServerStream struct {
}

func (*StubServerStream) Context added in v0.5.0

func (s *StubServerStream) Context() context.Context

func (*StubServerStream) RecvMsg added in v0.5.0

func (s *StubServerStream) RecvMsg(m interface{}) error

func (*StubServerStream) Send added in v0.5.0

func (*StubServerStream) SendHeader added in v0.5.0

func (s *StubServerStream) SendHeader(md metadata.MD) error

func (*StubServerStream) SendMsg added in v0.5.0

func (s *StubServerStream) SendMsg(m interface{}) error

func (*StubServerStream) SetHeader added in v0.5.0

func (s *StubServerStream) SetHeader(md metadata.MD) error

func (*StubServerStream) SetTrailer added in v0.5.0

func (s *StubServerStream) SetTrailer(md metadata.MD)

type VideoProfileByteMap added in v0.5.0

type VideoProfileByteMap map[[VideoProfileIDBytes]byte]string

Jump to

Keyboard shortcuts

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