) // PrivKey is part of PrivAccount and state.PrivValidator. type PrivKey interface { Sign(msg []byte) Signature PubKey() PubKey } // Types of PrivKey implementations const ( PrivKeyTypeEd25519 = byte(0x01) ) // for binary.readReflect var _ = binary.RegisterInterface( struct{ PrivKey }{}, binary.ConcreteType{PrivKeyEd25519{}, PrivKeyTypeEd25519}, ) //------------------------------------- // Implements PrivKey type PrivKeyEd25519 []byte func (key PrivKeyEd25519) Sign(msg []byte) Signature { pubKey := key.PubKey().(PubKeyEd25519) keyBytes := new([64]byte) copy(keyBytes[:32], key[:]) copy(keyBytes[32:], pubKey[:]) signatureBytes := ed25519.Sign(keyBytes, msg) return SignatureEd25519(signatureBytes[:]) }
msgTypeNewRoundStep = byte(0x01) msgTypeCommitStep = byte(0x02) msgTypeProposal = byte(0x11) msgTypeProposalPOL = byte(0x12) msgTypeBlockPart = byte(0x13) // both block & POL msgTypeVote = byte(0x14) msgTypeHasVote = byte(0x15) ) type ConsensusMessage interface{} var _ = binary.RegisterInterface( struct{ ConsensusMessage }{}, binary.ConcreteType{&NewRoundStepMessage{}, msgTypeNewRoundStep}, binary.ConcreteType{&CommitStepMessage{}, msgTypeCommitStep}, binary.ConcreteType{&ProposalMessage{}, msgTypeProposal}, binary.ConcreteType{&ProposalPOLMessage{}, msgTypeProposalPOL}, binary.ConcreteType{&BlockPartMessage{}, msgTypeBlockPart}, 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 {
//----------------------------------------------------------------------------- // 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 {
"github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/binary" . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/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)) }
// 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 }
TxTypeCall = byte(0x02) TxTypeName = byte(0x03) // 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{&NameTx{}, TxTypeName}, 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 int64 `json:"amount"` // Must not exceed account balance Sequence int `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 }