mongodb

package
v0.0.0-...-6077ea7 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: ISC Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Coin <~> Database
	VIA  dbName = "viacoin"
	BTC  dbName = "bitcoin"
	LTC  dbName = "litecoin"
	TEST dbName = "explorer-test"

	// Collection names
	TRANSACTIONS = "Transactions"
	BLOCKS       = "Blocks"
	ADDRESSINFO  = "AddressInfo"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoDAO

type MongoDAO struct {
	Server   string
	Database string
}

func (*MongoDAO) AddAddressInfo

func (dao *MongoDAO) AddAddressInfo(AddressInfo *insightjson.AddressInfo) error

add addressInfo to the database

func (*MongoDAO) AddBlock

func (dao *MongoDAO) AddBlock(Block *insightjson.BlockResult) error

func (*MongoDAO) AddTransaction

func (dao *MongoDAO) AddTransaction(transaction *insightjson.Tx) error

add transaction to the database. Make sure the txid is unique.

func (*MongoDAO) Connect

func (dao *MongoDAO) Connect()

func (*MongoDAO) DropDatabase

func (dao *MongoDAO) DropDatabase() error

delete the database. Only use for testing

func (*MongoDAO) GetAddressInfo

func (dao *MongoDAO) GetAddressInfo(address string) (insightjson.AddressInfo, error)

func (*MongoDAO) GetAddressUTXO

func (dao *MongoDAO) GetAddressUTXO(address string) []insightjson.UnpsentOutput

Get the unspent outs of an address by getting the addressInfo of an address and aggregate over all transaction id's from the past get the tx info from the database and check for the vouts example: https://explorer.viacoin.org/api/addr/VmkyKgGBWDpcnFCtw8rvcYqg8xr7U4Ubzx/utxo

func (*MongoDAO) GetBlock

func (dao *MongoDAO) GetBlock(hash *chainhash.Hash) (*insightjson.BlockResult, error)

func (*MongoDAO) GetLastBlock

func (dao *MongoDAO) GetLastBlock() (insightjson.BlockResult, error)

get the latest block and return it in insightjson format

func (*MongoDAO) GetTransaction

func (dao *MongoDAO) GetTransaction(txid string) (insightjson.Tx, error)

Find transactions by txid in the database

func (*MongoDAO) RollbackAddressInfoReceived

func (dao *MongoDAO) RollbackAddressInfoReceived(AddressInfo *insightjson.AddressInfo, receivedSat int64, confirmed bool, txid string) error

Update addressInfo by searching with the address string

func (*MongoDAO) RollbackAddressInfoSent

func (dao *MongoDAO) RollbackAddressInfoSent(AddressInfo *insightjson.AddressInfo, sentSat int64, confirmed bool, txid string) error

Rollback address info sent. This is part of a chain rollback.

func (*MongoDAO) UpdateAddressInfoReceived

func (dao *MongoDAO) UpdateAddressInfoReceived(AddressInfo *insightjson.AddressInfo, receivedSat int64, confirmed bool, txid string) error

Update addressInfo by searching with the address string

func (*MongoDAO) UpdateAddressInfoSent

func (dao *MongoDAO) UpdateAddressInfoSent(AddressInfo *insightjson.AddressInfo, sentSat int64, confirmed bool, txid string) error

func (*MongoDAO) UpdateTransaction

func (dao *MongoDAO) UpdateTransaction(tx *insightjson.Tx) error

Update Transaction by txid

Jump to

Keyboard shortcuts

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