faucet

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 License: Apache-2.0, BSD-2-Clause Imports: 33 Imported by: 1

Documentation

Index

Examples

Constants

View Source
const (
	// PluginName is the name of the faucet dApp.
	PluginName = "Faucet"

	// CfgFaucetSeed defines the base58 encoded seed the faucet uses.
	CfgFaucetSeed = "faucet.seed"
	// CfgFaucetTokensPerRequest defines the amount of tokens the faucet should send for each request.
	CfgFaucetTokensPerRequest = "faucet.tokensPerRequest"
	// CfgFaucetMaxTransactionBookedAwaitTimeSeconds defines the time to await for the transaction fulfilling a funding request
	// to become booked in the value layer.
	CfgFaucetMaxTransactionBookedAwaitTimeSeconds = "faucet.maxTransactionBookedAwaitTimeSeconds"
	// CfgFaucetPoWDifficulty defines the PoW difficulty for faucet payloads.
	CfgFaucetPoWDifficulty = "faucet.powDifficulty"
	// CfgFaucetBlacklistCapacity holds the maximum amount the address blacklist holds.
	// An address for which a funding was done in the past is added to the blacklist and eventually is removed from it.
	CfgFaucetBlacklistCapacity = "faucet.blacklistCapacity"
)
View Source
const (
	// ObjectName defines the name of the faucet object (payload).
	ObjectName = "faucet"
)

Variables

View Source
var (
	// ErrAddressIsBlacklisted is returned if a funding can't be processed since the address is blacklisted.
	ErrAddressIsBlacklisted = errors.New("can't fund address as it is blacklisted")
)

Type represents the identifier for the faucet Request type.

Functions

func IsFaucetReq

func IsFaucetReq(msg *tangle.Message) bool

IsFaucetReq checks if the message is faucet payload.

func PayloadUnmarshaler

func PayloadUnmarshaler(data []byte) (payload payload.Payload, err error)

PayloadUnmarshaler sets the generic unmarshaler.

func Plugin

func Plugin() *node.Plugin

Plugin returns the plugin instance of the faucet dApp.

Types

type Component

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

Component implements a faucet component which will send tokens to actors requesting tokens.

func Faucet

func Faucet() *Component

Faucet gets the faucet component instance the faucet dApp has initialized.

func New

func New(seed []byte, tokensPerRequest int64, blacklistCapacity int, maxTxBookedAwaitTime time.Duration) *Component

New creates a new faucet component using the given seed and tokensPerRequest config.

func (*Component) IsAddressBlacklisted

func (c *Component) IsAddressBlacklisted(addr address.Address) bool

IsAddressBlacklisted checks whether the given address is currently blacklisted.

func (*Component) SendFunds

func (c *Component) SendFunds(msg *tangle.Message) (m *tangle.Message, txID string, err error)

SendFunds sends IOTA tokens to the address from faucet request.

type Request

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

Request represents a faucet request which contains an address for the faucet to send funds to.

Example
keyPair := ed25519.GenerateKeyPair()
local := identity.NewLocalIdentity(keyPair.PublicKey, keyPair.PrivateKey)

// 1. create faucet payload
faucetRequest, err := NewRequest(address.Random(), 4)
if err != nil {
	panic(err)
}

// 2. build actual message
tx := tangle.NewMessage(
	[]tangle.MessageID{tangle.EmptyMessageID},
	[]tangle.MessageID{},
	time.Now(),
	local.PublicKey(),
	0,
	faucetRequest,
	0,
	ed25519.EmptySignature,
)
fmt.Println(tx.String())
Output:

func FromBytes

func FromBytes(bytes []byte) (result *Request, consumedBytes int, err error)

FromBytes parses the marshaled version of a Request into a request object.

func NewRequest

func NewRequest(addr address.Address, powTarget int) (*Request, error)

NewRequest is the constructor of a Request and creates a new Request object from the given details.

func (*Request) Address

func (p *Request) Address() address.Address

Address returns the address of the faucet Request.

func (*Request) Bytes

func (p *Request) Bytes() []byte

Bytes marshals the faucet Request payload into a sequence of bytes.

func (*Request) String

func (p *Request) String() string

String returns a human readable version of faucet Request payload (for debug purposes).

func (*Request) Type

func (p *Request) Type() payload.Type

Type returns the type of the faucet Request.

Jump to

Keyboard shortcuts

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