types

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDialRetryMax    = errors.New("dialed maximum retries")
	ErrConnWaitTimeout = errors.New("waited for remote signer for too long")
	ErrConnTimeout     = errors.New("remote signer timed out")
)

Socket errors.

Functions

This section is empty.

Types

type LastSignedInfo

type LastSignedInfo struct {
	Height    int64            `json:"height"`
	Round     int              `json:"round"`
	Step      int8             `json:"step"`
	Signature crypto.Signature `json:"signature,omitempty"` // so we dont lose signatures
	SignBytes cmn.HexBytes     `json:"signbytes,omitempty"` // so we dont lose signatures
}

LastSignedInfo contains information about the latest data signed by a validator to help prevent double signing.

func NewLastSignedInfo

func NewLastSignedInfo() *LastSignedInfo

func (*LastSignedInfo) Reset

func (info *LastSignedInfo) Reset()

Reset resets all the values. XXX: Unsafe.

func (*LastSignedInfo) Set

func (info *LastSignedInfo) Set(height int64, round int, step int8,
	signBytes []byte, sig crypto.Signature)

Set height/round/step and signature on the info

func (*LastSignedInfo) SignProposal

func (lsi *LastSignedInfo) SignProposal(signer types.Signer, chainID string, proposal *types.Proposal) error

SignProposal checks if the height/round/step (HRS) are greater than the latest state of the LastSignedInfo. If so, it signs the proposal, updates the LastSignedInfo, and sets the signature on the proposal. If the HRS are equal and the only thing changed is the timestamp, it sets the timestamp to the previous value and the Signature to the LastSignedInfo.Signature. Else it returns an error.

func (*LastSignedInfo) SignVote

func (lsi *LastSignedInfo) SignVote(signer types.Signer, chainID string, vote *types.Vote) error

SignVote checks the height/round/step (HRS) are greater than the latest state of the LastSignedInfo. If so, it signs the vote, updates the LastSignedInfo, and sets the signature on the vote. If the HRS are equal and the only thing changed is the timestamp, it sets the vote.Timestamp to the previous value and the Signature to the LastSignedInfo.Signature. Else it returns an error.

func (*LastSignedInfo) String

func (info *LastSignedInfo) String() string

func (LastSignedInfo) Verify

func (info LastSignedInfo) Verify(height int64, round int, step int8) (bool, error)

Verify returns an error if there is a height/round/step regression or if the HRS matches but there are no LastSignBytes. It returns true if HRS matches exactly and the LastSignature exists. It panics if the HRS matches, the LastSignBytes are not empty, but the LastSignature is empty.

type PrivKey

type PrivKey crypto.PrivKey

PrivKey implements Signer

func (PrivKey) MarshalJSON

func (pk PrivKey) MarshalJSON() ([]byte, error)

MarshalJSON satisfies json.Marshaler.

func (PrivKey) Sign

func (pk PrivKey) Sign(msg []byte) (crypto.Signature, error)

Sign - Implements Signer

func (*PrivKey) UnmarshalJSON

func (pk *PrivKey) UnmarshalJSON(b []byte) error

UnmarshalJSON satisfies json.Unmarshaler.

type PrivValMsg

type PrivValMsg interface{}

PrivValMsg is sent between RemoteSigner and SocketClient.

type PrivValidator

type PrivValidator = types.PrivValidator2

PrivValidator aliases types.PrivValidator

type PrivValidatorJSON

type PrivValidatorJSON struct {
	*PrivValidatorUnencrypted
	// contains filtered or unexported fields
}

PrivValidatorJSON wraps PrivValidatorUnencrypted and persists it to disk after every SignVote and SignProposal.

func GenPrivValidatorJSON

func GenPrivValidatorJSON(filePath string) *PrivValidatorJSON

GenPrivValidatorJSON generates a new validator with randomly generated private key and the given filePath. It does not persist to file.

func LoadOrGenPrivValidatorJSON

func LoadOrGenPrivValidatorJSON(filePath string) *PrivValidatorJSON

LoadOrGenPrivValidatorJSON loads a PrivValidatorJSON from the given filePath or else generates a new one and saves it to the filePath.

func LoadPrivValidatorJSON

func LoadPrivValidatorJSON(filePath string) *PrivValidatorJSON

LoadPrivValidatorJSON loads a PrivValidatorJSON from the filePath.

func NewTestPrivValidator

func NewTestPrivValidator(signer types.TestSigner) *PrivValidatorJSON

NewTestPrivValidator returns a PrivValidatorJSON with a tempfile for the file path.

func UpgradePrivValidator

func UpgradePrivValidator(filePath string) (*PrivValidatorJSON, error)

func (*PrivValidatorJSON) Reset

func (pvj *PrivValidatorJSON) Reset()

Reset resets the PrivValidatorUnencrypted. Panics if the Signer is the wrong type. NOTE: Unsafe!

func (*PrivValidatorJSON) Save

func (pvj *PrivValidatorJSON) Save()

Save persists the PrivValidatorJSON to disk.

func (*PrivValidatorJSON) SignProposal

func (pvj *PrivValidatorJSON) SignProposal(chainID string, proposal *types.Proposal) error

SignProposal implements PrivValidator. It persists to disk.

func (*PrivValidatorJSON) SignVote

func (pvj *PrivValidatorJSON) SignVote(chainID string, vote *types.Vote) error

SignVote implements PrivValidator. It persists to disk.

func (*PrivValidatorJSON) String

func (pvj *PrivValidatorJSON) String() string

String returns a string representation of the PrivValidatorJSON.

type PrivValidatorUnencrypted

type PrivValidatorUnencrypted struct {
	ID             types.ValidatorID `json:"id"`
	PrivKey        PrivKey           `json:"priv_key"`
	LastSignedInfo *LastSignedInfo   `json:"last_signed_info"`
}

PrivValidatorUnencrypted implements PrivValidator. It uses an in-memory crypto.PrivKey that is persisted to disk unencrypted.

func NewPrivValidatorUnencrypted

func NewPrivValidatorUnencrypted(priv crypto.PrivKey) *PrivValidatorUnencrypted

NewPrivValidatorUnencrypted returns an instance of PrivValidatorUnencrypted.

func (*PrivValidatorUnencrypted) Address

func (upv *PrivValidatorUnencrypted) Address() (cmn.HexBytes, error)

func (*PrivValidatorUnencrypted) PubKey

func (upv *PrivValidatorUnencrypted) PubKey() (crypto.PubKey, error)

func (*PrivValidatorUnencrypted) SignHeartbeat

func (upv *PrivValidatorUnencrypted) SignHeartbeat(chainID string, heartbeat *types.Heartbeat) error

func (*PrivValidatorUnencrypted) SignProposal

func (upv *PrivValidatorUnencrypted) SignProposal(chainID string, proposal *types.Proposal) error

func (*PrivValidatorUnencrypted) SignVote

func (upv *PrivValidatorUnencrypted) SignVote(chainID string, vote *types.Vote) error

func (*PrivValidatorUnencrypted) String

func (upv *PrivValidatorUnencrypted) String() string

String returns a string representation of the PrivValidatorUnencrypted

type PrivValidatorV1

type PrivValidatorV1 struct {
	Address       cmn.HexBytes     `json:"address"`
	PubKey        crypto.PubKey    `json:"pub_key"`
	LastHeight    int64            `json:"last_height"`
	LastRound     int              `json:"last_round"`
	LastStep      int8             `json:"last_step"`
	LastSignature crypto.Signature `json:"last_signature,omitempty"` // so we dont lose signatures
	LastSignBytes cmn.HexBytes     `json:"last_signbytes,omitempty"` // so we dont lose signatures
	PrivKey       crypto.PrivKey   `json:"priv_key"`
}

type PrivValidatorsByAddress

type PrivValidatorsByAddress []*PrivValidatorJSON

PrivValidatorsByAddress is a list of PrivValidatorJSON ordered by their addresses.

func (PrivValidatorsByAddress) Len

func (pvs PrivValidatorsByAddress) Len() int

func (PrivValidatorsByAddress) Less

func (pvs PrivValidatorsByAddress) Less(i, j int) bool

func (PrivValidatorsByAddress) Swap

func (pvs PrivValidatorsByAddress) Swap(i, j int)

type PubKeyMsg

type PubKeyMsg struct {
	PubKey crypto.PubKey
}

PubKeyMsg is a PrivValidatorSocket message containing the public key.

type RemoteSigner

type RemoteSigner struct {
	cmn.BaseService
	// contains filtered or unexported fields
}

RemoteSigner implements PrivValidator by dialing to a socket.

func NewRemoteSigner

func NewRemoteSigner(
	logger log.Logger,
	chainID, socketAddr string,
	privVal PrivValidator,
	privKey crypto.PrivKeyEd25519,
) *RemoteSigner

NewRemoteSigner returns an instance of RemoteSigner.

func (*RemoteSigner) OnStart

func (rs *RemoteSigner) OnStart() error

OnStart implements cmn.Service.

func (*RemoteSigner) OnStop

func (rs *RemoteSigner) OnStop()

OnStop implements cmn.Service.

type RemoteSignerOption

type RemoteSignerOption func(*RemoteSigner)

RemoteSignerOption sets an optional parameter on the RemoteSigner.

func RemoteSignerConnDeadline

func RemoteSignerConnDeadline(deadline time.Duration) RemoteSignerOption

RemoteSignerConnDeadline sets the read and write deadline for connections from external signing processes.

func RemoteSignerConnRetries

func RemoteSignerConnRetries(retries int) RemoteSignerOption

RemoteSignerConnRetries sets the amount of attempted retries to connect.

type SignHeartbeatMsg

type SignHeartbeatMsg struct {
	Heartbeat *types.Heartbeat
}

SignHeartbeatMsg is a PrivValidatorSocket message containing a Heartbeat.

type SignProposalMsg

type SignProposalMsg struct {
	Proposal *types.Proposal
}

SignProposalMsg is a PrivValidatorSocket message containing a Proposal.

type SignVoteMsg

type SignVoteMsg struct {
	Vote *types.Vote
}

SignVoteMsg is a PrivValidatorSocket message containing a vote.

type SocketClient

type SocketClient struct {
	cmn.BaseService
	// contains filtered or unexported fields
}

SocketClient implements PrivValidator, it uses a socket to request signatures from an external process.

func NewSocketClient

func NewSocketClient(
	logger log.Logger,
	socketAddr string,
	privKey crypto.PrivKeyEd25519,
) *SocketClient

NewSocketClient returns an instance of SocketClient.

func (*SocketClient) Address

func (sc *SocketClient) Address() (cmn.HexBytes, error)

Address is an alias for PubKey().Address().

func (*SocketClient) GetAddress

func (sc *SocketClient) GetAddress() types.Address

GetAddress implements PrivValidator. TODO(xla): Remove when PrivValidator2 replaced PrivValidator.

func (*SocketClient) GetPubKey

func (sc *SocketClient) GetPubKey() crypto.PubKey

GetPubKey implements PrivValidator. TODO(xla): Remove when PrivValidator2 replaced PrivValidator.

func (*SocketClient) OnStart

func (sc *SocketClient) OnStart() error

OnStart implements cmn.Service.

func (*SocketClient) OnStop

func (sc *SocketClient) OnStop()

OnStop implements cmn.Service.

func (*SocketClient) PubKey

func (sc *SocketClient) PubKey() (crypto.PubKey, error)

PubKey implements PrivValidator2.

func (*SocketClient) SignHeartbeat

func (sc *SocketClient) SignHeartbeat(
	chainID string,
	heartbeat *types.Heartbeat,
) error

SignHeartbeat implements PrivValidator2.

func (*SocketClient) SignProposal

func (sc *SocketClient) SignProposal(
	chainID string,
	proposal *types.Proposal,
) error

SignProposal implements PrivValidator2.

func (*SocketClient) SignVote

func (sc *SocketClient) SignVote(chainID string, vote *types.Vote) error

SignVote implements PrivValidator2.

type SocketClientOption

type SocketClientOption func(*SocketClient)

SocketClientOption sets an optional parameter on the SocketClient.

func SocketClientAcceptDeadline

func SocketClientAcceptDeadline(deadline time.Duration) SocketClientOption

SocketClientAcceptDeadline sets the deadline for the SocketClient listener. A zero time value disables the deadline.

func SocketClientConnDeadline

func SocketClientConnDeadline(deadline time.Duration) SocketClientOption

SocketClientConnDeadline sets the read and write deadline for connections from external signing processes.

func SocketClientConnWait

func SocketClientConnWait(timeout time.Duration) SocketClientOption

SocketClientConnWait sets the timeout duration before connection of external signing processes are considered to be unsuccessful.

func SocketClientHeartbeat

func SocketClientHeartbeat(period time.Duration) SocketClientOption

SocketClientHeartbeat sets the period on which to check the liveness of the connected Signer connections.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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