Documentation ¶
Index ¶
- Variables
- type Events
- type Faucet
- func (f *Faucet) ApplyConfirmation(confirmation *whiteflag.Confirmation) error
- func (f *Faucet) Enqueue(bech32Addr string) (*FaucetEnqueueResponse, error)
- func (f *Faucet) FlushRequests()
- func (f *Faucet) Info() (*FaucetInfoResponse, error)
- func (f *Faucet) NetworkPrefix() iotago.NetworkPrefix
- func (f *Faucet) RunFaucetLoop(ctx context.Context, initDoneCallback func()) error
- type FaucetEnqueueResponse
- type FaucetInfoResponse
- type Option
- func WithAmount(amount uint64) Option
- func WithBatchTimeout(timeout time.Duration) Option
- func WithHRPNetworkPrefix(networkPrefix iotago.NetworkPrefix) Option
- func WithIndexationMessage(indexationMessage string) Option
- func WithLogger(logger *logger.Logger) Option
- func WithMaxAddressBalance(maxAddressBalance uint64) Option
- func WithMaxOutputCount(maxOutputCount int) Option
- func WithPowWorkerCount(powWorkerCount int) Option
- func WithSmallAmount(smallAmount uint64) Option
- type Options
- type SendMessageFunc
- type TipselFunc
Constants ¶
This section is empty.
Variables ¶
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.
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 ¶
WithAmount defines the amount of funds the requester receives.
func WithBatchTimeout ¶
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 ¶
WithIndexationMessage defines the faucet transaction indexation payload.
func WithLogger ¶
WithLogger enables logging within the faucet.
func WithMaxAddressBalance ¶
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 ¶
WithMaxOutputCount defines the maximum output count per faucet message.
func WithPowWorkerCount ¶
WithPowWorkerCount defines the amount of workers used for calculating PoW when issuing faucet messages.
func WithSmallAmount ¶
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 ¶
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.