mongo

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: CC0-1.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCtx

func BuildCtx() (context.Context, context.CancelFunc)

BuildCtx returns a new Mongo context

func Builder

func Builder(cfg *config.MongoDBConfig, codec *codec.Codec) (db.Database, error)

Builder allows to create a new MongoDB connection from the given config and codec

func ConvertBlockToBSONSetDocument

func ConvertBlockToBSONSetDocument(block *tmctypes.ResultBlock, totalGas, preCommits uint64) bson.D

func ConvertPrecommitToBSONSetDocument

func ConvertPrecommitToBSONSetDocument(commitSig tmtypes.CommitSig, votingPower, proposerPriority int64) bson.D

func ConvertTxToBSONSetDocument

func ConvertTxToBSONSetDocument(codec *codec.Codec, tx *types.Tx) (bson.D, error)

ConvertTxToBSONSetDocument converts the given tx into a BSON document that allows it to be saved inside a collection

func ConvertValidatorToBSONSetDocument

func ConvertValidatorToBSONSetDocument(address, publicKey string) bson.D

func Open

func Open(cfg *config.MongoDBConfig, codec *codec.Codec, ctx context.Context) (db.Database, error)

Open allows to open a new MongoDb instance connection using the specified config

Types

type Db

type Db struct {
	Mongo *mongo.Database
	Codec *codec.Codec
}

MongoDb represents a MongoDb instance that relies on a MongoDB instance

func (Db) HasBlock

func (db Db) HasBlock(height int64) (bool, error)

HasBlock implements Database

func (Db) HasValidator

func (db Db) HasValidator(addr string) (bool, error)

HasValidator returns true if a given validator by HEX address exists. An error should never be returned.

func (Db) SaveBlock

func (db Db) SaveBlock(b *tmctypes.ResultBlock, totalGas, preCommits uint64) error

SaveBlock implements Database

func (Db) SaveCommitSig

func (db Db) SaveCommitSig(height int64, commitSig tmtypes.CommitSig, votingPower, proposerPriority int64) error

SetPreCommit stores a validator's pre-commit and returns the resulting record ID. An error is returned if the operation fails.

func (Db) SaveTx

func (db Db) SaveTx(tx *types.Tx) error

SaveTx implements Database

func (Db) SaveValidator

func (db Db) SaveValidator(addr, pk string) error

SetValidator stores a validator if it does not already exist. An error is returned if the operation fails.

Jump to

Keyboard shortcuts

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