owlnet

package
v0.0.0-...-1704659 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenHandle

func OpenHandle(secret *[32]byte, peerID PeerID, x Handle) (data [16]byte, _ error)

OpenHandle returns the data from the handle or an error if the handle is invalid

func ServeAsks

func ServeAsks(ctx context.Context, asker p2p.AskServer[inet256.ID], h AskHandler) error

Types

type AskHandler

type AskHandler interface {
	HandleAsk(ctx context.Context, resp []byte, req p2p.Message[inet256.ID]) int
}

type BlobPullClient

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

func (BlobPullClient) Pull

func (c BlobPullClient) Pull(ctx context.Context, dst PeerID, h Handle, id cadata.ID, buf []byte) (int, error)

type BlobPullReq

type BlobPullReq struct {
	Store Handle    `json:"store"`
	ID    cadata.ID `json:"id"`
}

type BlobPullServer

type BlobPullServer struct {
	Open func(peerID PeerID, volID uint32, sid uint8) cadata.Getter
	// contains filtered or unexported fields
}

func (*BlobPullServer) HandleAsk

func (s *BlobPullServer) HandleAsk(ctx context.Context, resp []byte, msg p2p.Message[inet256.ID]) int

type DAGClient

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

func (*DAGClient) Get

func (dc *DAGClient) Get(ctx context.Context, dst PeerID, scheme string, refs []owldag.Ref) (*DAGInfo, error)

func (*DAGClient) GetHeads

func (dc *DAGClient) GetHeads(ctx context.Context, dst PeerID, h Handle) ([]owldag.Head, error)

func (*DAGClient) List

func (dc *DAGClient) List(ctx context.Context, dst PeerID, scheme string, refs []owldag.Ref) ([]DAGInfo, error)

func (*DAGClient) PushHeads

func (dc *DAGClient) PushHeads(ctx context.Context, dst PeerID, srcDAG uint32, h Handle, heads []owldag.Head) error

type DAGInfo

type DAGInfo struct {
	Scheme string       `json:"scheme"`
	Epochs []owldag.Ref `json:"epochs"`
	Handle Handle       `json:"handle"`
	Stores []Handle     `json:"stores"`
}

type DAGReq

type DAGReq struct {
	GetHeads  *GetHeadsReq  `json:"get_heads,omitempty"`
	PushHeads *PushHeadsReq `json:"push_heads,omitempty"`
	GetList   *GetListReq   `json:"list,omitempty"`
}

type DAGRes

type DAGRes struct {
	Error *WireError `json:"error,omitempty"`

	GetHeads  []owldag.Head `json:"get_heads,omitempty"`
	PushHeads *struct{}     `json:"push_heads,omitempty"`
	GetList   []DAGInfo     `json:"get_list,omitempty"`
}

type DAGServer

type DAGServer struct {
	OnPushHeads func(from PeerID, volID int, srcDAG Handle, heads []owldag.Head) error
	OnGetHeads  func(from PeerID, volID int) ([]owldag.Head, error)
	OnList      func(from PeerID, schemeIs string, mustContain []owldag.Ref) ([]LocalDAGInfo, error)
	// contains filtered or unexported fields
}

func (DAGServer) HandleAsk

func (s DAGServer) HandleAsk(ctx context.Context, resp []byte, msg p2p.Message[PeerID]) int

type GetHeadsReq

type GetHeadsReq struct {
	DAG Handle `json:"dag"`
}

type GetListReq

type GetListReq struct {
	// Scheme, if set, restricts the results returned to those which match the scheme
	Scheme string `json:"scheme"`
	// Contains when len(_) > 0 restricts the results to those which contain all the Refs.
	Contains []owldag.Ref `json:"contains"`
}

type Handle

type Handle [32]byte

Handle is a reference to a resource on a node

func NewHandle

func NewHandle(secret *[32]byte, peerID PeerID, data *[16]byte) (out Handle)

NewHandle creates a new handle for peerID containing x

func (Handle) MarhsalJSON

func (h Handle) MarhsalJSON() ([]byte, error)

func (*Handle) UnmarhsalJSON

func (h *Handle) UnmarhsalJSON(data []byte) error

type LocalDAGInfo

type LocalDAGInfo struct {
	ID     int
	Scheme string
	Epochs []owldag.Ref
}

type Node

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

func New

func New(swarm Swarm) *Node

func (*Node) BlobPullClient

func (n *Node) BlobPullClient() BlobPullClient

func (*Node) BlobPullServer

func (n *Node) BlobPullServer(ctx context.Context, srv *BlobPullServer) error

func (*Node) Close

func (n *Node) Close() error

func (*Node) DAGClient

func (n *Node) DAGClient() *DAGClient

func (*Node) DAGServer

func (n *Node) DAGServer(ctx context.Context, srv *DAGServer) error

type PeerID

type PeerID = owldag.PeerID

type PushHeadsReq

type PushHeadsReq struct {
	SrcDAG Handle        `json:"src_dag"`
	DstDAG Handle        `json:"dst_dag"`
	Heads  []owldag.Head `json:"heads"`
	Blobs  []byte        `json:"blobs"`
}

type Store

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

func NewStore

func NewStore(c BlobPullClient, addr PeerID, h Handle) *Store

func (*Store) Get

func (s *Store) Get(ctx context.Context, id cadata.ID, buf []byte) (int, error)

func (*Store) Hash

func (s *Store) Hash(x []byte) cadata.ID

func (*Store) MaxSize

func (s *Store) MaxSize() int

type Swarm

type Swarm = p2p.SecureAskSwarm[PeerID, inet256.PublicKey]

type WireError

type WireError struct {
	Code codes.Code
	Msg  string
}

func NewError

func NewError(c codes.Code, msg string) *WireError

func (WireError) Error

func (we WireError) Error() string

Jump to

Keyboard shortcuts

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