messagesigner

package
v0.0.0-...-484cccf Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: Apache-2.0, MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SigningBytes

func SigningBytes(msg *types.Message, sigType address.Protocol) ([]byte, error)

Types

type MessageSigner

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

MessageSigner keeps track of nonces per address, and increments the nonce when signing a message

func NewMessageSigner

func NewMessageSigner(wallet api.Wallet, mpool messagepool.MpoolNonceAPI, ds dtypes.MetadataDS) *MessageSigner

func (*MessageSigner) GetSignedMessage

func (ms *MessageSigner) GetSignedMessage(ctx context.Context, uuid uuid.UUID) (*types.SignedMessage, error)

func (*MessageSigner) NextNonce

func (ms *MessageSigner) NextNonce(ctx context.Context, addr address.Address) (uint64, error)

NextNonce gets the next nonce for the given address. If there is no nonce in the datastore, gets the nonce from the message pool.

func (*MessageSigner) SaveNonce

func (ms *MessageSigner) SaveNonce(ctx context.Context, addr address.Address, nonce uint64) error

SaveNonce increments the nonce for this address and writes it to the datastore

func (*MessageSigner) SignMessage

func (ms *MessageSigner) SignMessage(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec, cb func(*types.SignedMessage) error) (*types.SignedMessage, error)

SignMessage increments the nonce for the message From address, and signs the message

func (*MessageSigner) StoreSignedMessage

func (ms *MessageSigner) StoreSignedMessage(ctx context.Context, uuid uuid.UUID, message *types.SignedMessage) error

type MessageSignerConsensus

type MessageSignerConsensus struct {
	MsgSigner
	Consensus *consensus.Consensus
}

func NewMessageSignerConsensus

func NewMessageSignerConsensus(
	wallet api.Wallet,
	mpool messagepool.MpoolNonceAPI,
	ds dtypes.MetadataDS,
	consensus *consensus.Consensus) *MessageSignerConsensus

func (*MessageSignerConsensus) GetRaftState

func (ms *MessageSignerConsensus) GetRaftState(ctx context.Context) (*consensus.RaftState, error)

func (*MessageSignerConsensus) GetSignedMessage

func (ms *MessageSignerConsensus) GetSignedMessage(ctx context.Context, uuid uuid.UUID) (*types.SignedMessage, error)

func (*MessageSignerConsensus) IsLeader

func (ms *MessageSignerConsensus) IsLeader(ctx context.Context) bool

func (*MessageSignerConsensus) Leader

func (ms *MessageSignerConsensus) Leader(ctx context.Context) (peer.ID, error)

func (*MessageSignerConsensus) RedirectToLeader

func (ms *MessageSignerConsensus) RedirectToLeader(ctx context.Context, method string, arg interface{}, ret interface{}) (bool, error)

func (*MessageSignerConsensus) SignMessage

type MsgSigner

type MsgSigner interface {
	SignMessage(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec, cb func(*types.SignedMessage) error) (*types.SignedMessage, error)
	GetSignedMessage(ctx context.Context, uuid uuid.UUID) (*types.SignedMessage, error)
	StoreSignedMessage(ctx context.Context, uuid uuid.UUID, message *types.SignedMessage) error
	NextNonce(ctx context.Context, addr address.Address) (uint64, error)
	SaveNonce(ctx context.Context, addr address.Address, nonce uint64) error
}

Jump to

Keyboard shortcuts

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