faucet

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoTipsGiven is returned when no tips were given to issue a message.
	ErrNoTipsGiven = errors.New("no tips given")
	// ErrNothingToProcess is returned when there is no need to sweep or send funds.
	ErrNothingToProcess = errors.New("nothing to process")
)

Functions

This section is empty.

Types

type Events

type Events struct {
	// Fired when a faucet message is issued.
	IssuedMessage *events.Event
	// SoftError is triggered when a soft error is encountered.
	SoftError *events.Event
}

Events are the events issued by the faucet.

type Faucet

type Faucet struct {
	// lock used to secure the state of the faucet.
	syncutils.Mutex
	// the logger used to log events.
	*utils.WrappedLogger

	// events of the faucet.
	Events *Events
	// contains filtered or unexported fields
}

Faucet is used to issue transaction to users that requested funds via a REST endpoint.

func New

func New(
	daemon daemon.Daemon,
	dbStorage *storage.Storage,
	syncManager *syncmanager.SyncManager,
	networkID uint64,
	belowMaxDepth int,
	utxoManager *utxo.Manager,
	address *iotago.Ed25519Address,
	addressSigner iotago.AddressSigner,
	tipselFunc TipselFunc,
	powHandler *pow.Handler,
	sendMessageFunc SendMessageFunc,
	opts ...Option) *Faucet

New creates a new faucet instance.

func (*Faucet) ApplyConfirmation added in v1.1.0

func (f *Faucet) ApplyConfirmation(confirmation *whiteflag.Confirmation) error

ApplyConfirmation applies new milestone confirmations to the faucet. Pending transactions are checked for their current state and either removed, readded, or left pending. If a conflict is found, all remaining pending transactions are readded to the queue. no need to ReadLockLedger, because this function should be called from milestone confirmation event anyway.

func (*Faucet) Enqueue

func (f *Faucet) Enqueue(bech32Addr string) (*FaucetEnqueueResponse, error)

Enqueue adds a new faucet request to the queue.

func (*Faucet) FlushRequests added in v1.1.0

func (f *Faucet) FlushRequests()

FlushRequests stops current batching of faucet requests.

func (*Faucet) Info

func (f *Faucet) Info() (*FaucetInfoResponse, error)

Info returns the used faucet address and remaining balance.

func (*Faucet) NetworkPrefix

func (f *Faucet) NetworkPrefix() iotago.NetworkPrefix

NetworkPrefix returns the used network prefix.

func (*Faucet) RunFaucetLoop

func (f *Faucet) RunFaucetLoop(ctx context.Context, initDoneCallback func()) error

RunFaucetLoop collects unspent outputs on the faucet address and batches the requests from the queue.

type FaucetEnqueueResponse

type FaucetEnqueueResponse struct {
	// The bech32 address.
	Address string `json:"address"`
	// The number of waiting requests in the queue.
	WaitingRequests int `json:"waitingRequests"`
}

FaucetEnqueueResponse defines the response of a POST RouteFaucetEnqueue REST API call.

type FaucetInfoResponse

type FaucetInfoResponse struct {
	// The bech32 address of the faucet.
	Address string `json:"address"`
	// The remaining balance of faucet.
	Balance uint64 `json:"balance"`
}

FaucetInfoResponse defines the response of a GET RouteFaucetInfo REST API call.

type Option

type Option func(opts *Options)

Option is a function setting a faucet option.

func WithAmount

func WithAmount(amount uint64) Option

WithAmount defines the amount of funds the requester receives.

func WithBatchTimeout

func WithBatchTimeout(timeout time.Duration) Option

WithBatchTimeout sets the maximum duration for collecting faucet batches.

func WithHRPNetworkPrefix

func WithHRPNetworkPrefix(networkPrefix iotago.NetworkPrefix) Option

WithHRPNetworkPrefix sets the bech32 HRP network prefix.

func WithIndexationMessage

func WithIndexationMessage(indexationMessage string) Option

WithIndexationMessage defines the faucet transaction indexation payload.

func WithLogger

func WithLogger(logger *logger.Logger) Option

WithLogger enables logging within the faucet.

func WithMaxAddressBalance

func WithMaxAddressBalance(maxAddressBalance uint64) Option

WithMaxAddressBalance defines the maximum allowed amount of funds on the target address. If there are more funds already, the faucet request is rejected.

func WithMaxOutputCount

func WithMaxOutputCount(maxOutputCount int) Option

WithMaxOutputCount defines the maximum output count per faucet message.

func WithPowWorkerCount

func WithPowWorkerCount(powWorkerCount int) Option

WithPowWorkerCount defines the amount of workers used for calculating PoW when issuing faucet messages.

func WithSmallAmount

func WithSmallAmount(smallAmount uint64) Option

WithSmallAmount defines the amount of funds the requester receives if the target address has more funds than the faucet amount and less than maximum.

type Options

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

Options define options for the faucet.

type SendMessageFunc

type SendMessageFunc = func(msg *storage.Message) error

SendMessageFunc is a function which sends a message to the network.

type TipselFunc

type TipselFunc = func() (tips hornet.MessageIDs, err error)

TipselFunc selects tips for the faucet.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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