Documentation
¶
Overview ¶
Package db provides database interface for storing and retrieving blocks and transactions
Index ¶
- Constants
- type Cassandra
- func (c *Cassandra) Connect() error
- func (c *Cassandra) GetBlockInfoByPayload(searchExpression string) ([]Tx, error)
- func (c *Cassandra) GetByBlocknum(blocknum uint64) ([]Tx, error)
- func (c *Cassandra) GetByTxId(txID string) ([]Tx, error)
- func (c *Cassandra) GetLastEntry() (Tx, error)
- func (c *Cassandra) Insert(tx Tx) error
- func (c *Cassandra) QueryAll() ([]Tx, error)
- func (c *Cassandra) QueryBlockByHash(hash string) ([]Tx, error)
- func (c *Cassandra) UpdateMax(id gocql.UUID, blocknum uint64) error
- type DBmongo
- func (db *DBmongo) Connect() error
- func (db *DBmongo) GetBlockInfoByPayload(payload string) ([]Tx, error)
- func (db *DBmongo) GetByBlocknum(blocknum uint64) ([]Tx, error)
- func (db *DBmongo) GetByTxId(txID string) ([]Tx, error)
- func (db *DBmongo) GetLastEntry() (Tx, error)
- func (db *DBmongo) Insert(tx Tx) error
- func (db *DBmongo) QueryAll() ([]Tx, error)
- func (db *DBmongo) QueryBlockByHash(hash string) ([]Tx, error)
- type RW
- type Storage
- type Tx
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 (*Cassandra) GetBlockInfoByPayload ¶
func (*Cassandra) GetLastEntry ¶
func (*Cassandra) QueryBlockByHash ¶
type DBmongo ¶
type DBmongo struct {
Host string
Port int
User string
Password string
DBname string
Collection string
Instance *mongo.Client
}
func CreateDBConfMongo ¶
func (*DBmongo) GetBlockInfoByPayload ¶
func (*DBmongo) GetLastEntry ¶
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
Click to show internal directories.
Click to hide internal directories.