faucet

package
v0.7.7 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2021 License: Apache-2.0, BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	// ObjectName defines the name of the faucet object (payload).
	ObjectName = "faucet"
)

Variables

View Source
var (
	Type = payload.NewType(payloadType, ObjectName, PayloadUnmarshaler)
)

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.

Types

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)
emptyID := identity.ID{}

// 1. create faucet payload
faucetRequest := NewRequest(address, emptyID, emptyID, 0)

// 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 ledgerstate.Address, accessManaPledgeID, consensusManaPledgeID identity.ID, nonce uint64) *Request

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

func (*Request) AccessManaPledgeID

func (p *Request) AccessManaPledgeID() identity.ID

AccessManaPledgeID returns the access mana pledge ID of the faucet request.

func (*Request) Address

func (p *Request) Address() ledgerstate.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) ConsensusManaPledgeID

func (p *Request) ConsensusManaPledgeID() identity.ID

ConsensusManaPledgeID returns the consensus mana pledge ID of the faucet request.

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