node

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: BSD-3-Clause Imports: 87 Imported by: 1

Documentation

Index

Constants

View Source
const DhtPrefix = "/pop"

DhtPrefix sets a Pop prefix to be attached to the DHT protocols. For example: /pop/kad/1.0.0 instead of /ipfs/kad/1.0.0

View Source
const KContentBatch = "content-batch"

KContentBatch is the keystore used for storing the root CID of the HAMT used to aggregate content for storage

View Source
const MaxMessageSize = 10 << 20

MaxMessageSize is the maximum message size, in bytes.

View Source
const (
	ReleaseURL = "https://api.github.com/repos/myelnet/pop/releases"
)

Variables

View Source
var (
	// ErrFilecoinRPCOffline is returned when the node is running without a provided filecoin api endpoint + token
	ErrFilecoinRPCOffline = errors.New("filecoin RPC is offline")

	// ErrAllDealsFailed is returned when all storage deals failed to get started
	ErrAllDealsFailed = errors.New("all deals failed")

	// ErrNoTx is returned when no transaction is staged and we attempt to commit
	ErrNoTx = errors.New("no tx to commit")

	// ErrNodeNotFound is returned when we cannot find the node in the given root
	ErrNodeNotFound = errors.New("node not found")

	// ErrQuoteNotFound is returned when we are trying to store but couldn't get a quote
	ErrQuoteNotFound = errors.New("quote not found")

	// ErrInvalidPeer is returned when trying to ping a peer with invalid peer ID or address
	ErrInvalidPeer = errors.New("invalid peer ID or address")

	// ErrCacheRFInvalid is returned if the cache RF is inconsistant with the specified peers
	ErrCacheRFInvalid = errors.New("Cache replication factor is smaller than specified peers")
)
View Source
var (
	// DefaultChunkSize is the default size a chunk
	DefaultChunkSize int64 = 128_000

	// DefaultChunker is the default chunker of the DAG builder
	DefaultChunker = func(buf io.ReadSeeker) chunk.Splitter {
		return chunk.NewSizeSplitter(buf, DefaultChunkSize)
	}

	// DefaultLayout is the default layout of the DAG builder
	DefaultLayout = balanced.Layout
)
View Source
var JsonEscapedZero = []byte(`\u0000`)

Functions

func DownloadFile

func DownloadFile(filepath string, url string) error

func ReadMsg

func ReadMsg(r io.Reader) ([]byte, error)

func ReleaseCompleted

func ReleaseCompleted(steps []Step) bool

contains checks if a string is present in a slice

func RestartByExec

func RestartByExec()

RestartByExec calls `syscall.Exec()` to restart app

func Run

func Run(ctx context.Context, opts Options) error

Run runs a pop IPFS node

func VerifySignature

func VerifySignature(payload string, requestSignature string, secret string) bool

func WithLayout

func WithLayout(layout func(*helpers.DagBuilderHelper) (ipldformat.Node, error)) func(n *DAGParams)

WithLayout overrides the default dag layout with a layout function defining the overall layout of a DAG

func WriteMsg

func WriteMsg(w io.Writer, b []byte) error

Types

type Asset

type Asset struct {
	URL string `json:"browser_download_url"`
}

type CommArgs

type CommArgs struct {
	CacheRF    int // CacheRF is the cache replication factor or number of cache provider will request
	Attempts   int
	BackoffMin time.Duration
	Peers      []string
}

CommArgs are passed to the Commit command

type CommResult

type CommResult struct {
	Ref    string
	Caches []string
	Size   int64
	Err    string
}

CommResult is feedback on the push operation

type Command

type Command struct {
	Off          *OffArgs
	Ping         *PingArgs
	Put          *PutArgs
	Status       *StatusArgs
	WalletList   *WalletListArgs
	WalletExport *WalletExportArgs
	WalletPay    *WalletPayArgs
	Commit       *CommArgs
	Get          *GetArgs
	List         *ListArgs
	Import       *ImportArgs
	PaySubmit    *PayArgs
	PayList      *PayArgs
	PayTrack     *PayArgs
	PaySettle    *PayArgs
	PayCollect   *PayArgs
}

Command is a message sent from a client to the daemon

type CommandClient

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

CommandClient sends commands to a daemon process

func NewCommandClient

func NewCommandClient(sendCommandMsg func(jsonb []byte)) *CommandClient

func (*CommandClient) Commit

func (cc *CommandClient) Commit(args *CommArgs)

func (*CommandClient) Get

func (cc *CommandClient) Get(args *GetArgs)

func (*CommandClient) GotNotifyMsg

func (cc *CommandClient) GotNotifyMsg(b []byte)

func (*CommandClient) Import

func (cc *CommandClient) Import(args *ImportArgs)

func (*CommandClient) List

func (cc *CommandClient) List(args *ListArgs)

func (*CommandClient) Off

func (cc *CommandClient) Off()

func (*CommandClient) PayCollect

func (cc *CommandClient) PayCollect(args *PayArgs)

func (*CommandClient) PayList

func (cc *CommandClient) PayList(args *PayArgs)

func (*CommandClient) PaySettle

func (cc *CommandClient) PaySettle(args *PayArgs)

func (*CommandClient) PaySubmit

func (cc *CommandClient) PaySubmit(args *PayArgs)

func (*CommandClient) PayTrack

func (cc *CommandClient) PayTrack(args *PayArgs)

func (*CommandClient) Ping

func (cc *CommandClient) Ping(addr string)

func (*CommandClient) Put

func (cc *CommandClient) Put(args *PutArgs)

func (*CommandClient) SetNotifyCallback

func (cc *CommandClient) SetNotifyCallback(fn func(Notify))

func (*CommandClient) Status

func (cc *CommandClient) Status(args *StatusArgs)

func (*CommandClient) WalletExport

func (cc *CommandClient) WalletExport(args *WalletExportArgs)

func (*CommandClient) WalletListKeys

func (cc *CommandClient) WalletListKeys(args *WalletListArgs)

func (*CommandClient) WalletPay

func (cc *CommandClient) WalletPay(args *WalletPayArgs)

type CommandServer

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

CommandServer receives commands on the daemon side and executes them

func NewCommandServer

func NewCommandServer(node *Pop, sendNotifyMsg func(b []byte)) *CommandServer

func (*CommandServer) GotMsg

func (cs *CommandServer) GotMsg(ctx context.Context, cmd *Command) error

func (*CommandServer) GotMsgBytes

func (cs *CommandServer) GotMsgBytes(ctx context.Context, b []byte) error

type DAGOption

type DAGOption func(*DAGParams)

DAGOption is a functional option overriding default DAG params

func WithChunker

func WithChunker(chunker chunk.Splitter) DAGOption

WithChunker overrides the default chunker with a given chunker interface

type DAGParams

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

DAGParams is a set of features used to chunk and format files into DAGs

func NewDAGParams

func NewDAGParams(buf io.ReadSeeker) *DAGParams

NewDAGParams initializes default params for generating a DAG

type DealInfoArgs

type DealInfoArgs struct {
	CID cid.Cid
}

DealInfoArgs gives some params to find the deal

type DealInfoResult

type DealInfoResult struct {
	Funds abi.TokenAmount
	PayCh address.Address
}

DealInfoResult describes any ongoing deal

type GetArgs

type GetArgs struct {
	Cid          string `json:"cid"`
	Key          string `json:"key,omitempty"`
	Sel          string `json:"sel,omitempty"`
	Out          string `json:"out,omitempty"`
	Timeout      int    `json:"timeout,omitempty"`
	Verbose      bool   `json:"verbose,omitempty"`
	Miner        string `json:"miner,omitempty"`
	Peer         string `json:"peer,omitempty"`
	Strategy     string `json:"strategy,omitempty"`
	MaxPPB       int64  `json:"maxPPB,omitempty"`
	ProviderAddr string `json:"providerAddr,omitempty"`
	Size         int64  `json:"size,omitempty"`
}

GetArgs get passed to the Get command

type GetResult

type GetResult struct {
	Status          string  `json:"status,omitempty"`
	DealID          string  `json:"dealID,omitempty"`
	Size            int64   `json:"size,omitempty"`
	TotalSpent      string  `json:"totalSpent,omitempty"`
	TotalReceived   int64   `json:"totalReceived,omitempty"`
	BytesPaidFor    string  `json:"bytesPaidFor,omitempty"`
	TotalFunds      string  `json:"totalFunds,omitempty"`
	PricePerByte    string  `json:"pricePerByte,omitempty"`
	UnsealPrice     string  `json:"unsealPrice,omitempty"`
	DiscLatSeconds  float64 `json:"discLatSeconds,omitempty"`
	TransLatSeconds float64 `json:"tansLatSeconds,omitempty"`
	Local           bool    `json:"local,omitempty"`
	Err             string  `json:"error,omitempty"`
}

GetResult gives us feedback on the result of the Get request

type ImportArgs

type ImportArgs struct {
	Path       string
	CacheRF    int
	Attempts   int
	BackoffMin time.Duration
	Peers      []string
}

ImportArgs provides the path to the car file

type ImportResult

type ImportResult struct {
	Roots  []string
	Caches []string
	Err    string
}

ImportResult returns the resulting index entries from the CAR file

type ListArgs

type ListArgs struct {
	Page int // potential pagination as the amount may be very large
}

ListArgs provides params for the List command

type ListResult

type ListResult struct {
	Root string
	Freq int64
	Size int64
	Last bool
	Err  string
}

ListResult contains the result for a single item of the list

type Notify

type Notify struct {
	OffResult    *OffResult
	PingResult   *PingResult
	PutResult    *PutResult
	StatusResult *StatusResult
	WalletResult *WalletResult
	CommResult   *CommResult
	GetResult    *GetResult
	ListResult   *ListResult
	ImportResult *ImportResult
	PayResult    *PayResult
}

Notify is a message sent from the daemon to the client

type OffArgs

type OffArgs struct{}

OffArgs get passed to the Off command

type OffResult

type OffResult struct{}

OffResult doesn't return any value at this time

type Options

type Options struct {
	// RepoPath is the file system path to use to persist our datastore
	RepoPath string
	// SocketPath is the unix socket path to listen on
	SocketPath string
	// Addresses allows setting custom listening addresses for the node
	Addresses []string
	// BootstrapPeers is a peer address to connect to for discovering other peers
	BootstrapPeers []string
	// FilEndpoint is the websocket url for accessing a remote filecoin api
	FilEndpoint string
	// FilToken is the authorization token to access the filecoin api
	FilToken string
	// PrivKey is a hex encoded private key to use for default address
	PrivKey string
	// MaxPPB is the maximum price per byte when fetching data
	MaxPPB int64
	// PBB is the price per byte when serving data
	PPB int64
	// Regions is a list of regions a provider chooses to support.
	// Nothing prevents providers from participating in regions outside of their geographic location however they may get less deals since the latency is likely to be higher
	Regions []string
	// Capacity is the maximum storage capacity dedicated to the exchange
	Capacity uint64
	// ReplInterval defines how often the node attempts to find new content from connected peers
	ReplInterval time.Duration
	// Domains is a list of DNS names we can establish TLS handshakes with
	Domains []string
	// Certmagic flag activates certificate generation
	Certmagic bool
	// RemoteIndexURL is a url to send index records to
	RemoteIndexURL string
	// UpgradeSecret is used to verify automatic updates from a github webhook
	UpgradeSecret string
	// CancelFunc is used for gracefully shutting down the node
	CancelFunc context.CancelFunc
}

Options determines configurations for the IPFS node

type PayArgs

type PayArgs struct {
	ChAddr string
	Lane   uint64
}

PayArgs provides params for controlling a payment channel

type PayResult

type PayResult struct {
	SettlingIn  string
	ChannelList string
	Err         string
}

PayResult returns the result of submitted vouchers

type PeeringService

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

PeeringService maintains connections to specified peers, reconnecting on disconnect with a back-off.

func NewPeeringService

func NewPeeringService(host host.Host) *PeeringService

NewPeeringService constructs a new peering service. Peers can be added and removed immediately, but connections won't be formed until `Start` is called.

func (*PeeringService) AddPeer

func (ps *PeeringService) AddPeer(info peer.AddrInfo)

AddPeer adds a peer to the peering service. This function may be safely called at any time: before the service is started, while running, or after it stops.

Add peer may also be called multiple times for the same peer. The new addresses will replace the old.

func (*PeeringService) ListPeers

func (ps *PeeringService) ListPeers() []peer.AddrInfo

ListPeers lists peers in the peering service.

func (*PeeringService) RemovePeer

func (ps *PeeringService) RemovePeer(id peer.ID)

RemovePeer removes a peer from the peering service. This function may be safely called at any time: before the service is started, while running, or after it stops.

func (*PeeringService) Start

func (ps *PeeringService) Start() error

Start starts the peering service, connecting and maintaining connections to all registered peers. It returns an error if the service has already been stopped.

func (*PeeringService) Stop

func (ps *PeeringService) Stop() error

Stop stops the peering service.

type PingArgs

type PingArgs struct {
	Addr string
}

PingArgs get passed to the Ping command

type PingResult

type PingResult struct {
	ID             string   // Host's peer ID
	Addrs          []string // Addresses the host is listening on
	Peers          []string // Peers currently connected to the node (local daemon only)
	LatencySeconds float64
	Version        string // The Version the node is running
	Err            string
}

PingResult is sent in the notify message to give us the info we requested

type Pop

type Pop struct {
	Host host.Host
	// contains filtered or unexported fields
}

Pop is the pop node implementation

func New

func New(ctx context.Context, opts Options) (*Pop, error)

New puts together all the components of the ipfs node

func (*Pop) Add

func (nd *Pop) Add(ctx context.Context, dag ipldformat.DAGService, buf io.ReadSeeker, opts ...DAGOption) (cid.Cid, error)

Add a buffer into the given DAG. These DAGs can eventually be put into transactions.

func (*Pop) Commit

func (nd *Pop) Commit(ctx context.Context, args *CommArgs)

Commit a content transaction for storage

func (*Pop) DealInfo

func (nd *Pop) DealInfo(ctx context.Context, args *DealInfoArgs) (DealInfoResult, error)

DealInfo returns info about any ongoing deals for a given CID

func (*Pop) Get

func (nd *Pop) Get(ctx context.Context, args *GetArgs)

Get sends a request for content with the given arguments. It also sends feedback to any open cli connections

func (*Pop) Import

func (nd *Pop) Import(ctx context.Context, args *ImportArgs)

Import blocks from a CAR file

func (*Pop) List

func (nd *Pop) List(ctx context.Context, args *ListArgs)

List returns all the roots for the content stored by this node

func (*Pop) Load

func (nd *Pop) Load(ctx context.Context, args *GetArgs) (chan GetResult, error)

Load is an RPC method that retrieves a given CID and key to the local blockstore. It sends feedback events to a result channel that it returns.

func (*Pop) Off

func (nd *Pop) Off(ctx context.Context)

Off shutdown the node gracefully

func (*Pop) PayCollect

func (nd *Pop) PayCollect(ctx context.Context, args *PayArgs)

PayCollect sends a collect message for a given actor, validating before to make sure the channel is in the right state

func (*Pop) PayList

func (nd *Pop) PayList(ctx context.Context, args *PayArgs)

PayList all vouchers for all payment channels we have

func (*Pop) PaySettle

func (nd *Pop) PaySettle(ctx context.Context, args *PayArgs)

PaySettle sends a settle message for a given actor and saves the time after which it can be collected

func (*Pop) PaySubmit

func (nd *Pop) PaySubmit(ctx context.Context, args *PayArgs)

PaySubmit vouchers for a given payment channel

func (*Pop) PayTrack

func (nd *Pop) PayTrack(ctx context.Context, args *PayArgs)

PayTrack the given channel loading the state from chain and adding it to the store currently only for inbound channels. Mostly for debugging purposes

func (*Pop) Ping

func (nd *Pop) Ping(ctx context.Context, who string)

Ping the node for sanity check more than anything

func (*Pop) Put

func (nd *Pop) Put(ctx context.Context, args *PutArgs)

Put a file into a new or pending transaction

func (*Pop) SetNotify

func (nd *Pop) SetNotify(notify func(Notify))

SetNotify sets a notify callback function

func (*Pop) Status

func (nd *Pop) Status(ctx context.Context, args *StatusArgs)

Status prints the current transaction status. It shows which files have been added but not yet committed to the network

func (*Pop) WalletExport

func (nd *Pop) WalletExport(ctx context.Context, args *WalletExportArgs)

WalletExport writes the private key for a given address to a file at the given path

func (*Pop) WalletList

func (nd *Pop) WalletList(ctx context.Context, args *WalletListArgs)

WalletList returns a list of all addresses for which we have the private keys

func (*Pop) WalletPay

func (nd *Pop) WalletPay(ctx context.Context, args *WalletPayArgs)

WalletPay transfers funds from one given address for which we have the private key to another one

type PutArgs

type PutArgs struct {
	Path      string
	ChunkSize int
	Codec     uint64
}

PutArgs get passed to the Put command

type PutResult

type PutResult struct {
	RootCid   string
	Key       string
	Cid       string
	Size      int64
	TotalSize string
	Len       int
	Err       string
}

PutResult gives us feedback on the result of the Put request

type RRecord

type RRecord struct {
	PeerAddr  []byte
	PayAddr   address.Address
	Size      int64
	Signature *crypto.Signature
}

RRecord is a lightweight record to store as encoded bytes in a remote index

func (*RRecord) MarshalCBOR

func (t *RRecord) MarshalCBOR(w io.Writer) error

func (*RRecord) SigningBytes

func (r *RRecord) SigningBytes() ([]byte, error)

SigningBytes prepares the bytes for signing

func (*RRecord) UnmarshalCBOR

func (t *RRecord) UnmarshalCBOR(r io.Reader) error

type ReleaseDetails

type ReleaseDetails struct {
	AssetsURL string `json:"assets_url"`
	ID        int    `json:"id"`
}

type ReleaseUpdate

type ReleaseUpdate struct {
	Action   string          `json:"action"`
	Workflow WorkflowDetails `json:"workflow_job"`
}

type RemoteIndex

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

RemoteIndex can publish cbor encoded records that a provider is storing a thing

func NewRemoteIndex

func NewRemoteIndex(url string, h host.Host, w wallet.Driver, domains []string) (*RemoteIndex, error)

NewRemoteIndex creates a new index instance for the given wallet and host

func (*RemoteIndex) Delete

func (ri *RemoteIndex) Delete(key cid.Cid) error

Delete a record when the content has been evicted from our store

func (*RemoteIndex) Publish

func (ri *RemoteIndex) Publish(key cid.Cid, size int64) error

Publish a record to the remote url for a given cid

type StatusArgs

type StatusArgs struct {
	Verbose bool
}

StatusArgs get passed to the Status command

type StatusResult

type StatusResult struct {
	RootCid string
	Entries string
	Err     string
}

StatusResult gives us the result of status request to ping

type Step

type Step struct {
	Name       string `json:"name"`
	Status     string `json:"status"`
	Conclusion string `json:"conclusion"`
}

type WalletExportArgs

type WalletExportArgs struct {
	Address    string
	OutputPath string
}

WalletExportArgs get passed to the WalletExport command

type WalletListArgs

type WalletListArgs struct{}

WalletListArgs get passed to the WalletList command

type WalletPayArgs

type WalletPayArgs struct {
	From   string
	To     string
	Amount string
}

WalletPayArgs get passed to the WalletPay command

type WalletResult

type WalletResult struct {
	Err            string
	Addresses      []string
	DefaultAddress string
}

WalletResult returns the output of every WalletList/WalletExport/WalletPay requests

type WorkflowDetails

type WorkflowDetails struct {
	Name  string `json:"name"`
	ID    int    `json:"id"`
	Steps []Step `json:"steps"`
}

Jump to

Keyboard shortcuts

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