Documentation ¶
Overview ¶
Package db defines the standard go-summercash transaction database.
Package db defines the standard go-summercash transaction database.
Package db defines the standard go-summercash transaction database.
Index ¶
- Variables
- type Dag
- func (dag *Dag) AddLeaf(leaf *Leaf) error
- func (dag *Dag) AddTransaction(transaction *types.Transaction) error
- func (dag *Dag) Flatten() (*Flattened, error)
- func (dag *Dag) MakeGenesis(config *config.ChainConfig) error
- func (dag *Dag) QueryLeafWithHash(hash common.Hash) (*Leaf, error)
- func (dag *Dag) QueryNextCommonLeaf(lastCommonLeaf *Leaf) (*Leaf, error)
- func (dag *Dag) QueryTransactionWithHash(hash common.Hash) (*types.Transaction, error)
- func (dag *Dag) QueryTransactionsWithRecipient(recipient common.Address) ([]*types.Transaction, error)
- func (dag *Dag) QueryTransactionsWithSender(sender common.Address) ([]*types.Transaction, error)
- func (dag *Dag) WriteToMemory(network string) error
- type Flattened
- type Leaf
- func (leaf *Leaf) GetChildByHash(hash common.Hash) (*Leaf, error)
- func (leaf *Leaf) GetChildren() ([]*Leaf, error)
- func (leaf *Leaf) GetChildrenByRecipient(recipient common.Address) ([]*Leaf, error)
- func (leaf *Leaf) GetChildrenBySender(sender common.Address) ([]*Leaf, error)
- func (leaf *Leaf) GetDirectChildByHash(hash common.Hash) (*Leaf, error)
- func (leaf *Leaf) GetDirectChildrenByRecipient(recipient common.Address) ([]*Leaf, error)
- func (leaf *Leaf) GetDirectChildrenBySender(sender common.Address) ([]*Leaf, error)
- func (leaf *Leaf) GetNextCommonLeaf() (*Leaf, error)
- func (leaf *Leaf) GetOnlyChild() (*Leaf, error)
- func (leaf *Leaf) IsOnlyChild() bool
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoCommonLeaf defines an error describing a lack of common leaves. ErrNoCommonLeaf = errors.New("no common leaf exists") // ErrNoParents defines an error describing a lack of parent leaves. ErrNoParents = errors.New("leaf has no parents") // ErrDuplicateLeaf defines an error describing a duplicate dag leaf. ErrDuplicateLeaf = errors.New("leaf already exists in dag") )
var ( // ErrNoOnlyChild represents an error describing a request for an only child where the leaf has multiple or no children. ErrNoOnlyChild = errors.New("leaf has no only child") // ErrNoMatchingLeaf represents an error describing a request for a child with a particular hash--that of which // is nonexistent. ErrNoMatchingLeaf = errors.New("no matching leaf") // ErrNilLeafContents represents an error describing a leaf value of nil. ErrNilLeafContents = errors.New("nil leaf contents") )
var ErrNilDag = errors.New("dag has no root")
ErrNilDag is an error definition representing a root dag leaf of nil value.
Functions ¶
This section is empty.
Types ¶
type Dag ¶
type Dag struct {
Root *Leaf `json:"root"` // Root leaf
}
Dag implements the standard directed acyclic graph global chain.
func ImportBlockmesh ¶
ImportBlockmesh attempts to reconstruct the dag from a given blockmesh.
func NewDagWithRoot ¶
NewDagWithRoot initializes a new dag from a given root.
func ReadDagFromMemory ¶
ReadDagFromMemory attempts to reconstruct a dag from the local persisted dag db.
func UnflattenDag ¶
UnflattenDag attempts to unflatten the given flattened dag.
func (*Dag) AddTransaction ¶
func (dag *Dag) AddTransaction(transaction *types.Transaction) error
AddTransaction adds the given transaction to the working dag.
func (*Dag) Flatten ¶
Flatten flattens the working dag. If the working dag is nil, an error is returned.
func (*Dag) MakeGenesis ¶
func (dag *Dag) MakeGenesis(config *config.ChainConfig) error
MakeGenesis constructs a set of genesis transactions from the given config and adds them to the working dag.
func (*Dag) QueryLeafWithHash ¶
QueryLeafWithHash queries the dag for a leaf with the corresponding hash.
func (*Dag) QueryNextCommonLeaf ¶
QueryNextCommonLeaf attempts to find the next common leaf in the dag. A common leaf is defined as a leaf that has no siblings. If no common leaf exists, an error is returned.
func (*Dag) QueryTransactionWithHash ¶
QueryTransactionWithHash queries the dag for a transaction with the corresponding hash.
func (*Dag) QueryTransactionsWithRecipient ¶
func (dag *Dag) QueryTransactionsWithRecipient(recipient common.Address) ([]*types.Transaction, error)
QueryTransactionsWithRecipient queries the dag for a list of transactions with the corresponding recipient.
func (*Dag) QueryTransactionsWithSender ¶
QueryTransactionsWithSender queries the dag for a list of transactions with the corresponding sender.
func (*Dag) WriteToMemory ¶
WriteToMemory writes the working dag to persistent memory.
type Flattened ¶
type Flattened struct {
Transactions []*types.Transaction `json:"transactions"` // Flattened dag transactions
}
Flattened implements a flattened representation of the standard dag.
type Leaf ¶
type Leaf struct { Transaction *types.Transaction `json:"transaction"` // Transaction at leaf Parents []*Leaf `json:"parents"` // Transaction parents Children []*Leaf `json:"children"` // Leaf children Hash common.Hash `json:"hash"` // Transaction hash at leaf }
Leaf defines a leaf in the go-summercash DAG.
func NewLeaf ¶
func NewLeaf(transaction *types.Transaction, parent *Leaf) (*Leaf, error)
NewLeaf initializes a new leaf with the given transaction.
func (*Leaf) GetChildByHash ¶
GetChildByHash queries the leaf's children for a particular hash. If the hash does not exist, an error is returned.
func (*Leaf) GetChildren ¶
GetChildren gets all children of the given leaf.
func (*Leaf) GetChildrenByRecipient ¶
GetChildrenByRecipient queries the leaf's children for a particular recipient. If a transaction with the corresponding recipient does not exist, an error is returned.
func (*Leaf) GetChildrenBySender ¶
GetChildrenBySender queries the leaf's children for a particular sender. If a transaction with the corresponding sender does not exist, an error is returned.
func (*Leaf) GetDirectChildByHash ¶
GetDirectChildByHash searches the set of immediate children for the given hash. If no child exists with the corresponding hash, an error is returned.
func (*Leaf) GetDirectChildrenByRecipient ¶
GetDirectChildrenByRecipient searches the set of immediate children for the given recipient. If no child exists with the corresponding recipient, an error is returned.
func (*Leaf) GetDirectChildrenBySender ¶
GetDirectChildrenBySender searches the set of immediate children for the given sender. If no child exists with the corresponding sender, an error is returned.
func (*Leaf) GetNextCommonLeaf ¶
GetNextCommonLeaf implements the functionality of the DAG QueryNextCommonLeaf method.
func (*Leaf) GetOnlyChild ¶
GetOnlyChild returns the only child of the current leaf (if applicable).
func (*Leaf) IsOnlyChild ¶
IsOnlyChild determines whether or not the current leaf has any siblings.