db

package
v1.0.0-rc6 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CHANNEL_ID      = "ChannelId"
	TXID            = "Txid"
	HASH            = "Hash"
	PREVIOUS_HASH   = "PreviousHash"
	BLOCKNUM        = "Blocknum"
	PAYLOAD         = "Payload"
	VALIDATION_CODE = "ValidationCode"
	TIME            = "Time"
	PAYLOADKEYS     = "Payloadkeys"
)
View Source
const (
	NOT_FOUND_ERR    = "not found"
	ERR_NO_DOCUMENTS = "mongo: no documents in result"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cassandra

type Cassandra struct {
	Host         string
	User         string
	Password     string
	Keyspace     string
	Columnfamily string
	Session      *gocql.Session
}

func NewCassandraClient

func NewCassandraClient(host, user, password, keyspace, columnfamily string) *Cassandra

func (*Cassandra) Connect

func (c *Cassandra) Connect() error

func (*Cassandra) GetBlockInfoByPayload

func (c *Cassandra) GetBlockInfoByPayload(searchExpression string) ([]Tx, error)

func (*Cassandra) GetByBlocknum

func (c *Cassandra) GetByBlocknum(blocknum uint64) ([]Tx, error)

func (*Cassandra) GetByTxId

func (c *Cassandra) GetByTxId(txID string) ([]Tx, error)

func (*Cassandra) GetLastEntry

func (c *Cassandra) GetLastEntry() (Tx, error)

func (*Cassandra) Insert

func (c *Cassandra) Insert(tx Tx) error

func (*Cassandra) QueryAll

func (c *Cassandra) QueryAll() ([]Tx, error)

func (*Cassandra) QueryBlockByHash

func (c *Cassandra) QueryBlockByHash(hash string) ([]Tx, error)

type DBmongo

type DBmongo struct {
	Host       string
	Port       int
	User       string
	Password   string
	DBname     string
	Collection string
	Instance   *mongo.Client
}

func CreateDBConfMongo

func CreateDBConfMongo(host string, port int, user, password, dbname, collection string) *DBmongo

func (*DBmongo) Connect

func (db *DBmongo) Connect() error

func (*DBmongo) GetBlockInfoByPayload

func (db *DBmongo) GetBlockInfoByPayload(payload string) ([]Tx, error)

func (*DBmongo) GetByBlocknum

func (db *DBmongo) GetByBlocknum(blocknum uint64) ([]Tx, error)

func (*DBmongo) GetByTxId

func (db *DBmongo) GetByTxId(txID string) ([]Tx, error)

func (*DBmongo) GetLastEntry

func (db *DBmongo) GetLastEntry() (Tx, error)

func (*DBmongo) Insert

func (db *DBmongo) Insert(tx Tx) error

func (*DBmongo) QueryAll

func (db *DBmongo) QueryAll() ([]Tx, error)

func (*DBmongo) QueryBlockByHash

func (db *DBmongo) QueryBlockByHash(hash string) ([]Tx, error)

type Entry

type Entry struct {
	ChannelId    string
	Txid         string
	Hash         string
	PreviousHash string
	Blocknum     uint64
	Payload      string
	Time         int64
}

type Manager

type Manager interface {
	Connect() error
	Insert(Tx) error
	QueryBlockByHash(hash string) ([]Tx, error)
	GetByTxId(string) ([]Tx, error)
	GetByBlocknum(uint64) ([]Tx, error)
	GetBlockInfoByPayload(string) ([]Tx, error)
	QueryAll() ([]Tx, error)
	GetLastEntry() (Tx, error)
}

type RW

type RW struct {
	Key   string
	Value string
}

type Tx

type Tx struct {
	ChannelId      string `json:"channelid" bson:"ChannelId"`
	Txid           string `json:"txid" bson:"Txid"`
	Hash           string `json:"hash" bson:"Hash"`
	PreviousHash   string `json:"previoushash" bson:"PreviousHash"`
	Blocknum       uint64 `json:"blocknum" bson:"Blocknum"`
	Payload        string `json:"payload" bson:"Payload"`
	ValidationCode int32  `json:"validationcode" bson:"ValidationCode"`
	Time           int64  `json:"time" bson:"Time"`
}

Jump to

Keyboard shortcuts

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