db

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package db provides database interface for storing and retrieving blocks and transactions

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"
	UPDATE_MAX      = `UPDATE MAX SET id = ?, blocknum = ? where fortable = ?;`
)
View Source
const ERR_NO_DOCUMENTS = "mongo: no documents in result"
View Source
const NOT_FOUND_ERR = "not found"

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)

func (*Cassandra) UpdateMax

func (c *Cassandra) UpdateMax(id gocql.UUID, blocknum uint64) 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 RW

type RW struct {
	Key   string
	Value string
}

RW stores key and value of chaincode payload

type Storage

type Storage interface {
	Connect() error
	Insert(tx Tx) error
	QueryBlockByHash(hash string) ([]Tx, error)
	GetByTxId(txid string) ([]Tx, error)
	GetByBlocknum(blocknum uint64) ([]Tx, error)
	GetBlockInfoByPayload(payload string) ([]Tx, error)
	QueryAll() ([]Tx, error)
	GetLastEntry() (Tx, error)
}

Storage db interface

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"`
}

Tx stores info about block and tx payload

Jump to

Keyboard shortcuts

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