dgraph

package
v0.0.0-...-bcfd2cf Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Coinbase

func Coinbase(in *tx.Input) bool

Coinbase returns whether an input is refers to coinbase output

Types

type Address

type Address struct {
	UID     string `json:"uid,omitempty"`
	Address string `json:"address"`
}

Address node

type BlockResp

type BlockResp struct {
	Blk []struct{ block.Block }
}

BlockResp represent the resp from a dgraph query returning a transaction node

type Cluster

type Cluster struct {
	UID       string    `json:"uid,omitempty"`
	Addresses []Address `json:"addresses,omitempty"`
	Cluster   uint32    `json:"cluster,omitempty"`
}

Cluster set of addresses related to the same entity

type Clusters

type Clusters struct {
	UID     string    `json:"uid,omitempty"`
	Size    uint32    `json:"size,omitempty"`
	Height  int32     `json:"height,omitempty"`
	Parents []Parent  `json:"parents,omitempty"`
	Ranks   []Rank    `json:"ranks,omitempty"`
	Set     []Cluster `json:"set,omitempty"`
}

Clusters represents the set of clusters

type ClustersResp

type ClustersResp struct {
	C []struct{ Clusters }
}

ClustersResp basic structure to unmarshall cluster query

type Config

type Config struct {
	Host string
	Port int
}

Config strcut containing initialization fields

func Conf

func Conf() *Config

Conf exports the Config object to initialize indexing dgraph

type Dgraph

type Dgraph struct {
	*dgo.Dgraph
	// contains filtered or unexported fields
}

Dgraph wrapper of dgraph client

func Instance

func Instance(conf *Config, c *cache.Cache) *Dgraph

Instance implements the singleton pattern to return the DGraph instance

func (*Dgraph) AddParent

func (d *Dgraph) AddParent(pos, parent uint32) error

AddParent appends a rank to the cluster

func (*Dgraph) AddRank

func (d *Dgraph) AddRank(pos, rank uint32) error

AddRank appends a rank to the cluster

func (*Dgraph) BulkMakeSet

func (d *Dgraph) BulkMakeSet(address string, size, parentPos, rankPos uint32) error

BulkMakeSet take together single update operations and update clusters with a single request

func (*Dgraph) Delete

func (d *Dgraph) Delete(UID string) (err error)

Delete removes the node corresponding to the passed uid

func (*Dgraph) Empty

func (d *Dgraph) Empty() (err error)

Empty removes all data from dgraph with a drop all command

func (*Dgraph) GetBlockFromHash

func (d *Dgraph) GetBlockFromHash(hash string) (blk block.Block, err error)

GetBlockFromHash returns the hash of the block retrieving it based on its height

func (*Dgraph) GetBlockFromHeight

func (d *Dgraph) GetBlockFromHeight(height int32) (blk block.Block, err error)

GetBlockFromHeight returns the hash of the block retrieving it based on its height

func (*Dgraph) GetBlockFromHeightRange

func (d *Dgraph) GetBlockFromHeightRange(height int32, first int) (blks []block.Block, err error)

GetBlockFromHeightRange returns the hash of the block retrieving it based on its height

func (*Dgraph) GetBlockTxOutputsFromHash

func (d *Dgraph) GetBlockTxOutputsFromHash(hash string) (uids map[string][]string, err error)

GetBlockTxOutputsFromHash retrieves the list of outputs uid of all block's transactions

func (*Dgraph) GetBlockTxOutputsFromRange

func (d *Dgraph) GetBlockTxOutputsFromRange(height int32, first int) (uids map[string]map[string][]string, err error)

GetBlockTxOutputsFromRange retrieves the list of outputs uid of all block's transactions in the block range

func (*Dgraph) GetClusterHeight

func (d *Dgraph) GetClusterHeight() (int32, error)

GetClusterHeight returns the UID of the cluster

func (*Dgraph) GetClusterUID

func (d *Dgraph) GetClusterUID() (string, error)

GetClusterUID returns the UID of the cluster

func (*Dgraph) GetClusters

func (d *Dgraph) GetClusters() (Clusters, error)

GetClusters returns the set of all clusters stored in dgraph

func (*Dgraph) GetFirstOccurenceHeight

func (d *Dgraph) GetFirstOccurenceHeight(address string) (height int32, err error)

GetFirstOccurenceHeight returns the height of the block in which the address appeared for the first time

func (*Dgraph) GetFollowingTx

func (d *Dgraph) GetFollowingTx(hash string, vout uint32) (transaction tx.Tx, err error)

GetFollowingTx returns the transaction spending the output (vout) of the transaction passed as input to the function TODO: rememeber orderasc fetches no more than 1000 elements

func (*Dgraph) GetLastBlockHeight

func (d *Dgraph) GetLastBlockHeight() (height int32, err error)

GetLastBlockHeight returns the height of the last block synced by Bitgodine

func (*Dgraph) GetOccurences

func (d *Dgraph) GetOccurences(address string) (occurences []string, err error)

GetOccurences returns an array containing the transactions where the address appears in the blockchain

func (*Dgraph) GetParent

func (d *Dgraph) GetParent(pos uint32) (Parent, error)

GetParent returns the parent struct at the required position

func (*Dgraph) GetRank

func (d *Dgraph) GetRank(pos uint32) (Rank, error)

GetRank returns the parent struct at the required position

func (*Dgraph) GetSetUID

func (d *Dgraph) GetSetUID(set uint32) (string, error)

GetSetUID returns the UID of the specified set of addresses

func (*Dgraph) GetSpentTxOutput

func (d *Dgraph) GetSpentTxOutput(hash string, vout uint32) (output tx.Output, err error)

GetSpentTxOutput returns the output spent (the vout) of the corresponding tx

func (*Dgraph) GetStoredBlocks

func (d *Dgraph) GetStoredBlocks() (blks []block.Block, err error)

GetStoredBlocks returns an array containing all blocks stored on dgraph

func (*Dgraph) GetStoredTxs

func (d *Dgraph) GetStoredTxs() (transactions []string, err error)

GetStoredTxs returns all the stored transactions hashes

func (*Dgraph) GetTx

func (d *Dgraph) GetTx(hash string) (transaction tx.Tx, err error)

GetTx returns the node from the query queried TODO: orderasc on inputs, outputs, check whether they can have more than 1000 elments (1000 dgraph limit fetch)

func (*Dgraph) GetTxBlock

func (d *Dgraph) GetTxBlock(hash string) (blk block.Block, err error)

GetTxBlock returns the block containing the transaction

func (*Dgraph) GetTxBlockHeight

func (d *Dgraph) GetTxBlockHeight(hash string) (height int32, err error)

GetTxBlockHeight returns the height of the block based on its hash

func (*Dgraph) GetTxOutputs

func (d *Dgraph) GetTxOutputs(hash string) (outputs []tx.Output, err error)

GetTxOutputs returns the outputs of the queried tx by hash TODO: rememeber orderasc fetches no more than 1000 elements

func (*Dgraph) GetTxUID

func (d *Dgraph) GetTxUID(hash string) (uid string, err error)

GetTxUID returns the uid of the queried tx by hash

func (*Dgraph) GetUtxoSet

func (d *Dgraph) GetUtxoSet() (UtxoSet, error)

GetUtxoSet returns the set of all utxos stored in dgraph

func (*Dgraph) GetUtxoSetByHash

func (d *Dgraph) GetUtxoSetByHash(hash string) (Utxo, error)

GetUtxoSetByHash returns the UID of the specified set of addresses

func (*Dgraph) GetUtxoSetUID

func (d *Dgraph) GetUtxoSetUID() (string, error)

GetUtxoSetUID returns the UID of the cluster

func (*Dgraph) IsSpent

func (d *Dgraph) IsSpent(tx string, index uint32) bool

IsSpent returns true if exists a transaction that takes as input to the new tx the output corresponding to the index passed to the function

func (*Dgraph) LastBlock

func (d *Dgraph) LastBlock() (blk block.Block, err error)

LastBlock returns the last block synced by Bitgodine

func (*Dgraph) NewClusters

func (d *Dgraph) NewClusters() error

NewClusters stores the basic struct to manage the cluster sets

func (*Dgraph) NewSet

func (d *Dgraph) NewSet(address string, cluster uint32) error

NewSet creates a new set in the cluster. A set is composed by at least an addres, that is why address is passed as argument

func (*Dgraph) NewUtxo

func (d *Dgraph) NewUtxo(txid string, outputs []tx.Output) error

NewUtxo add a new group of unspent output associated with the tx hash

func (*Dgraph) NewUtxoSet

func (d *Dgraph) NewUtxoSet() error

NewUtxoSet stores the basic struct to manage the utxo sets

func (*Dgraph) RemoveLastBlock

func (d *Dgraph) RemoveLastBlock() (err error)

RemoveLastBlock deletes the last block stored in the db

func (*Dgraph) RemoveStxo

func (d *Dgraph) RemoveStxo(txid string, index uint32) error

RemoveStxo remove a spent transaction output from the utxos set

func (*Dgraph) Setup

func (d *Dgraph) Setup() error

Setup initializes the schema in dgraph

func (*Dgraph) Store

func (d *Dgraph) Store(v interface{}) (err error)

Store encodes received object as json object and stores it in dgraph

func (*Dgraph) StoreBatch

func (d *Dgraph) StoreBatch(v interface{}) (err error)

StoreBatch loads a queue untill a threshold to perform a bulk insertion on dgraph

func (*Dgraph) StoreBlock

func (d *Dgraph) StoreBlock(v interface{}) (err error)

StoreBlock returns the hash of the block retrieving it based on its height

func (*Dgraph) StoreCoinbase

func (d *Dgraph) StoreCoinbase() error

StoreCoinbase prepare coinbase output to be used as input for coinbase transactions

func (*Dgraph) UpdateClusterHeight

func (d *Dgraph) UpdateClusterHeight(height int32) error

UpdateClusterHeight updates the size of the cluster

func (*Dgraph) UpdateParent

func (d *Dgraph) UpdateParent(pos, parent uint32) error

UpdateParent updates the parent tag in parent node based on passed position

func (*Dgraph) UpdateRank

func (d *Dgraph) UpdateRank(pos, rank uint32) error

UpdateRank updates the parent tag in parent node based on passed position

func (*Dgraph) UpdateSet

func (d *Dgraph) UpdateSet(address string, cluster uint32) error

UpdateSet adds an address to a cluster

func (*Dgraph) UpdateSize

func (d *Dgraph) UpdateSize(size uint32) error

UpdateSize updates the size of the cluster

type OutputsResp

type OutputsResp struct {
	Transactions []struct {
		Output []struct{ tx.Output }
	}
}

OutputsResp represent the resp from a dgraph query returning an array of output nodes

type Parent

type Parent struct {
	UID    string `json:"uid,omitempty"`
	Pos    uint32 `json:"pos"`
	Parent uint32 `json:"parent"`
}

Parent persist the parent tag and its position

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue data structure used as broker to load insertion queue

type Rank

type Rank struct {
	UID  string `json:"uid,omitempty"`
	Pos  uint32 `json:"pos"`
	Rank uint32 `json:"rank"`
}

Rank persist rank and its position

type TxResp

type TxResp struct {
	Txs []struct{ tx.Tx }
}

TxResp represent the resp from a dgraph query returning a transaction node

type Utxo

type Utxo struct {
	UID  string      `json:"uid,omitempty"`
	TxID string      `json:"txid,omitempty"`
	Utxo []tx.Output `json:"utxo"` // TODO: this could just be a refernce, e.g. the UID of the parsed output node
}

Utxo tracks utxos

type UtxoResp

type UtxoResp struct {
	U []struct{ UtxoSet }
}

UtxoResp basic structure to unmarshall utxo query

type UtxoSet

type UtxoSet struct {
	UID     string `json:"uid,omitempty"`
	UtxoSet []Utxo `json:"utxoset,omitempty"`
}

UtxoSet tracks utxos

Jump to

Keyboard shortcuts

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