db

package
v0.0.0-...-1dbe845 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 16 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrVAANotFound = errors.New("requested VAA not found in store")
)

Functions

func IsPendingMsg

func IsPendingMsg(keyBytes []byte) bool

func IsTransfer

func IsTransfer(keyBytes []byte) bool

func PendingMsgID

func PendingMsgID(k *common.MessagePublication) []byte

func TransferMsgID

func TransferMsgID(t *Transfer) []byte

Types

type AccountantDB

type AccountantDB interface {
	AcctStorePendingTransfer(msg *common.MessagePublication) error
	AcctDeletePendingTransfer(msgId string) error
	AcctGetData(logger *zap.Logger) ([]*common.MessagePublication, error)
}

type Database

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

func OpenDb

func OpenDb(logger *zap.Logger, dataDir *string) *Database

func (*Database) AcctDeletePendingTransfer

func (d *Database) AcctDeletePendingTransfer(msgId string) error

func (*Database) AcctGetData

func (d *Database) AcctGetData(logger *zap.Logger) ([]*common.MessagePublication, error)

This is called by the accountant on start up to reload pending transfers.

func (*Database) AcctStorePendingTransfer

func (d *Database) AcctStorePendingTransfer(msg *common.MessagePublication) error

func (*Database) Close

func (d *Database) Close() error

func (*Database) DeletePendingMsg

func (d *Database) DeletePendingMsg(pending *PendingTransfer) error

This is called by the chain governor to delete a pending transfer.

func (*Database) DeleteTransfer

func (d *Database) DeleteTransfer(t *Transfer) error

This is called by the chain governor to delete a transfer after the time limit has expired.

func (*Database) FindEmitterSequenceGap

func (d *Database) FindEmitterSequenceGap(prefix VAAID) (resp []uint64, firstSeq uint64, lastSeq uint64, err error)

func (*Database) GetChainGovernorData

func (d *Database) GetChainGovernorData(logger *zap.Logger) (transfers []*Transfer, pending []*PendingTransfer, err error)

This is called by the chain governor on start up to reload status.

func (*Database) GetChainGovernorDataForTime

func (d *Database) GetChainGovernorDataForTime(logger *zap.Logger, now time.Time) (transfers []*Transfer, pending []*PendingTransfer, err error)

func (*Database) GetSignedVAABytes

func (d *Database) GetSignedVAABytes(id VAAID) (b []byte, err error)

func (*Database) HasVAA

func (d *Database) HasVAA(id VAAID) (bool, error)

func (*Database) PurgeVaas

func (d *Database) PurgeVaas(prefix VAAID, oldestTime time.Time, logOnly bool) (string, error)

func (*Database) StorePendingMsg

func (d *Database) StorePendingMsg(pending *PendingTransfer) error

This is called by the chain governor to persist a pending transfer.

func (*Database) StoreSignedVAA

func (d *Database) StoreSignedVAA(v *vaa.VAA) error

func (*Database) StoreSignedVAABatch

func (d *Database) StoreSignedVAABatch(vaaBatch []*vaa.VAA) error

StoreSignedVAABatch writes multiple VAAs to the database using the BadgerDB batch API. Note that the API takes care of splitting up the slice into the maximum allowed count and size so we don't need to worry about that.

func (*Database) StoreTransfer

func (d *Database) StoreTransfer(t *Transfer) error

This is called by the chain governor to persist a pending transfer.

type GovernorDB

type GovernorDB interface {
	StoreTransfer(t *Transfer) error
	StorePendingMsg(k *PendingTransfer) error
	DeleteTransfer(t *Transfer) error
	DeletePendingMsg(k *PendingTransfer) error
	GetChainGovernorData(logger *zap.Logger) (transfers []*Transfer, pending []*PendingTransfer, err error)
}

type MockAccountantDB

type MockAccountantDB struct {
}

func (*MockAccountantDB) AcctDeletePendingTransfer

func (d *MockAccountantDB) AcctDeletePendingTransfer(msgId string) error

func (*MockAccountantDB) AcctGetData

func (d *MockAccountantDB) AcctGetData(logger *zap.Logger) ([]*common.MessagePublication, error)

func (*MockAccountantDB) AcctStorePendingTransfer

func (d *MockAccountantDB) AcctStorePendingTransfer(msg *common.MessagePublication) error

type MockGovernorDB

type MockGovernorDB struct {
}

func (*MockGovernorDB) DeletePendingMsg

func (d *MockGovernorDB) DeletePendingMsg(pending *PendingTransfer) error

func (*MockGovernorDB) DeleteTransfer

func (d *MockGovernorDB) DeleteTransfer(t *Transfer) error

func (*MockGovernorDB) GetChainGovernorData

func (d *MockGovernorDB) GetChainGovernorData(logger *zap.Logger) (transfers []*Transfer, pending []*PendingTransfer, err error)

func (*MockGovernorDB) StorePendingMsg

func (d *MockGovernorDB) StorePendingMsg(k *PendingTransfer) error

func (*MockGovernorDB) StoreTransfer

func (d *MockGovernorDB) StoreTransfer(t *Transfer) error

type PendingTransfer

type PendingTransfer struct {
	ReleaseTime time.Time
	Msg         common.MessagePublication
}

func UnmarshalPendingTransfer

func UnmarshalPendingTransfer(data []byte, isOld bool) (*PendingTransfer, error)

func (*PendingTransfer) Marshal

func (p *PendingTransfer) Marshal() ([]byte, error)

type Transfer

type Transfer struct {
	// This value is generated by the Governor. It is not read from the blockchain transaction. It represents the
	// time at which it was observed and evaluated by the Governor.
	Timestamp time.Time
	// Notional USD value of the transfer
	Value uint64
	// Where the asset was minted
	OriginChain   vaa.ChainID
	OriginAddress vaa.Address
	// Where the transfer was emitted. Not necessarily equal to OriginChain
	EmitterChain   vaa.ChainID
	EmitterAddress vaa.Address
	MsgID          string
	Hash           string
	TargetAddress  vaa.Address
	TargetChain    vaa.ChainID
}

func UnmarshalTransfer

func UnmarshalTransfer(data []byte) (*Transfer, error)

func (*Transfer) Marshal

func (t *Transfer) Marshal() ([]byte, error)

type VAAID

type VAAID struct {
	EmitterChain   vaa.ChainID
	EmitterAddress vaa.Address
	Sequence       uint64
}

func VaaIDFromString

func VaaIDFromString(s string) (*VAAID, error)

VaaIDFromString parses a <chain>/<address>/<sequence> string into a VAAID.

func VaaIDFromVAA

func VaaIDFromVAA(v *vaa.VAA) *VAAID

func (*VAAID) Bytes

func (i *VAAID) Bytes() []byte

func (*VAAID) EmitterPrefixBytes

func (i *VAAID) EmitterPrefixBytes() []byte

Jump to

Keyboard shortcuts

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