//----------------------------------------------------------------------------- // Messages const ( msgTypeBlockRequest = byte(0x10) msgTypeBlockResponse = byte(0x11) msgTypeStatusResponse = byte(0x20) msgTypeStatusRequest = byte(0x21) ) type BlockchainMessage interface{} var _ = binary.RegisterInterface( struct{ BlockchainMessage }{}, binary.ConcreteType{&bcBlockRequestMessage{}, msgTypeBlockRequest}, binary.ConcreteType{&bcBlockResponseMessage{}, msgTypeBlockResponse}, binary.ConcreteType{&bcStatusResponseMessage{}, msgTypeStatusResponse}, binary.ConcreteType{&bcStatusRequestMessage{}, msgTypeStatusRequest}, ) func DecodeMessage(bz []byte) (msgType byte, msg BlockchainMessage, err error) { msgType = bz[0] n := new(int64) r := bytes.NewReader(bz) msg = binary.ReadBinary(struct{ BlockchainMessage }{}, r, n, &err).(struct{ BlockchainMessage }).BlockchainMessage return } //------------------------------------- type bcBlockRequestMessage struct {
TxTypeSend = byte(0x01) TxTypeCall = byte(0x02) // Validation transactions TxTypeBond = byte(0x11) TxTypeUnbond = byte(0x12) TxTypeRebond = byte(0x13) TxTypeDupeout = byte(0x14) ) // for binary.readReflect var _ = binary.RegisterInterface( struct{ Tx }{}, binary.ConcreteType{&SendTx{}, TxTypeSend}, binary.ConcreteType{&CallTx{}, TxTypeCall}, binary.ConcreteType{&BondTx{}, TxTypeBond}, binary.ConcreteType{&UnbondTx{}, TxTypeUnbond}, binary.ConcreteType{&RebondTx{}, TxTypeRebond}, binary.ConcreteType{&DupeoutTx{}, TxTypeDupeout}, ) //----------------------------------------------------------------------------- type TxInput struct { Address []byte `json:"address"` // Hash of the PubKey Amount uint64 `json:"amount"` // Must not exceed account balance Sequence uint `json:"sequence"` // Must be 1 greater than the last committed TxInput Signature account.Signature `json:"signature"` // Depends on the PubKey type and the whole Tx PubKey account.PubKey `json:"pub_key"` // Must not be nil, may be nil }
// implements events.Eventable func (memR *MempoolReactor) SetFireable(evsw events.Fireable) { memR.evsw = evsw } //----------------------------------------------------------------------------- // Messages const ( msgTypeTx = byte(0x01) ) type MempoolMessage interface{} var _ = binary.RegisterInterface( struct{ MempoolMessage }{}, binary.ConcreteType{&TxMessage{}, msgTypeTx}, ) func DecodeMessage(bz []byte) (msgType byte, msg MempoolMessage, err error) { msgType = bz[0] n := new(int64) r := bytes.NewReader(bz) msg = binary.ReadBinary(struct{ MempoolMessage }{}, r, n, &err).(struct{ MempoolMessage }).MempoolMessage return } //------------------------------------- type TxMessage struct { Tx types.Tx }
const ( msgTypeNewRoundStep = byte(0x01) msgTypeCommitStep = byte(0x02) msgTypeProposal = byte(0x11) msgTypePart = byte(0x12) // both block & POL msgTypeVote = byte(0x13) msgTypeHasVote = byte(0x14) ) type ConsensusMessage interface{} var _ = binary.RegisterInterface( struct{ ConsensusMessage }{}, binary.ConcreteType{&NewRoundStepMessage{}, msgTypeNewRoundStep}, binary.ConcreteType{&CommitStepMessage{}, msgTypeCommitStep}, binary.ConcreteType{&ProposalMessage{}, msgTypeProposal}, binary.ConcreteType{&PartMessage{}, msgTypePart}, binary.ConcreteType{&VoteMessage{}, msgTypeVote}, binary.ConcreteType{&HasVoteMessage{}, msgTypeHasVote}, ) // TODO: check for unnecessary extra bytes at the end. func DecodeMessage(bz []byte) (msgType byte, msg ConsensusMessage, err error) { msgType = bz[0] n := new(int64) r := bytes.NewReader(bz) msg = binary.ReadBinary(struct{ ConsensusMessage }{}, r, n, &err).(struct{ ConsensusMessage }).ConsensusMessage return } //-------------------------------------
pexR.evsw = evsw } //----------------------------------------------------------------------------- // Messages const ( msgTypeRequest = byte(0x01) msgTypeAddrs = byte(0x02) ) type PexMessage interface{} var _ = binary.RegisterInterface( struct{ PexMessage }{}, binary.ConcreteType{&pexRequestMessage{}, msgTypeRequest}, binary.ConcreteType{&pexAddrsMessage{}, msgTypeAddrs}, ) func DecodeMessage(bz []byte) (msgType byte, msg PexMessage, err error) { msgType = bz[0] n := new(int64) r := bytes.NewReader(bz) msg = binary.ReadBinary(struct{ PexMessage }{}, r, n, &err).(struct{ PexMessage }).PexMessage return } /* A pexRequestMessage requests additional peer addresses. */ type pexRequestMessage struct {
"github.com/tendermint/tendermint/binary" . "github.com/tendermint/tendermint/common" ) // Signature is a part of Txs and consensus Votes. type Signature interface { } // Types of Signature implementations const ( SignatureTypeEd25519 = byte(0x01) ) // for binary.readReflect var _ = binary.RegisterInterface( struct{ Signature }{}, binary.ConcreteType{SignatureEd25519{}, SignatureTypeEd25519}, ) //------------------------------------- // Implements Signature type SignatureEd25519 []byte func (sig SignatureEd25519) IsNil() bool { return false } func (sig SignatureEd25519) IsZero() bool { return len(sig) == 0 } func (sig SignatureEd25519) String() string { return fmt.Sprintf("%X", Fingerprint(sig)) }
} type Command interface{} const ( commandTypeRunProcess = 0x01 commandTypeStopProcess = 0x02 commandTypeListProcesses = 0x03 commandTypeServeFile = 0x04 ) // for binary.readReflect var _ = binary.RegisterInterface( struct{ Command }{}, binary.ConcreteType{CommandRunProcess{}, commandTypeRunProcess}, binary.ConcreteType{CommandStopProcess{}, commandTypeStopProcess}, binary.ConcreteType{CommandListProcesses{}, commandTypeListProcesses}, binary.ConcreteType{CommandServeFile{}, commandTypeServeFile}, ) type CommandRunProcess struct { Wait bool Label string ExecPath string Args []string Input string } type CommandStopProcess struct { Label string Kill bool