bcnet

package
v0.0.0-...-817062f Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOK       = TreeStatus("OK")
	StatusDEGRADED = TreeStatus("DEGRADED")
	StatusINVALID  = TreeStatus("INVALID")
)
View Source
const MaxMessageSize = 1 << 22

Variables

This section is empty.

Functions

func Hash

func Hash(x []byte) cadata.ID

func NewBlobSet

func NewBlobSet(c *BlobMainClient, peer PeerID) cadata.Set

func Serve

func Serve(ctx context.Context, asker p2p.AskServer[PeerID], h AskHandler) error

Types

type AskHandler

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

type BlobMainClient

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

func (*BlobMainClient) Add

func (c *BlobMainClient) Add(ctx context.Context, dst PeerID, ids []cadata.ID) ([]bool, error)

func (*BlobMainClient) Delete

func (c *BlobMainClient) Delete(ctx context.Context, dst PeerID, ids []cadata.ID) ([]bool, error)

func (*BlobMainClient) Exists

func (c *BlobMainClient) Exists(ctx context.Context, dst PeerID, ids []cadata.ID) ([]bool, error)

func (*BlobMainClient) List

func (c *BlobMainClient) List(ctx context.Context, dst PeerID, span cadata.Span, ids []cadata.ID) (int, error)

type BlobMainServer

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

func (*BlobMainServer) HandleAsk

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

type BlobPullClient

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

func (BlobPullClient) Pull

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

type BlobPullServer

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

func (*BlobPullServer) HandleAsk

func (s *BlobPullServer) HandleAsk(ctx context.Context, resp []byte, req p2p.Message[PeerID]) int

type BlobReq

type BlobReq struct {
	Add    []cadata.ID  `json:"add,omitempty"`
	Delete []cadata.ID  `json:"delete,omitempty"`
	Exists []cadata.ID  `json:"exists,omitempty"`
	List   *ListBlobReq `json:"list,omitempty"`
}

type BlobRes

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

	Add    []bool       `json:"add,omitempty"`
	Delete []bool       `json:"delete,omitempty"`
	Exists []bool       `json:"exists,omitempty"`
	List   *ListBlobRes `json:"list,omitempty"`
}

type ListBlobReq

type ListBlobReq struct {
	First cadata.ID `json:"first"`
	Limit int       `json:"limit"`
}

type ListBlobRes

type ListBlobRes struct {
	IDs []cadata.ID `json:"ids"`
}

type NodeInfo

type NodeInfo struct {
	TotalCount int64 `json:"quota_count"`
	FreeCount  int64 `json:"free_count"`
}

type Params

type Params struct {
	Swarm       p2p.SecureAskSwarm[PeerID, inet256.PublicKey]
	OpenStore   func(PeerID) cadata.Store
	TreeService TreeService
	Logger      *logrus.Logger
}

type PeerID

type PeerID = inet256.ID

type Service

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

func New

func New(params Params) *Service

func (Service) BlobMain

func (s Service) BlobMain() *BlobMainClient

func (Service) BlobPull

func (s Service) BlobPull() *BlobPullClient

func (Service) Close

func (s Service) Close() error

func (Service) Trees

func (s Service) Trees() *TreeClient

type TreeClient

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

func (*TreeClient) Drop

func (c *TreeClient) Drop(ctx context.Context, dst PeerID, root tries.Root, maxCount int64) (bool, error)

func (*TreeClient) List

func (c *TreeClient) List(ctx context.Context, dst PeerID) ([]TreeInfo, error)

func (*TreeClient) Post

func (c *TreeClient) Post(ctx context.Context, dst PeerID, root tries.Root, maxCount int64) (*TreeInfo, error)

type TreeID

type TreeID int64

type TreeInfo

type TreeInfo struct {
	ID TreeID `json:"id"`

	Root     tries.Root `json:"root"`
	MaxCount int64      `json:"max_count"`

	Status TreeStatus `json:"status"`
	Reason string     `json:"message"`
}

type TreePostReq

type TreePostReq struct {
	Root     tries.Root `json:"root"`
	MaxCount int64      `json:"max_nodes"`
}

type TreeReq

type TreeReq struct {
	Post        *TreePostReq `json:"post,omitempty"`
	Drop        *TreeID      `json:"delete,omitempty"`
	List        *struct{}    `json:"list,omitempty"`
	GetNodeInfo *struct{}    `json:"get_node_info,omitempty"`
}

type TreeResp

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

	Post     *TreeInfo  `json:"post,omitempty"`
	Drop     *bool      `json:"drop,omitempty"`
	List     []TreeInfo `json:"list,omitempty"`
	NodeInfo *NodeInfo  `json:"node_info,omitempty"`
}

type TreeServer

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

func (*TreeServer) HandleAsk

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

type TreeService

type TreeService interface {
	Post(context.Context, PeerID, tries.Root, int64) (*TreeInfo, error)
	Drop(context.Context, PeerID, TreeID) (bool, error)
	List(context.Context, PeerID) ([]TreeInfo, error)
	GetNodeInfo(context.Context, PeerID) (*NodeInfo, error)
}

type TreeStatus

type TreeStatus string

type WireError

type WireError struct {
	Code    codes.Code `json:"code"`
	Message string     `json:"msg"`
}

func (WireError) Error

func (e WireError) Error() string

Jump to

Keyboard shortcuts

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