storage

package
v0.0.0-...-4318582 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const AttestTokenPayloadId = 2
View Source
const TokenTransferPayloadId = 1

Variables

This section is empty.

Functions

func GetDB

func GetDB(appCtx context.Context, log *zap.Logger, uri, databaseName string) (*mongo.Database, error)

GetDB connects to DB and returns a client that will disconnect when the passed in context is cancelled

Types

type AttestToken

type AttestToken struct {
	TokenAddress vaa.Address
	TokenChain   vaa.ChainID
	Decimals     uint8
	Symbol       string
	Name         string
}

func DecodeAttestToken

func DecodeAttestToken(data []byte) (*AttestToken, error)

type Fetcher

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

Fetch missing vaa from guardian nodes

func NewFetcher

func NewFetcher(
	config *common.BridgeConfig,
	repository *Repository,
	duration time.Duration,
	logger *zap.Logger,
	batchSize uint32,
	guardianGrpcUrl string,
) (*Fetcher, error)

func (*Fetcher) Start

func (f *Fetcher) Start(ctx context.Context)

type GuardianSetDoc

type GuardianSetDoc struct {
	Addresses []string `bson:"addresses"`
	Index     uint32   `bson:"index"`
}

type IndexingTimestamps

type IndexingTimestamps struct {
	IndexedAt time.Time `bson:"indexedAt"`
}

type MissingVaaUpdate

type MissingVaaUpdate struct {
	ID string `bson:"_id"`
}

type MongoConnections

type MongoConnections struct {
	Current      int32 `bson:"current"`
	Available    int32 `bson:"available"`
	TotalCreated int32 `bson:"totalCreated"`
}

MongoConnections represents a mongo server connection.

type MongoStatus

type MongoStatus struct {
	Ok          int32             `bson:"ok"`
	Host        string            `bson:"host"`
	Version     string            `bson:"version"`
	Process     string            `bson:"process"`
	Pid         int32             `bson:"pid"`
	Uptime      int32             `bson:"uptime"`
	Connections *MongoConnections `bson:"connections"`
}

MongoStatus represent a mongo server status.

type ObservationUpdate

type ObservationUpdate struct {
	MessageID    string      `bson:"messageId"`
	EmitterChain vaa.ChainID `bson:"emitterChain"`
	Emitter      string      `bson:"emitterAddr"`
	TargetChain  vaa.ChainID `bson:"targetChain"`
	Sequence     uint64      `bson:"sequence"`
	Hash         []byte      `bson:"hash"`
	TxId         []byte      `bson:"txId"`
	GuardianAddr string      `bson:"guardianAddr"`
	Signature    []byte      `bson:"signature"`
	UpdatedAt    *time.Time  `bson:"updatedAt"`
}

type Repository

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

TODO separate and maybe share between fly and web

func NewRepository

func NewRepository(
	ctx context.Context,
	db *mongo.Database,
	log *zap.Logger,
	governanceChain vaa.ChainID,
	governanceEmitter vaa.Address,
	statDuration time.Duration,
) *Repository

TODO wrap repository with a service that filters using redis

func (*Repository) FindOldestMissingIds

func (r *Repository) FindOldestMissingIds(ctx context.Context, emitterId *emitterId, size int64) ([]uint64, error)

func (*Repository) GetMongoStatus

func (r *Repository) GetMongoStatus(ctx context.Context) (*MongoStatus, error)

GetMongoStatus get mongo server status

func (*Repository) HasVAA

func (s *Repository) HasVAA(ctx context.Context, emitterId *emitterId, seq uint64) (bool, error)

func (*Repository) RunStat

func (s *Repository) RunStat(ctx context.Context, detailsC <-chan *tokenTransferDetails, duration time.Duration)

func (*Repository) UpsertGuardianSet

func (s *Repository) UpsertGuardianSet(gs *common.GuardianSet) error

func (*Repository) UpsertHeartbeat

func (s *Repository) UpsertHeartbeat(hb *gossipv1.Heartbeat) error

func (*Repository) UpsertObservation

func (s *Repository) UpsertObservation(o *gossipv1.SignedObservation) error

func (*Repository) UpsertVaa

func (s *Repository) UpsertVaa(ctx context.Context, v *vaa.VAA, serializedVaa []byte) error

type StatisticUpdate

type StatisticUpdate struct {
	ID                  string      `bson:"_id"`
	Date                *time.Time  `bson:"date"`
	EmitterChain        vaa.ChainID `bson:"emitterChain"`
	EmitterAddr         string      `bson:"emitterAddr"`
	TargetChain         vaa.ChainID `bson:"targetChain"`
	TokenChain          vaa.ChainID `bson:"tokenChain"`
	TokenAddress        string      `bson:"tokenAddress"`
	TotalVAACount       uint32      `bson:"totalVAACount"`
	TotalTransferAmount string      `bson:"totalTransferAmount"`
	TotalNotionalUSD    float64     `bson:"totalNotionalUSD"`
	UpdatedAt           *time.Time  `bson:"updatedAt"`
}

type TokenTransfer

type TokenTransfer struct {
	Amount        big.Int
	TokenAddress  vaa.Address
	TokenChain    vaa.ChainID
	TargetAddress []byte
}

func DecodeTokenTransfer

func DecodeTokenTransfer(data []byte) (*TokenTransfer, error)

type TokenTransferUpdate

type TokenTransferUpdate struct {
	ID           string      `bson:"_id"`
	EmitterChain vaa.ChainID `bson:"emitterChain"`
	EmitterAddr  string      `bson:"emitterAddr"`
	TargetChain  vaa.ChainID `bson:"targetChain"`
	TokenAddress string      `bson:"tokenAddress"`
	Symbol       string      `bson:"symbol"`
	TokenChain   vaa.ChainID `bson:"tokenChain"`
	ToAddress    string      `bson:"toAddress"`
	Amount       string      `bson:"amount"`
	NotionalUSD  float64     `bson:"notionalUSD"`
	PriceUSD     string      `bson:"priceUSD"`
	Timestamp    *time.Time  `bson:"timestamp"`
}

type TokenUpdate

type TokenUpdate struct {
	ID              string      `bson:"_id"`
	TokenAddress    string      `bson:"tokenAddress"`
	TokenChain      vaa.ChainID `bson:"tokenChain"`
	Decimals        uint8       `bson:"decimals"`
	Symbol          string      `bson:"symbol"`
	Name            string      `bson:"name"`
	NativeAddress   string      `bson:"nativeAddress"`
	CoinGeckoCoinId string      `bson:"coinGeckoCoinId"`
	UpdatedAt       *time.Time  `bson:"updatedAt"`
}

type Uint64

type Uint64 uint64

func (Uint64) MarshalBSONValue

func (u Uint64) MarshalBSONValue() (bsontype.Type, []byte, error)

func (*Uint64) UnmarshalBSONValue

func (u *Uint64) UnmarshalBSONValue(t bsontype.Type, b []byte) error

type VaaUpdate

type VaaUpdate struct {
	ID               string      `bson:"_id"`
	Version          uint8       `bson:"version"`
	EmitterChain     vaa.ChainID `bson:"emitterChain"`
	EmitterAddr      string      `bson:"emitterAddr"`
	TargetChain      vaa.ChainID `bson:"targetChain"`
	Sequence         uint64      `bson:"sequence"`
	GuardianSetIndex uint32      `bson:"guardianSetIndex"`
	TxId             []byte      `bson:"txId,omitempty"`
	Vaa              []byte      `bson:"vaas"`
	Timestamp        *time.Time  `bson:"timestamp"`
	UpdatedAt        *time.Time  `bson:"updatedAt"`
}

Jump to

Keyboard shortcuts

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