helper

package
v0.0.0-...-9fdd194 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0, MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EscrowChanMaps              = cmap.New()
	EscrowContractMaps          = cmap.New()
	GuardChanMaps               = cmap.New()
	GuardContractMaps           = cmap.New()
	BalanceChanMaps             = cmap.New()
	UnsignedChannelCommitMaps   = cmap.New()
	SignedChannelCommitChanMaps = cmap.New()
	PayinReqChanMaps            = cmap.New()
	FileMetaChanMaps            = cmap.New()
	QuestionsChanMaps           = cmap.New()
	WaitUploadChanMap           = cmap.New()
)
View Source
var (
	WaitUploadBo = func(maxTime time.Duration) *backoff.ExponentialBackOff {
		bo := backoff.NewExponentialBackOff()
		bo.InitialInterval = 10 * time.Second
		bo.MaxElapsedTime = maxTime
		bo.Multiplier = 1.5
		bo.MaxInterval = 10 * time.Minute
		return bo
	}
	HandleShardBo = func() *backoff.ExponentialBackOff {
		bo := backoff.NewExponentialBackOff()
		bo.InitialInterval = 1 * time.Second
		bo.MaxElapsedTime = 300 * time.Second
		bo.Multiplier = 1
		bo.MaxInterval = 1 * time.Second
		return bo
	}()
	CheckPaymentBo = func() *backoff.ExponentialBackOff {
		bo := backoff.NewExponentialBackOff()
		bo.InitialInterval = 10 * time.Second
		bo.MaxElapsedTime = 5 * time.Minute
		bo.Multiplier = 1.5
		bo.MaxInterval = 60 * time.Second
		return bo
	}()
	DownloadShardBo = func(maxTime time.Duration) *backoff.ExponentialBackOff {
		bo := backoff.NewExponentialBackOff()
		bo.InitialInterval = 10 * time.Second
		bo.MaxElapsedTime = maxTime
		bo.Multiplier = 1.5
		bo.MaxInterval = 30 * time.Minute
		return bo
	}
	WaitingForPeersBo = func() *backoff.ExponentialBackOff {
		bo := backoff.NewExponentialBackOff()
		bo.InitialInterval = 1 * time.Second
		bo.MaxElapsedTime = 300 * time.Second
		bo.Multiplier = 1.2
		bo.MaxInterval = 5 * time.Second
		return bo
	}()
)

Functions

func GetPriceAndMinStorageLength

func GetPriceAndMinStorageLength(params *ContextParams) (price int64, storageLength int, err error)

func GetShardHashes

func GetShardHashes(params *ContextParams, fileHash string) (shardHashes []string, fileSize int64,
	shardSize int64, err error)

func GetShardHashesCopy

func GetShardHashesCopy(params *ContextParams, fileHash string, copyNum int) (shardHashes []string, fileSize int64,
	shardSize int64, err error)

func NewContractID

func NewContractID(sessionId string) string

func SplitContractId

func SplitContractId(contractId string) (ssId string, shardHash string)

func TotalPay

func TotalPay(shardSize int64, price int64, storageLength int, rate *big.Int) (int64, error)

func TotalPayReal

func TotalPayReal(shardSize int64, price int64, storageLength int, rate *big.Int) (int64, error)

func TotalPayRound

func TotalPayRound(shardSize int64, price int64, storageLength int, rate *big.Int) (int64, error)

Types

type ContextParams

type ContextParams struct {
	Req *cmds.Request
	Env cmds.Environment
	Ctx context.Context
	N   *core.IpfsNode
	Cfg *config.Config
	Api iface.CoreAPI
}

func ExtractContextParams

func ExtractContextParams(req *cmds.Request, env cmds.Environment) (*ContextParams, error)

type CustomizedHostsProvider

type CustomizedHostsProvider struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*CustomizedHostsProvider) AddIndex

func (p *CustomizedHostsProvider) AddIndex() (int, error)

func (*CustomizedHostsProvider) NextValidHost

func (p *CustomizedHostsProvider) NextValidHost() (string, error)

type HostsProvider

type HostsProvider struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*HostsProvider) AddIndex

func (p *HostsProvider) AddIndex() (int, error)

func (*HostsProvider) NextValidHost

func (p *HostsProvider) NextValidHost() (string, error)

func (*HostsProvider) PickFromBackupHosts

func (p *HostsProvider) PickFromBackupHosts() (string, error)

type IHostsProvider

type IHostsProvider interface {
	NextValidHost() (string, error)
}

func GetCustomizedHostsProvider

func GetCustomizedHostsProvider(cp *ContextParams, hosts []string) IHostsProvider

func GetHostsProvider

func GetHostsProvider(cp *ContextParams, blacklist []string) IHostsProvider

type Peers

type Peers []iface.ConnectionInfo

func (Peers) Len

func (p Peers) Len() int

func (Peers) Less

func (p Peers) Less(i int, j int) bool

func (Peers) Swap

func (p Peers) Swap(i int, j int)

Jump to

Keyboard shortcuts

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