Documentation ¶
Index ¶
Examples ¶
Constants ¶
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" )
const (
// ObjectName defines the name of the faucet object (payload).
ObjectName = "faucet"
)
Variables ¶
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") )
var Type = payload.NewType(2, ObjectName, PayloadUnmarshaler)
Type represents the identifier for the faucet Request type.
Functions ¶
func IsFaucetReq ¶
IsFaucetReq checks if the message is faucet payload.
func PayloadUnmarshaler ¶
PayloadUnmarshaler sets the generic unmarshaler.
Types ¶
type Component ¶
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 ledgerstate.Address) bool
IsAddressBlacklisted checks whether the given address is currently blacklisted.
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() address := ledgerstate.NewED25519Address(keyPair.PublicKey) local := identity.NewLocalIdentity(keyPair.PublicKey, keyPair.PrivateKey) // 1. create faucet payload faucetRequest, err := NewRequest(address, 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 NewRequest ¶
func NewRequest(addr ledgerstate.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() ledgerstate.Address
Address returns the address of the faucet Request.