Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToString(data []byte, encoding int) (string, error)
- func Call(ctx context.Context, cfg *config.Config, sub string) error
- func CheckAndGetReedSolomonShardHashes(ctx context.Context, node *core.IpfsNode, api coreiface.CoreAPI, ...) ([]cid.Cid, int64, error)
- func CheckAndValidateHostStorageMax(ctx context.Context, cfgRoot string, r repo.Repo, newMax *uint64, ...) (uint64, error)
- func ConvertPubKeyFromString(pubKeyStr string) (ic.PubKey, error)
- func ConvertToPubKey(pubKeyStr string) (ic.PubKey, error)
- func GetHostStorageConfig(ctx context.Context, node *core.IpfsNode) (*nodepb.Node_Settings, error)
- func GetHostStorageConfigForPeer(ctx context.Context, node *core.IpfsNode, peerID string) (*nodepb.Node_Settings, error)
- func GetHostStorageConfigHelper(ctx context.Context, node *core.IpfsNode, syncHub bool) (*nodepb.Node_Settings, error)
- func GetHostStorageKey(pid string) ds.Key
- func GetHostsFromDatastore(ctx context.Context, node *core.IpfsNode, mode string, num int) ([]*hubpb.Host, error)
- func NewGoContext(reqCtx context.Context) (context.Context, context.CancelFunc)
- func NewKeyHelper(kss ...string) ds.Key
- func PidFromString(key string) (peer.ID, error)
- func PutHostStorageConfig(ctx context.Context, node *core.IpfsNode, ns *nodepb.Node_Settings) error
- func SaveHostsIntoDatastore(ctx context.Context, node *core.IpfsNode, mode string, nodes []*hubpb.Host) error
- func StringToBytes(str string, encoding int) ([]byte, error)
- type ByteSize
Constants ¶
const ( HostStorePrefix = "/hosts/" // from btfs-hub HostStorageInfoPrefix = "/host_storage/" // self or from network )
const ( Text = iota + 1 Base64 )
const ( // Normally each op has its own timeout, but in case of buggy paths // this timeout serves as a catch-all to prevent mem leaks DefaultStorageTimeout = 5 * time.Minute )
Variables ¶
var ContractFilterMap = map[string]map[guardpb.Contract_ContractState]bool{ "active": { guardpb.Contract_UPLOADED: true, guardpb.Contract_RENEWED: true, guardpb.Contract_WARN: true, }, "finished": { guardpb.Contract_CLOSED: true, }, "invalid": { guardpb.Contract_DRAFT: true, guardpb.Contract_SIGNED: true, guardpb.Contract_LOST: true, guardpb.Contract_CANCELED: true, guardpb.Contract_OBSOLETE: true, guardpb.Contract_DRAFT_WARN: true, guardpb.Contract_READY_CHALLENGE: true, guardpb.Contract_RECREATED: true, guardpb.Contract_REQUEST_CHALLENGE: true, }, "all": { guardpb.Contract_DRAFT: true, guardpb.Contract_SIGNED: true, guardpb.Contract_UPLOADED: true, guardpb.Contract_LOST: true, guardpb.Contract_CANCELED: true, guardpb.Contract_CLOSED: true, guardpb.Contract_RENEWED: true, guardpb.Contract_OBSOLETE: true, guardpb.Contract_WARN: true, guardpb.Contract_DRAFT_WARN: true, guardpb.Contract_READY_CHALLENGE: true, guardpb.Contract_RECREATED: true, guardpb.Contract_REQUEST_CHALLENGE: true, }, }
Functions ¶
func CheckAndGetReedSolomonShardHashes ¶
func CheckAndGetReedSolomonShardHashes(ctx context.Context, node *core.IpfsNode, api coreiface.CoreAPI, rootHash cid.Cid) ([]cid.Cid, int64, error)
CheckAndGetReedSolomonShardHashes checks to see if a root hash is a reed solomon file, if ok, returns the list of shard hashes.
func CheckAndValidateHostStorageMax ¶
func CheckAndValidateHostStorageMax(ctx context.Context, cfgRoot string, r repo.Repo, newMax *uint64, maxAllowed bool) (uint64, error)
CheckAndValidateHostStorageMax makes sure the current storage max is under the accepted disk space max, if not, corrects this value. Optionally, this function can take a new max and sets the max to this value. Optionally, maxAllowed enables reducing unreasonable settings down to an allowed value.
func GetHostStorageConfig ¶
GetHostStorageConfig checks if locally is storing a config, if yes, returns it, otherwise, queries hub to retrieve the latest default config.
func GetHostStorageConfigForPeer ¶
func GetHostStorageConfigForPeer(ctx context.Context, node *core.IpfsNode, peerID string) (*nodepb.Node_Settings, error)
GetHostStorageConfigForPeer retrieves locally saved info about peer (including self)
func GetHostStorageConfigHelper ¶
func GetHostStorageConfigHelper(ctx context.Context, node *core.IpfsNode, syncHub bool) (*nodepb.Node_Settings, error)
GetHostStorageConfigHelper checks if locally is storing a config, if yes, returns it, otherwise, queries hub to retrieve the latest default config. If syncHub is on, force a sync from Hub to retrieve latest information.
func GetHostStorageKey ¶
func GetHostsFromDatastore ¶
func GetHostsFromDatastore(ctx context.Context, node *core.IpfsNode, mode string, num int) ([]*hubpb.Host, error)
GetHostsFromDatastore retrieves `num` hosts from the datastore, if not enough hosts are available, return an error instead of partial return. When num=0 it means unlimited.
func NewGoContext ¶
NewGoContext creates a new context with remaining timeout from the existing request context, so that request can be cancelled and new goroutine should use this new context.
func NewKeyHelper ¶
func PutHostStorageConfig ¶
PutHostStorageConfig saves an updated storage storage config.