Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ZeroWorker is a PoW worker that always returns 0 as the nonce. ZeroWorker = WorkerFunc(func([]byte) (uint64, error) { return 0, nil }) )
Functions ¶
This section is empty.
Types ¶
type Events ¶
type Events struct {
// Fired when a message is built including tips, sequence number and other metadata.
MessageConstructed *events.Event
// Fired when an error occurred.
Error *events.Event
}
Events represents events happening on a message factory.
type MessageFactory ¶
type MessageFactory struct {
Events *Events
// contains filtered or unexported fields
}
MessageFactory acts as a factory to create new messages.
func New ¶
func New(store kvstore.KVStore, sequenceKey []byte, localIdentity *identity.LocalIdentity, selector TipSelector) *MessageFactory
New creates a new message factory.
func (*MessageFactory) IssuePayload ¶
IssuePayload creates a new message including sequence number and tip selection and returns it. It also triggers the MessageConstructed event once it's done, which is for example used by the plugins to listen for messages that shall be attached to the tangle.
func (*MessageFactory) SetWorker ¶
func (m *MessageFactory) SetWorker(worker Worker)
SetWorker sets the PoW worker to be used for the messages.
func (*MessageFactory) Shutdown ¶
func (m *MessageFactory) Shutdown()
Shutdown closes the messageFactory and persists the sequence number.
type TipSelector ¶
A TipSelector selects two tips, branch and trunk, for a new message to attach to.
type TipSelectorFunc ¶
The TipSelectorFunc type is an adapter to allow the use of ordinary functions as tip selectors.