db

package
v0.2.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Account string `gorm:"primaryKey"`
	Balance uint64
	Nonce   uint64
}

func (*Account) ToGQL

func (a *Account) ToGQL() *model.Account

type AccountBalanceNotify

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

func NewAccountBalanceNotify

func NewAccountBalanceNotify(account string, channel chan *model.Account, db *Database) *AccountBalanceNotify

func (*AccountBalanceNotify) Notify

func (a *AccountBalanceNotify) Notify()

type Block

type Block struct {
	Hash      []byte `gorm:"primaryKey"`
	Height    uint64
	Slot      uint64
	Txs       []Tx
	Deposits  []Deposit
	Votes     []Vote
	Exits     []Exit
	RawBlock  []byte
	Timestamp uint64
}

func (*Block) DepositsGQL

func (b *Block) DepositsGQL() []*model.Deposit

func (*Block) ExitsGQL

func (b *Block) ExitsGQL() []*model.Exit

func (*Block) ToGQL

func (b *Block) ToGQL() *model.Block

func (*Block) TxsGQL

func (b *Block) TxsGQL() []*model.Tx

func (*Block) VotesGQL

func (b *Block) VotesGQL() []*model.Vote

type BlockHeader

type BlockHeader struct {
	Hash                        []byte `gorm:"primaryKey"`
	Version                     uint64
	Nonce                       []byte
	Timestamp                   time.Time
	Slot                        uint64
	FeeAddress                  []byte
	PreviousBlockHash           []byte
	VotesMerkleRoot             []byte
	DeposistMerkleRoot          []byte
	ExitsMerkleRoot             []byte
	PartialExitsMerkleRoot      []byte
	CoinProofsMerkleRoot        []byte
	ExecutionsMerkleRoot        []byte
	TxsMerkleRoot               []byte
	VoteSlashingMerkleRoot      []byte
	RandaoSlashingMerkleRoot    []byte
	ProposerSlashingMerkleRoot  []byte
	GovernanceVotesMerkleRoot   []byte
	MultiSignatureTxsMerkleRoot []byte
}

func (*BlockHeader) ToGQL

func (b *BlockHeader) ToGQL() *model.BlockHeader

type CoinProofs

type CoinProofs struct {
	Hash          []byte `gorm:"primarykey"`
	Transaction   []byte
	RedeemAccount string
}

func (*CoinProofs) ToGQL

func (c *CoinProofs) ToGQL() *model.CoinProofs

type Database

type Database struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

Database represents an DB connection

func NewDB

func NewDB(dbConnString string, log logger.Logger, wg *sync.WaitGroup, netParams *params.ChainParams) *Database

NewDB creates a db client

func (*Database) AddAccountBalanceNotifier

func (d *Database) AddAccountBalanceNotifier(account string, u uuid.UUID, n *AccountBalanceNotify)

func (*Database) AddAccounts

func (d *Database) AddAccounts(a []Account) error

func (*Database) AddBlock

func (d *Database) AddBlock(b *Block) error

func (*Database) AddEpoch

func (d *Database) AddEpoch(e *Epoch) error

func (*Database) AddHeader

func (d *Database) AddHeader(h *BlockHeader) error

func (*Database) AddSlot

func (d *Database) AddSlot(s *Slot) error

func (*Database) AddSlotVoteInclusions

func (d *Database) AddSlotVoteInclusions(s uint64, votes int) error

func (*Database) AddTipNotifier

func (d *Database) AddTipNotifier(u uuid.UUID, n *TipNotify)

func (*Database) AddValidators

func (d *Database) AddValidators(v *[]Validator) error

func (*Database) Close

func (d *Database) Close()

func (*Database) GetEpochParticipation

func (d *Database) GetEpochParticipation(e int) (string, error)

func (*Database) GetLastSlot

func (d *Database) GetLastSlot() (uint64, error)

func (*Database) GetRawBlock

func (d *Database) GetRawBlock(hash chainhash.Hash) (*primitives.Block, uint64, error)

func (*Database) GetState

func (d *Database) GetState() (state.State, chainhash.Hash, uint64, error)

func (*Database) MarkSlotProposed

func (d *Database) MarkSlotProposed(s *Slot) error

func (*Database) Migrate

func (d *Database) Migrate() error

func (*Database) RemoveAccountBalanceNotifier

func (d *Database) RemoveAccountBalanceNotifier(account string, u uuid.UUID)

func (*Database) RemoveTipNotifier

func (d *Database) RemoveTipNotifier(u uuid.UUID)

func (*Database) SetFinalized

func (d *Database) SetFinalized(e uint64) error

func (*Database) SetJustified

func (d *Database) SetJustified(e uint64) error

func (*Database) StoreState

func (d *Database) StoreState(s state.State, lastBlock *chainindex.BlockRow) error

type Deposit

type Deposit struct {
	Hash      []byte `gorm:"primaryKey"`
	BlockHash []byte
	PublicKey []byte
	Data      DepositData `gorm:"foreignKey:Hash"`
}

func (*Deposit) ToGQL

func (d *Deposit) ToGQL() *model.Deposit

type DepositData

type DepositData struct {
	Hash              []byte
	PublicKey         []byte `gorm:"primaryKey"`
	ProofOfPossession []byte
	WithdrawalAddress []byte
}

func (*DepositData) ToGQL

func (d *DepositData) ToGQL() *model.DepositData

type Epoch

type Epoch struct {
	Epoch         uint64 `gorm:"primaryKey"`
	Slot1         uint64
	Slot2         uint64
	Slot3         uint64
	Slot4         uint64
	Slot5         uint64
	ExpectedVotes uint64
	Finalized     bool
	Justified     bool
	Randao        []byte
}

func (*Epoch) ToGQL

func (e *Epoch) ToGQL() *model.Epoch

type Exit

type Exit struct {
	Hash                []byte `gorm:"primarykey"`
	BlockHash           []byte
	ValidatorPublicKey  []byte
	WithdrawalPublicKey []byte
}

func (*Exit) ToGQL

func (e *Exit) ToGQL() *model.Exit

type PartialExit

type PartialExit struct {
	Hash                []byte
	BlockHash           []byte
	ValidatorPublicKey  []byte
	WithdrawalPublicKey []byte
	Amount              uint64
}

type Slot

type Slot struct {
	Epoch         uint64
	Slot          uint64 `gorm:"primaryKey"`
	BlockHash     []byte
	ProposerIndex uint64
	Proposed      bool
	VotesIncluded uint64
}

func (*Slot) ToGQL

func (s *Slot) ToGQL() *model.Slot

type State

type State struct {
	Key             string `gorm:"primaryKey"`
	Raw             []byte
	LastBlock       []byte
	LastBlockHeight uint64
}

type TipNotify

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

func NewTipNotify

func NewTipNotify(channel chan *model.Tip, db *Database) *TipNotify

func (*TipNotify) Notify

func (t *TipNotify) Notify()

type Tx

type Tx struct {
	BlockHash         []byte
	Hash              []byte `gorm:"primarykey"`
	ToAddress         string
	FromPublicKeyHash string
	FromPublicKey     []byte
	Amount            uint64
	Nonce             uint64
	Fee               uint64
	Timestamp         uint64
}

func (*Tx) ToGQL

func (t *Tx) ToGQL() *model.Tx

type Validator

type Validator struct {
	Balance          uint64
	PubKey           []byte `gorm:"primaryKey"`
	PayeeAddress     string
	Status           uint64
	FirstActiveEpoch uint64
	LastActiveEpoch  uint64
}

func (*Validator) ToGQL

func (v *Validator) ToGQL() *model.Validator

type Vote

type Vote struct {
	BlockHash             []byte
	ParticipationBitfield []byte
	Hash                  []byte   `gorm:"primaryKey"`
	Data                  VoteData `gorm:"foreignKey:Hash"`
}

func (*Vote) ToGQL

func (v *Vote) ToGQL() *model.Vote

type VoteData

type VoteData struct {
	Hash            []byte `gorm:"primaryKey"`
	Slot            uint64
	FromEpoch       uint64
	FromHash        []byte
	ToEpoch         uint64
	ToHash          []byte
	BeaconBlockHash []byte
	Nonce           []byte
}

func (*VoteData) ToGQL

func (v *VoteData) ToGQL() *model.VoteData

Jump to

Keyboard shortcuts

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