Documentation
¶
Index ¶
- type Config
- type Payload
- func (p *Payload) DecodeBinary(r *io.BinReader)
- func (p *Payload) DecodeBinaryUnsigned(r *io.BinReader)
- func (p *Payload) EncodeBinary(w *io.BinWriter)
- func (p *Payload) EncodeBinaryUnsigned(w *io.BinWriter)
- func (p Payload) GetChangeView() payload.ChangeView
- func (p Payload) GetCommit() payload.Commit
- func (p Payload) GetPrepareRequest() payload.PrepareRequest
- func (p Payload) GetPrepareResponse() payload.PrepareResponse
- func (p Payload) GetRecoveryMessage() payload.RecoveryMessage
- func (p Payload) GetRecoveryRequest() payload.RecoveryRequest
- func (p *Payload) Hash() util.Uint256
- func (p Payload) Height() uint32
- func (p Payload) MarshalUnsigned() []byte
- func (p Payload) Payload() interface{}
- func (p Payload) PrevHash() util.Uint256
- func (p *Payload) SetHeight(h uint32)
- func (p *Payload) SetPayload(pl interface{})
- func (p *Payload) SetPrevHash(h util.Uint256)
- func (p *Payload) SetType(t payload.MessageType)
- func (p *Payload) SetValidatorIndex(i uint16)
- func (p *Payload) SetVersion(v uint32)
- func (p *Payload) SetViewNumber(view byte)
- func (p *Payload) Sign(key *privateKey) error
- func (p Payload) Type() payload.MessageType
- func (p *Payload) UnmarshalUnsigned(data []byte) error
- func (p Payload) ValidatorIndex() uint16
- func (p *Payload) Verify(scriptHash util.Uint160) bool
- func (p Payload) Version() uint32
- func (p Payload) ViewNumber() byte
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Logger is a logger instance.
Logger *zap.Logger
// Broadcast is a callback which is called to notify server
// about new consensus payload to sent.
Broadcast func(cache.Hashable)
// Chain is a core.Blockchainer instance.
Chain core.Blockchainer
// RequestTx is a callback to which will be called
// when a node lacks transactions present in a block.
RequestTx func(h ...util.Uint256)
// TimePerBlock minimal time that should pass before next block is accepted.
TimePerBlock time.Duration
// Wallet is a local-node wallet configuration.
Wallet *wallet.Config
}
Config is a configuration for consensus services.
type Payload ¶
type Payload struct {
Witness transaction.Witness
// contains filtered or unexported fields
}
Payload is a type for consensus-related messages.
func (*Payload) DecodeBinary ¶
func (p *Payload) DecodeBinary(r *io.BinReader)
DecodeBinary implements io.Serializable interface.
func (*Payload) DecodeBinaryUnsigned ¶
func (p *Payload) DecodeBinaryUnsigned(r *io.BinReader)
DecodeBinaryUnsigned reads payload from w excluding signature.
func (*Payload) EncodeBinary ¶
func (p *Payload) EncodeBinary(w *io.BinWriter)
EncodeBinary implements io.Serializable interface.
func (*Payload) EncodeBinaryUnsigned ¶
func (p *Payload) EncodeBinaryUnsigned(w *io.BinWriter)
EncodeBinaryUnsigned writes payload to w excluding signature.
func (Payload) GetChangeView ¶
func (p Payload) GetChangeView() payload.ChangeView
GetChangeView implements payload.ConsensusPayload interface.
func (Payload) GetCommit ¶
func (p Payload) GetCommit() payload.Commit
GetCommit implements payload.ConsensusPayload interface.
func (Payload) GetPrepareRequest ¶
func (p Payload) GetPrepareRequest() payload.PrepareRequest
GetPrepareRequest implements payload.ConsensusPayload interface.
func (Payload) GetPrepareResponse ¶
func (p Payload) GetPrepareResponse() payload.PrepareResponse
GetPrepareResponse implements payload.ConsensusPayload interface.
func (Payload) GetRecoveryMessage ¶
func (p Payload) GetRecoveryMessage() payload.RecoveryMessage
GetRecoveryMessage implements payload.ConsensusPayload interface.
func (Payload) GetRecoveryRequest ¶
func (p Payload) GetRecoveryRequest() payload.RecoveryRequest
GetRecoveryRequest implements payload.ConsensusPayload interface.
func (*Payload) Hash ¶
func (p *Payload) Hash() util.Uint256
Hash implements payload.ConsensusPayload interface.
func (Payload) Height ¶
func (p Payload) Height() uint32
Height implements payload.ConsensusPayload interface.
func (Payload) MarshalUnsigned ¶
func (p Payload) MarshalUnsigned() []byte
MarshalUnsigned implements payload.ConsensusPayload interface.
func (Payload) Payload ¶
func (p Payload) Payload() interface{}
Payload implements payload.ConsensusPayload interface.
func (Payload) PrevHash ¶
func (p Payload) PrevHash() util.Uint256
PrevHash implements payload.ConsensusPayload interface.
func (*Payload) SetHeight ¶
func (p *Payload) SetHeight(h uint32)
SetHeight implements payload.ConsensusPayload interface.
func (*Payload) SetPayload ¶
func (p *Payload) SetPayload(pl interface{})
SetPayload implements payload.ConsensusPayload interface.
func (*Payload) SetPrevHash ¶
func (p *Payload) SetPrevHash(h util.Uint256)
SetPrevHash implements payload.ConsensusPayload interface.
func (*Payload) SetType ¶
func (p *Payload) SetType(t payload.MessageType)
SetType implements payload.ConsensusPayload interface.
func (*Payload) SetValidatorIndex ¶
func (p *Payload) SetValidatorIndex(i uint16)
SetValidatorIndex implements payload.ConsensusPayload interface.
func (*Payload) SetVersion ¶
func (p *Payload) SetVersion(v uint32)
SetVersion implements payload.ConsensusPayload interface.
func (*Payload) SetViewNumber ¶
func (p *Payload) SetViewNumber(view byte)
SetViewNumber implements payload.ConsensusPayload interface.
func (*Payload) Sign ¶
func (p *Payload) Sign(key *privateKey) error
Sign signs payload using the private key. It also sets corresponding verification and invocation scripts.
func (Payload) Type ¶
func (p Payload) Type() payload.MessageType
Type implements payload.ConsensusPayload interface.
func (*Payload) UnmarshalUnsigned ¶
func (p *Payload) UnmarshalUnsigned(data []byte) error
UnmarshalUnsigned implements payload.ConsensusPayload interface.
func (Payload) ValidatorIndex ¶
func (p Payload) ValidatorIndex() uint16
ValidatorIndex implements payload.ConsensusPayload interface.
func (*Payload) Verify ¶
func (p *Payload) Verify(scriptHash util.Uint160) bool
Verify verifies payload using provided Witness.
func (Payload) Version ¶
func (p Payload) Version() uint32
Version implements payload.ConsensusPayload interface.
func (Payload) ViewNumber ¶
func (p Payload) ViewNumber() byte
ViewNumber implements payload.ConsensusPayload interface.
type Service ¶
type Service interface {
// Start initializes dBFT and starts event loop for consensus service.
// It must be called only when sufficient amount of peers are connected.
Start()
// OnPayload is a callback to notify Service about new received payload.
OnPayload(p *Payload)
// OnTransaction is a callback to notify Service about new received transaction.
OnTransaction(tx *transaction.Transaction)
// GetPayload returns Payload with specified hash if it is present in the local cache.
GetPayload(h util.Uint256) *Payload
}
Service represents consensus instance.
func NewService ¶
func NewService(cfg Config) (Service, error)
NewService returns new consensus.Service instance.