Documentation ¶
Index ¶
- Constants
- func AnyHasAncestor(ctx context.Context, s cadata.Getter, srcs IDSet[Ref], ancRef cadata.ID) (bool, error)
- func CheckNode[T any](ctx context.Context, s cadata.Getter, node Node[T]) error
- func ForEachDesc[T any](ctx context.Context, s cadata.Getter, ids []Ref, fn func(Ref, Node[T]) error) error
- func ForEachDescGroup[T any](ctx context.Context, s cadata.Getter, ids []Ref, ...) error
- func HasAncestor(ctx context.Context, s cadata.Getter, srcRef Ref, ancRef cadata.ID) (bool, error)
- type ConsultFunc
- type DAG
- func (d *DAG[T]) AddHead(ctx context.Context, h Head) error
- func (d *DAG[T]) CanRead(ctx context.Context, peer PeerID) (bool, error)
- func (d *DAG[T]) ContainsAll(ctx context.Context, refs []Ref) (bool, error)
- func (d *DAG[T]) GetEpoch(ctx context.Context) (*Ref, error)
- func (d *DAG[T]) GetHeadRefs() []Ref
- func (d *DAG[T]) GetHeads() []Head
- func (d *DAG[T]) ListPeers(ctx context.Context) ([]PeerID, error)
- func (d *DAG[T]) Modify(ctx context.Context, privKey PrivateKey, ...) error
- func (d *DAG[T]) Pull(ctx context.Context, src cadata.Getter, h Head) error
- func (d *DAG[T]) SaveBytes() []byte
- func (d *DAG[T]) View() T
- type ErrBadN
- type ErrNotAllowed
- type ErrReplayedN
- type Head
- type IDSet
- type Node
- type Pair
- type PeerID
- type PrivateKey
- type PublicKey
- type Ref
- type Scheme
- type State
Constants ¶
const MaxNodeSize = 1 << 16
Variables ¶
This section is empty.
Functions ¶
func AnyHasAncestor ¶
func AnyHasAncestor(ctx context.Context, s cadata.Getter, srcs IDSet[Ref], ancRef cadata.ID) (bool, error)
AnyHasAncestor determines if any of srcs have an ancestor target. Nodes are considered to be their own ancestor
func CheckNode ¶
CheckNode runs context independent checks on the node. CheckNode: - ensures that all the nodes which are referenced by node exist. - that the node's N is exactly 1 greater than the max of the previous nodes. - is NOT recursive. It is assumed that nodes in s are already valid.
func ForEachDesc ¶
func ForEachDesc[T any](ctx context.Context, s cadata.Getter, ids []Ref, fn func(Ref, Node[T]) error) error
ForEachDesc traverses the DAG in descending order of N, starting with ids. Nodes with the same value of N can be visited in any order.
Types ¶
type ConsultFunc ¶
type DAG ¶
type DAG[T any] struct { // contains filtered or unexported fields }
func New ¶
New creates a new DAG using dagStore to store nodes, and passing innerStore to the underlying scheme as needed.
func (*DAG[T]) ContainsAll ¶
func (*DAG[T]) GetHeadRefs ¶
func (*DAG[T]) Modify ¶
func (d *DAG[T]) Modify(ctx context.Context, privKey PrivateKey, fn func(s cadata.Store, x T) (*T, error)) error
Modify calls fn to modify the DAG's state.
type ErrNotAllowed ¶
type ErrNotAllowed struct {
Peer PeerID
}
func (ErrNotAllowed) Error ¶
func (e ErrNotAllowed) Error() string
type ErrReplayedN ¶
func (ErrReplayedN) Error ¶
func (e ErrReplayedN) Error() string
type Head ¶
Head is a signed reference to a Node in the DAG It represents a single peer's view of the DAG at the time of their last modification.
type IDSet ¶
type IDSet[T ~[32]byte] []T
func (IDSet[T]) MarshalJSON ¶
func (*IDSet[T]) UnmarshalJSON ¶
type Node ¶
type Node[T any] struct { N uint64 `json:"n"` Previous IDSet[Ref] `json:"prevs"` Salt []byte `json:"salt,omitempty"` State T `json:"state"` Sigs gotkv.Root `json:"sigs"` }
Node is a Node/Vertex in the DAG
type PrivateKey ¶
type PrivateKey = inet256.PrivateKey
type Scheme ¶
type Scheme[T any] interface { // Validate checks that the state is valid Validate(ctx context.Context, s cadata.Getter, consult ConsultFunc, x T) error // ValidateStep checks that next is valid, given that prev is known to be valid. ValidateStep(ctx context.Context, s cadata.Getter, consult ConsultFunc, prev, next T) error Merge(ctx context.Context, s cadata.Store, xs []T) (*T, error) // Sync ensures that all of the data reachable by x is in dst, using src // to get missing data. Sync(ctx context.Context, src cadata.Getter, dst cadata.Store, x T) error CanRead(ctx context.Context, s cadata.Getter, x T, id PeerID) (bool, error) ListPeers(ctx context.Context, s cadata.Getter, x T) ([]PeerID, error) }
type State ¶
type State[T any] struct { Max uint64 `json:"max"` // Prev is the set of heads needed to reference the entire graph. Prev []Head `json:"prev"` // Heads is the root of the head for each peer. Heads gotkv.Root `json:"heads"` Epochs []Ref `json:"epochs"` X T `json:"x"` }
State is the current state of the feed.