Documentation ¶
Overview ¶
Package wire implements the bitcoin wire protocol.
For the complete details of the bitcoin protocol, see the official wiki entry at https://en.bitcoin.it/wiki/Protocol_specification. The following only serves as a quick overview to provide information on how to use the package.
At a high level, this package provides support for marshalling and unmarshalling supported bitcoin messages to and from the wire. This package does not deal with the specifics of message handling such as what to do when a message is received. This provides the caller with a high level of flexibility.
Bitcoin Message Overview ¶
The bitcoin protocol consists of exchanging messages between peers. Each message is preceded by a header which identifies information about it such as which bitcoin network it is a part of, its type, how big it is, and a checksum to verify validity. All encoding and decoding of message headers is handled by this package.
To accomplish this, there is a generic interface for bitcoin messages named Message which allows messages of any type to be read, written, or passed around through channels, functions, etc. In addition, concrete implementations of most of the currently supported bitcoin messages are provided. For these supported messages, all of the details of marshalling and unmarshalling to and from the wire using bitcoin encoding are handled so the caller doesn't have to concern themselves with the specifics.
Message Interaction ¶
The following provides a quick summary of how the bitcoin messages are intended to interact with one another. As stated above, these interactions are not directly handled by this package. For more in-depth details about the appropriate interactions, see the official bitcoin protocol wiki entry at https://en.bitcoin.it/wiki/Protocol_specification.
The initial handshake consists of two peers sending each other a version message (MsgVersion) followed by responding with a verack message (MsgVerAck). Both peers use the information in the version message (MsgVersion) to negotiate things such as protocol version and supported services with each other. Once the initial handshake is complete, the following chart indicates message interactions in no particular order.
Peer A Sends Peer B Responds ---------------------------------------------------------------------------- getaddr message (MsgGetAddr) addr message (MsgAddr) getblocks message (MsgGetBlocks) inv message (MsgInv) inv message (MsgInv) getdata message (MsgGetData) getdata message (MsgGetData) block message (MsgBlock) -or- tx message (MsgTx) -or- notfound message (MsgNotFound) getheaders message (MsgGetHeaders) headers message (MsgHeaders) ping message (MsgPing) pong message (MsgHeaders)* -or- (none -- Ability to send message is enough) NOTES: * The pong message was not added until later protocol versions as defined in BIP0031. The BIP0031Version constant can be used to detect a recent enough protocol version for this purpose (version > BIP0031Version).
Common Parameters ¶
There are several common parameters that arise when using this package to read and write bitcoin messages. The following sections provide a quick overview of these parameters so the next sections can build on them.
Protocol Version ¶
The protocol version should be negotiated with the remote peer at a higher level than this package via the version (MsgVersion) message exchange, however, this package provides the wire.ProtocolVersion constant which indicates the latest protocol version this package supports and is typically the value to use for all outbound connections before a potentially lower protocol version is negotiated.
Bitcoin Network ¶
The bitcoin network is a magic number which is used to identify the start of a message and which bitcoin network the message applies to. This package provides the following constants:
wire.MainNet wire.TestNet (Regression test network) wire.TestNet3 (Test network version 3) wire.SimNet (Simulation test network)
Determining Message Type ¶
As discussed in the bitcoin message overview section, this package reads and writes bitcoin messages using a generic interface named Message. In order to determine the actual concrete type of the message, use a type switch or type assertion. An example of a type switch follows:
// Assumes msg is already a valid concrete message such as one created // via NewMsgVersion or read via ReadMessage. switch msg := msg.(type) { case *wire.MsgVersion: // The message is a pointer to a MsgVersion struct. fmt.Printf("Protocol version: %v", msg.ProtocolVersion) case *wire.MsgBlock: // The message is a pointer to a MsgBlock struct. fmt.Printf("Number of tx in block: %v", msg.Header.TxnCount) }
Reading Messages ¶
In order to unmarshall bitcoin messages from the wire, use the ReadMessage function. It accepts any io.Reader, but typically this will be a net.Conn to a remote node running a bitcoin peer. Example syntax is:
// Reads and validates the next bitcoin message from conn using the // protocol version pver and the bitcoin network btcnet. The returns // are a wire.Message, a []byte which contains the unmarshalled // raw payload, and a possible error. msg, rawPayload, err := wire.ReadMessage(conn, pver, btcnet) if err != nil { // Log and handle the error }
Writing Messages ¶
In order to marshall bitcoin messages to the wire, use the WriteMessage function. It accepts any io.Writer, but typically this will be a net.Conn to a remote node running a bitcoin peer. Example syntax to request addresses from a remote peer is:
// Create a new getaddr bitcoin message. msg := wire.NewMsgGetAddr() // Writes a bitcoin message msg to conn using the protocol version // pver, and the bitcoin network btcnet. The return is a possible // error. err := wire.WriteMessage(conn, msg, pver, btcnet) if err != nil { // Log and handle the error }
Errors ¶
Errors returned by this package are either the raw errors provided by underlying calls to read/write from streams such as io.EOF, io.ErrUnexpectedEOF, and io.ErrShortWrite, or of type wire.MessageError. This allows the caller to differentiate between general IO errors and malformed messages through type assertions.
Bitcoin Improvement Proposals ¶
This package includes spec changes outlined by the following BIPs:
BIP0014 (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) BIP0031 (https://github.com/bitcoin/bips/blob/master/bip-0031.mediawiki) BIP0035 (https://github.com/bitcoin/bips/blob/master/bip-0035.mediawiki) BIP0037 (https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki) BIP0111 (https://github.com/bitcoin/bips/blob/master/bip-0111.mediawiki) BIP0130 (https://github.com/bitcoin/bips/blob/master/bip-0130.mediawiki) BIP0133 (https://github.com/bitcoin/bips/blob/master/bip-0133.mediawiki)
Index ¶
- Constants
- Variables
- func GetMtvValueFromOut(op *OutPoint) *big.Int
- func MakeMessageHash(msg Message, pver uint32, btcnet BitcoinNet) chainhash.Hash
- func MsgShouldRelay(msg Message) bool
- func MtvValueToData(value *big.Int) []byte
- func RandomUint64() (uint64, error)
- func ReadVarBytes(r io.Reader, pver uint32, maxAllowed uint32, fieldName string) ([]byte, error)
- func ReadVarInt(r io.Reader, pver uint32) (uint64, error)
- func ReadVarString(r io.Reader, pver uint32) (string, error)
- func UnspentOutHash(o *OutPoint) *merkle.MerkleHash
- func VarIntSerializeSize(val uint64) int
- func WriteMessage(w io.Writer, msg Message, pver uint32, btcnet BitcoinNet) error
- func WriteMessageN(w io.Writer, msg Message, pver uint32, btcnet BitcoinNet) (int, error)
- func WriteMessageWithEncodingN(w io.Writer, msg Message, pver uint32, btcnet BitcoinNet, ...) (int, error)
- func WriteVarBytes(w io.Writer, pver uint32, bytes []byte) error
- func WriteVarInt(w io.Writer, pver uint32, val uint64) error
- func WriteVarString(w io.Writer, pver uint32, str string) error
- type Alert
- type BitcoinNet
- type BlockBody
- type BlockHeader
- func (h BlockHeader) BlockHeaderHash() chainhash.Hash
- func (h *BlockHeader) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (h *BlockHeader) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (h *BlockHeader) Command() string
- func (h *BlockHeader) Deserialize(r io.Reader) error
- func (h *BlockHeader) GetShardIndex() shard.Index
- func (h *BlockHeader) IsEqualTo(header *BlockHeader) bool
- func (h *BlockHeader) MaxPayloadLength(pver uint32) uint32
- func (h *BlockHeader) Serialize(w io.Writer) error
- func (h *BlockHeader) String() string
- func (h *BlockHeader) ToBytesArray() []byte
- type BlockHeight
- type BlockLocator
- type BloomUpdateType
- type ByzAgreementValue
- type ClipTreeData
- type ConsensusMsg
- type Credential
- type CredentialWithBA
- type GCMessage
- func (m *GCMessage) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (m *GCMessage) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (GCMessage) Command() string
- func (m *GCMessage) GetByzAgreementValue() *ByzAgreementValue
- func (m *GCMessage) GetInShardProofs() [][]byte
- func (m *GCMessage) GetRound() int
- func (m *GCMessage) GetShardIndex() shard.Index
- func (m *GCMessage) GetSignedCredential() *SignedMsg
- func (m *GCMessage) GetStep() int
- func (m *GCMessage) IsValidated() (err error)
- func (GCMessage) MaxPayloadLength(uint32) uint32
- func (m *GCMessage) Sign(sk []byte) (err error)
- func (m *GCMessage) String() string
- type HeartBeatMsg
- func (msg *HeartBeatMsg) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *HeartBeatMsg) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *HeartBeatMsg) Command() string
- func (msg *HeartBeatMsg) Deserialize(r io.Reader) error
- func (msg *HeartBeatMsg) MaxPayloadLength(pver uint32) uint32
- func (msg *HeartBeatMsg) Serialize(w io.Writer) error
- type InvGroup
- type InvType
- type InvVect
- type LeaderProposalMessage
- func (msg *LeaderProposalMessage) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (msg *LeaderProposalMessage) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (msg *LeaderProposalMessage) Command() string
- func (msg *LeaderProposalMessage) GetInShardProofs() [][]byte
- func (msg *LeaderProposalMessage) GetRound() int
- func (msg *LeaderProposalMessage) GetShardIndex() shard.Index
- func (msg *LeaderProposalMessage) GetSignedCredential() *SignedMsg
- func (msg *LeaderProposalMessage) GetStep() int
- func (msg *LeaderProposalMessage) IsValidated() error
- func (msg *LeaderProposalMessage) MaxPayloadLength(_ uint32) uint32
- func (msg *LeaderProposalMessage) Sign(sk []byte) (err error)
- func (msg *LeaderProposalMessage) String() string
- type LeaderVoteMessage
- func (m *LeaderVoteMessage) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (m *LeaderVoteMessage) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (m *LeaderVoteMessage) Command() string
- func (m *LeaderVoteMessage) GetByzAgreementValue() *ByzAgreementValue
- func (m *LeaderVoteMessage) GetInShardProofs() [][]byte
- func (m *LeaderVoteMessage) GetRound() int
- func (m *LeaderVoteMessage) GetShardIndex() shard.Index
- func (m *LeaderVoteMessage) GetSignedCredential() *SignedMsg
- func (m *LeaderVoteMessage) GetStep() int
- func (m *LeaderVoteMessage) IsValidated() (err error)
- func (m *LeaderVoteMessage) MaxPayloadLength(_ uint32) uint32
- func (m *LeaderVoteMessage) Sign(sk []byte) (err error)
- func (m *LeaderVoteMessage) String() string
- type LedgerInfo
- type MTVCoinData
- type MTVDepositData
- type MTVWithdrawData
- type Message
- func ReadMessage(r io.Reader, pver uint32, btcnet BitcoinNet) (Message, []byte, error)
- func ReadMessageN(r io.Reader, pver uint32, btcnet BitcoinNet) (int, Message, []byte, error)
- func ReadMessageWithEncodingN(r io.Reader, pver uint32, btcnet BitcoinNet, enc MessageEncoding) (int, Message, []byte, error)
- type MessageEncoding
- type MessageError
- type MsgAddr
- func (msg *MsgAddr) AddAddress(na *NetAddress) error
- func (msg *MsgAddr) AddAddresses(netAddrs ...*NetAddress) error
- func (msg *MsgAddr) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgAddr) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgAddr) ClearAddresses()
- func (msg *MsgAddr) Command() string
- func (msg *MsgAddr) MaxPayloadLength(pver uint32) uint32
- type MsgAlert
- type MsgBinaryBA
- func (m *MsgBinaryBA) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (m *MsgBinaryBA) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (m *MsgBinaryBA) Command() string
- func (m *MsgBinaryBA) GetBValue() byte
- func (m *MsgBinaryBA) GetByzAgreementValue() ByzAgreementValue
- func (m *MsgBinaryBA) GetInShardProofs() [][]byte
- func (m *MsgBinaryBA) GetRawB() []byte
- func (m *MsgBinaryBA) GetRawV() []byte
- func (m *MsgBinaryBA) GetRound() int
- func (m *MsgBinaryBA) GetShardIndex() shard.Index
- func (m *MsgBinaryBA) GetSignedCredential() *SignedMsg
- func (m *MsgBinaryBA) GetStep() int
- func (m *MsgBinaryBA) IsValidated() error
- func (m *MsgBinaryBA) MaxPayloadLength(uint32) uint32
- func (m *MsgBinaryBA) Sign(sk []byte) (err error)
- func (m MsgBinaryBA) String() string
- type MsgBinaryBAFin
- type MsgBlock
- func (m *MsgBlock) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (m *MsgBlock) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (m *MsgBlock) Command() string
- func (m *MsgBlock) Deserialize(r io.Reader) error
- func (m *MsgBlock) GetShardIndex() shard.Index
- func (m *MsgBlock) MaxPayloadLength(pver uint32) uint32
- func (m *MsgBlock) Serialize(w io.Writer) error
- func (m *MsgBlock) SerializeNoWitness(w io.Writer) error
- func (m *MsgBlock) SerializeSize() int
- func (m *MsgBlock) SerializeSizeStripped() int
- func (m *MsgBlock) String() string
- type MsgBlockConfirmation
- func (msg *MsgBlockConfirmation) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (msg *MsgBlockConfirmation) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (msg *MsgBlockConfirmation) Command() string
- func (msg *MsgBlockConfirmation) GetByzAgreementValue() ByzAgreementValue
- func (msg *MsgBlockConfirmation) GetInShardProofs() [][]byte
- func (msg *MsgBlockConfirmation) GetRawV() []byte
- func (msg *MsgBlockConfirmation) GetRound() int
- func (msg *MsgBlockConfirmation) GetShardIndex() shard.Index
- func (msg *MsgBlockConfirmation) GetSignedCredential() *SignedMsg
- func (msg *MsgBlockConfirmation) GetStep() int
- func (msg *MsgBlockConfirmation) GetVoters() [][]byte
- func (msg *MsgBlockConfirmation) IsValidated() error
- func (msg *MsgBlockConfirmation) MaxPayloadLength(uint32) uint32
- func (msg *MsgBlockConfirmation) String() string
- type MsgFeeFilter
- type MsgFetchDeposit
- func (msg *MsgFetchDeposit) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgFetchDeposit) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgFetchDeposit) Command() string
- func (msg *MsgFetchDeposit) GetShardIndex() shard.Index
- func (msg *MsgFetchDeposit) MaxPayloadLength(pver uint32) uint32
- type MsgFetchEncode
- type MsgFetchInit
- func (m *MsgFetchInit) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (m *MsgFetchInit) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (m *MsgFetchInit) Command() string
- func (m *MsgFetchInit) GetShardIndex() shard.Index
- func (m *MsgFetchInit) MaxPayloadLength(pver uint32) uint32
- type MsgFetchSmartContractInfo
- func (msg *MsgFetchSmartContractInfo) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgFetchSmartContractInfo) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgFetchSmartContractInfo) Command() string
- func (msg *MsgFetchSmartContractInfo) GetShardIndex() shard.Index
- func (msg *MsgFetchSmartContractInfo) MaxPayloadLength(pver uint32) uint32
- type MsgFetchTxs
- func (m *MsgFetchTxs) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (m *MsgFetchTxs) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (m *MsgFetchTxs) Command() string
- func (m *MsgFetchTxs) GetShardIndex() shard.Index
- func (m *MsgFetchTxs) MaxPayloadLength(pver uint32) uint32
- type MsgFilterAdd
- type MsgFilterClear
- type MsgFilterLoad
- type MsgGetAddr
- type MsgGetShardAddr
- type MsgPing
- type MsgPong
- type MsgReSendSyncReq
- type MsgReject
- type MsgReturnDeposit
- type MsgReturnInit
- func (msg *MsgReturnInit) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgReturnInit) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgReturnInit) Command() string
- func (msg *MsgReturnInit) GetShardIndex() shard.Index
- func (msg *MsgReturnInit) MaxPayloadLength(pver uint32) uint32
- type MsgReturnShardAddr
- type MsgReturnTxs
- func (msg *MsgReturnTxs) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgReturnTxs) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgReturnTxs) Command() string
- func (msg *MsgReturnTxs) GetShardIndex() shard.Index
- func (msg *MsgReturnTxs) MaxPayloadLength(pver uint32) uint32
- type MsgSeed
- func (m *MsgSeed) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (m *MsgSeed) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (m *MsgSeed) Command() string
- func (m *MsgSeed) GetInShardProofs() [][]byte
- func (m *MsgSeed) GetRound() int
- func (m *MsgSeed) GetSender() []byte
- func (m *MsgSeed) GetShardIndex() shard.Index
- func (m *MsgSeed) GetSignedCredential() *SignedMsg
- func (m *MsgSeed) GetStep() int
- func (m *MsgSeed) IsValidated() error
- func (m *MsgSeed) MaxPayloadLength(uint32) uint32
- func (m *MsgSeed) Sign(sk []byte) error
- type MsgSendHeaders
- type MsgStartNet
- type MsgSyncBlock
- func (msg *MsgSyncBlock) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (msg *MsgSyncBlock) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (msg *MsgSyncBlock) Command() string
- func (msg *MsgSyncBlock) GetShardIndex() shard.Index
- func (msg *MsgSyncBlock) MaxPayloadLength(uint32) uint32
- type MsgSyncHeaders
- func (msg *MsgSyncHeaders) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (msg *MsgSyncHeaders) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (msg *MsgSyncHeaders) Command() string
- func (msg *MsgSyncHeaders) GetShardIndex() shard.Index
- func (msg *MsgSyncHeaders) MaxPayloadLength(uint32) uint32
- type MsgSyncInv
- func (msg *MsgSyncInv) AddInvGroup(shardIdx shard.Index, hashes ...chainhash.Hash)
- func (msg *MsgSyncInv) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (msg *MsgSyncInv) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (msg *MsgSyncInv) Command() string
- func (msg *MsgSyncInv) GetShardIndex() shard.Index
- func (msg *MsgSyncInv) MaxPayloadLength(uint32) uint32
- func (msg *MsgSyncInv) String() string
- type MsgSyncReq
- func (msg *MsgSyncReq) AddBlockLocator(shardIdx shard.Index, fromHeight int64, toHeight int64)
- func (msg *MsgSyncReq) AddBlockLocatorToRecent(shardIdx shard.Index, fromHeight int64)
- func (msg *MsgSyncReq) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (msg *MsgSyncReq) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (msg *MsgSyncReq) Command() string
- func (msg *MsgSyncReq) GetShardIndex() shard.Index
- func (msg *MsgSyncReq) MaxPayloadLength(uint32) uint32
- func (msg *MsgSyncReq) String() string
- type MsgSyncSlimBlock
- func (msg *MsgSyncSlimBlock) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (msg *MsgSyncSlimBlock) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (msg *MsgSyncSlimBlock) Command() string
- func (msg *MsgSyncSlimBlock) GetShardIndex() shard.Index
- func (msg *MsgSyncSlimBlock) MaxPayloadLength(uint32) uint32
- type MsgTx
- func (tx *MsgTx) AddTxIn(ti *TxIn)
- func (tx *MsgTx) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (tx *MsgTx) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (tx *MsgTx) Command() string
- func (tx *MsgTx) Deserialize(r io.Reader) error
- func (tx *MsgTx) GetFee() (*big.Int, error)
- func (tx *MsgTx) GetShardForTx() shard.Index
- func (tx *MsgTx) IsEnoughForReward() bool
- func (tx *MsgTx) IsReduceTx() bool
- func (tx *MsgTx) IsRewardTx() bool
- func (tx *MsgTx) IsSmartContractTx() bool
- func (tx *MsgTx) IsTxInShard(shardIndex shard.Index) bool
- func (tx *MsgTx) MaxPayloadLength(pver uint32) uint32
- func (tx *MsgTx) Serialize(w io.Writer) error
- func (tx *MsgTx) SerializeSize() int
- func (tx *MsgTx) SerializeSizeStripped() int
- func (tx MsgTx) SerializeWithoutSignatureAndPubKey() []byte
- func (tx *MsgTx) SetSignatureScriptAndPubKey(publicKey signature.PublicKey, sig []byte)
- func (tx *MsgTx) Sign(privateKey *signature.PrivateKey)
- func (tx MsgTx) TotalMtvValue() *big.Int
- func (tx *MsgTx) TxHash() chainhash.Hash
- func (tx *MsgTx) VerifySignature() bool
- func (tx *MsgTx) VerifyTransaction() error
- func (tx *MsgTx) VerifyWithdrawTx(blockHeight int64) error
- type MsgTxBatch
- func (msg *MsgTxBatch) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (msg *MsgTxBatch) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (msg *MsgTxBatch) Command() string
- func (msg *MsgTxBatch) GetShardIndex() shard.Index
- func (msg *MsgTxBatch) MaxPayloadLength(_ uint32) uint32
- func (msg *MsgTxBatch) String() string
- type MsgTxWithProofs
- func (msg *MsgTxWithProofs) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (msg *MsgTxWithProofs) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (msg *MsgTxWithProofs) Command() string
- func (msg *MsgTxWithProofs) Deserialize(r io.Reader) error
- func (msg *MsgTxWithProofs) MaxPayloadLength(_ uint32) uint32
- func (msg *MsgTxWithProofs) Serialize(w io.Writer) error
- func (msg *MsgTxWithProofs) ToBytesArray() []byte
- func (msg *MsgTxWithProofs) VerifyTxWithProof(ledgerMerkleRoot *merkle.MerkleHash) error
- type MsgVerAck
- type MsgVersion
- func (msg *MsgVersion) AddService(service ServiceFlag)
- func (msg *MsgVersion) AddUserAgent(name string, version string, comments ...string) error
- func (msg *MsgVersion) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *MsgVersion) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *MsgVersion) Command() string
- func (msg *MsgVersion) HasService(service ServiceFlag) bool
- func (msg *MsgVersion) MaxPayloadLength(pver uint32) uint32
- type NetAddress
- type NewRoundStartMessage
- func (msg *NewRoundStartMessage) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (msg *NewRoundStartMessage) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (msg *NewRoundStartMessage) Command() string
- func (msg *NewRoundStartMessage) GetRound() int
- func (msg *NewRoundStartMessage) MaxPayloadLength(_ uint32) uint32
- type OutPoint
- func (o *OutPoint) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (o *OutPoint) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (o *OutPoint) Deserialize(r io.Reader) error
- func (o *OutPoint) IsBindingLock(height int64) bool
- func (o *OutPoint) IsDepositOut() bool
- func (o *OutPoint) IsLock(height int64) bool
- func (o *OutPoint) IsSmartContractCode() bool
- func (o *OutPoint) IsSmartContractShardInitOut() bool
- func (o *OutPoint) IsWithdrawOut() bool
- func (o *OutPoint) Serialize(w io.Writer) error
- func (o *OutPoint) String() string
- func (o *OutPoint) ToSpentOutState() *OutState
- func (o *OutPoint) ToUnspentOutState() *OutState
- type OutState
- type OutType
- type OutWithProof
- type ReduceAction
- type RejectCode
- type RelayHashMsg
- func (msg *RelayHashMsg) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (msg *RelayHashMsg) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
- func (msg *RelayHashMsg) Command() string
- func (msg *RelayHashMsg) Deserialize(r io.Reader) error
- func (msg *RelayHashMsg) MaxPayloadLength(pver uint32) uint32
- func (msg *RelayHashMsg) Serialize(w io.Writer) error
- type Serializable
- type ServiceFlag
- type ShardMessage
- type SignedMsg
- type SlimBlock
- func (m *SlimBlock) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
- func (m *SlimBlock) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (m *SlimBlock) Command() string
- func (m *SlimBlock) GetShardIndex() shard.Index
- func (m *SlimBlock) MaxPayloadLength(pver uint32) uint32
- type SmartContract
- type SmartContractInfo
- func (msg *SmartContractInfo) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (msg *SmartContractInfo) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (msg *SmartContractInfo) Command() string
- func (msg *SmartContractInfo) MaxPayloadLength(uint32) uint32
- func (msg *SmartContractInfo) Verify(root *merkle.MerkleHash) error
- type SyncInvType
- type Timestamp
- type TxIn
- type UpdateAction
- type UpdatePeerInfoMessage
- func (msg *UpdatePeerInfoMessage) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
- func (msg *UpdatePeerInfoMessage) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
- func (msg *UpdatePeerInfoMessage) Command() string
- func (msg *UpdatePeerInfoMessage) GetShards() []shard.Index
- func (msg *UpdatePeerInfoMessage) MaxPayloadLength(_ uint32) uint32
Constants ¶
const ( InvTypeError InvType = 0 InvTypeTx InvType = 1 InvTypeBlock InvType = 2 InvTypeFilteredBlock InvType = 3 InvTypeMultiVac InvType = 4 InvTypeWitnessBlock = InvTypeBlock | InvWitnessFlag InvTypeWitnessTx = InvTypeTx | InvWitnessFlag InvTypeFilteredWitnessBlock = InvTypeFilteredBlock | InvWitnessFlag )
These constants define the various supported inventory vector types.
const ( // Cmd string size limit is 12!!! CmdVersion = "version" CmdVerAck = "verack" CmdGetAddr = "getaddr" CmdAddr = "addr" CmdBlock = "block" CmdBlockHeader = "blockheader" CmdSlimBlock = "slimblock" CmdTx = "tx" CmdTxWithProofs = "txwithproofs" CmdHeartBeat = "heartbeat" CmdRelayHash = "relayhash" CmdFetchTxs = "fetchtxs" CmdReturnTxs = "returntxs" CmdFetchDeposit = "fetchdeposit" CmdInitAbciData = "initabcdata" CmdReturnInit = "returninit" CmdReturnDeposit = "returndep" CmdPing = "ping" CmdPong = "pong" CmdAlert = "alert" CmdFilterAdd = "filteradd" CmdFilterClear = "filterclear" CmdFilterLoad = "filterload" CmdReject = "reject" CmdSendHeaders = "sendheaders" CmdFeeFilter = "feefilter" CmdNewRoundStart = "new_round" CmdLeaderProposal = "lead_prevote" CmdLeaderVote = "lead_commit" CmdGC = "gc" CmdBinaryBA = "bba" CmdBinaryBAFin = "bbafin" CmdMsgBlockConfirmation = "blockconfrm" CmdSeed = "seed" CmdStartNet = "startnet" CmdGetShardAddr = "getshardaddr" CmdReturnAddr = "returnaddr" CmdUpdatePeerInfo = "update_peer" CmdTxBatch = "tx_batch" CmdSmartContractInfo = "smartCInfo" CmdFetchSmartContractInfo = "fetchSCInfo" // Sync relevant messages CmdSyncReq = "syncreq" CmdSyncInv = "syncinv" CmdReSendSyncreq = "resendsync" CmdSyncBlock = "syncblock" CmdSyncSlimBlock = "syncslblock" CmdSyncHeaders = "syncheaders" )
Commands used in bitcoin message headers which describe the type of message.
const ( // SyncInvTypeFullList is to sync inventory full list. SyncInvTypeFullList = iota // SyncInvTypeGetData is to sync inventory data. SyncInvTypeGetData )
const ( // MsgSyncReqMaxPayload is a very arbitrary number MsgSyncReqMaxPayload = 4000000 // DefaultShardCapacity defines the default shard capacity. // TODO(huangsz): Make this to be loaded from genesis DefaultShardCapacity = 64 // ReqSyncToLatest defines whether request to the last. ReqSyncToLatest = -1 )
const ( // MaxFilterLoadHashFuncs is the maximum number of hash functions to // load into the Bloom filter. MaxFilterLoadHashFuncs = 50 // MaxFilterLoadFilterSize is the maximum size in bytes a filter may be. MaxFilterLoadFilterSize = 36000 )
const ( // TxVersion is the current latest supported transaction version. TxVersion = 1 // StateUnused is state of an out point. Not using boolean because there will be special types // of transactions and outs which will have more than 2 states. StateUnused byte = 0 // StateUsed is state of an out point. StateUsed byte = 1 // DepositOut is type of deposit DepositOut OutType = iota // WithdrawOut is type of withdraw WithdrawOut // Binding is type of binding Binding // Transfer is type of transfer out Transfer // WithdrawHeight is deposit withdraw lock height WithdrawHeight = 200 // BindingLockHeight is binding tx locking duration BindingLockHeight = 20 )
const ( // ProtocolVersion is the latest protocol version this package supports. ProtocolVersion uint32 = 70013 // MultipleAddressVersion is the protocol version which added multiple // addresses per message (pver >= MultipleAddressVersion). MultipleAddressVersion uint32 = 209 // NetAddressTimeVersion is the protocol version which added the // timestamp field (pver >= NetAddressTimeVersion). NetAddressTimeVersion uint32 = 31402 // BIP0031Version is the protocol version AFTER which a pong message // and nonce field in ping were added (pver > BIP0031Version). BIP0031Version uint32 = 60000 // BIP0035Version is the protocol version which added the mempool // message (pver >= BIP0035Version). BIP0035Version uint32 = 60002 // BIP0037Version is the protocol version which added new connection // bloom filtering related messages and extended the version message // with a relay flag (pver >= BIP0037Version). BIP0037Version uint32 = 70001 // RejectVersion is the protocol version which added a new reject // message. RejectVersion uint32 = 70002 // BIP0111Version is the protocol version which added the SFNodeBloom // service flag. BIP0111Version uint32 = 70011 // SendHeadersVersion is the protocol version which added a new // sendheaders message. SendHeadersVersion uint32 = 70012 // FeeFilterVersion is the protocol version which added a new // feefilter message. FeeFilterVersion uint32 = 70013 )
XXX pedro: we will probably need to bump this.
const BlockVersion = 1
BlockVersion defines the version of block.
const CommandSize = 12
CommandSize is the fixed size of all commands in the common bitcoin message header. Shorter commands must be zero padded.
const DefaultUserAgent = "/btcwire:0.5.0/"
DefaultUserAgent for wire in the stack
const ( // InvWitnessFlag denotes that the inventory vector type is requesting, // or sending a version which includes witness data. InvWitnessFlag = 1 << 30 )
const MaxAddrPerMsg = 1000
MaxAddrPerMsg is the maximum number of addresses that can be in a single bitcoin addr message (MsgAddr).
const (
MaxBlockHeaderPayload = MaxBlockPayload / 2000
)
MaxBlockHeaderPayload is set to be 1/2000 of a whole block size at max. Note that this wasn't decided with a scientific calculation.
const MaxBlockPayload = 4000000
MaxBlockPayload is the maximum bytes a block message can be in bytes. After Segregated Witness, the max block payload has been raised to 4MB.
const MaxBlocksPerMsg = 500
MaxBlocksPerMsg is the maximum number of blocks allowed per message.
const ( // MaxFilterAddDataSize is the maximum byte size of a data // element to add to the Bloom filter. It is equal to the // maximum element size of a script. MaxFilterAddDataSize = 520 )
const MaxMessagePayload = (1024 * 1024 * 32) // 32MB
MaxMessagePayload is the maximum bytes a message can be regardless of other individual limits imposed by messages themselves.
const MaxReturnedMsgsPayload = MaxBlockPayload * 20
MaxReturnedMsgsPayload is the max payload for returned msgs from storagenode is set to be at the maximum of 20 blocks' size.
const MaxUserAgentLen = 256
MaxUserAgentLen is the maximum allowed length for the user agent field in a version message (MsgVersion).
const (
// MaxVarIntPayload is the maximum payload size for a variable length integer.
MaxVarIntPayload = 9
)
const MessageHeaderSize = 24
MessageHeaderSize is the number of bytes in a bitcoin message header. Bitcoin network (magic) 4 bytes + command 12 bytes + payload length 4 bytes + checksum 4 bytes.
const (
// MsgReSendSyncReqMaxPayload is a very arbitrary number
MsgReSendSyncReqMaxPayload = 4000000
)
const ( // MsgSyncBlockMaxPayload is a very arbitrary number MsgSyncBlockMaxPayload = MaxBlockPayload )
const ( // MsgSyncHeadersMaxPayload is a very arbitrary number MsgSyncHeadersMaxPayload = MaxBlockPayload )
const (
// MsgSyncInvMaxPayload is a very arbitrary number
MsgSyncInvMaxPayload = 4000000
)
const ( // MsgSyncSlimBlockMaxPayload is a very arbitrary number MsgSyncSlimBlockMaxPayload = MaxBlockPayload )
Variables ¶
var ( // MinerReward is the amount of MultiVac coins given to miner as reward for creating a block. MinerReward = new(big.Int).SetUint64(10e18) // DepositTxFee is the transaction fee for a deposit transaction // It is set to motivate a miner stay a minimal time as a miner DepositTxFee = big.NewInt(10) // WithdrawTxFee is need to calculate the accurate deposit amount WithdrawTxFee = big.NewInt(10) // MinimalDepositAmount defines the minimal deposit count. MinimalDepositAmount = big.NewInt(10) )
var LargeMaxPayloadLength uint32 = 104857600
LargeMaxPayloadLength temporary Max payload length used for all messages.
var LatestEncoding = WitnessEncoding
LatestEncoding is the most recently specified encoding for the Bitcoin wire protocol.
Functions ¶
func GetMtvValueFromOut ¶
GetMtvValueFromOut fetches the out Value from the given OutPoint.Data
func MakeMessageHash ¶
func MakeMessageHash(msg Message, pver uint32, btcnet BitcoinNet) chainhash.Hash
MakeMessageHash calculate Message hash.
func MsgShouldRelay ¶
MsgShouldRelay checks if the message needs to relay.
func MtvValueToData ¶
MtvValueToData writes the out Value into OutPoint.Data
func RandomUint64 ¶
RandomUint64 returns a cryptographically random uint64 value.
func ReadVarBytes ¶
ReadVarBytes reads a variable length byte array. A byte array is encoded as a varInt containing the length of the array followed by the bytes themselves. An error is returned if the length is greater than the passed maxAllowed parameter which helps protect against memory exhaustion attacks and forced panics through malformed messages. The fieldName parameter is only used for the error message so it provides more context in the error.
func ReadVarInt ¶
ReadVarInt reads a variable length integer from r and returns it as a uint64.
func ReadVarString ¶
ReadVarString reads a variable length string from r and returns it as a Go string. A variable length string is encoded as a variable length integer containing the length of the string followed by the bytes that represent the string itself. An error is returned if the length is greater than the maximum block payload size since it helps protect against memory exhaustion attacks and forced panics through malformed messages.
func UnspentOutHash ¶
func UnspentOutHash(o *OutPoint) *merkle.MerkleHash
UnspentOutHash returns the unspent out hash.
func VarIntSerializeSize ¶
VarIntSerializeSize returns the number of bytes it would take to serialize val as a variable length integer.
func WriteMessage ¶
WriteMessage writes a bitcoin Message to w including the necessary header information. This function is the same as WriteMessageN except it doesn't doesn't return the number of bytes written. This function is mainly provided for backwards compatibility with the original API, but it's also useful for callers that don't care about byte counts.
func WriteMessageN ¶
WriteMessageN writes a bitcoin Message to w including the necessary header information and returns the number of bytes written. This function is the same as WriteMessage except it also returns the number of bytes written.
func WriteMessageWithEncodingN ¶
func WriteMessageWithEncodingN(w io.Writer, msg Message, pver uint32, btcnet BitcoinNet, encoding MessageEncoding) (int, error)
WriteMessageWithEncodingN writes a bitcoin Message to w including the necessary header information and returns the number of bytes written. This function is the same as WriteMessageN except it also allows the caller to specify the message encoding format to be used when serializing wire messages.
func WriteVarBytes ¶
WriteVarBytes serializes a variable length byte array to w as a varInt containing the number of bytes, followed by the bytes themselves.
func WriteVarInt ¶
WriteVarInt serializes val to w using a variable number of bytes depending on its value.
Types ¶
type Alert ¶
type Alert struct { // Alert format version Version int32 // Timestamp beyond which nodes should stop relaying this alert RelayUntil int64 // Timestamp beyond which this alert is no longer in effect and // should be ignored Expiration int64 // A unique ID number for this alert ID int32 // All alerts with an ID less than or equal to this number should // cancelled, deleted and not accepted in the future Cancel int32 // All alert IDs contained in this set should be cancelled as above SetCancel []int32 // This alert only applies to versions greater than or equal to this // version. Other versions should still relay it. MinVer int32 // This alert only applies to versions less than or equal to this version. // Other versions should still relay it. MaxVer int32 // If this set contains any elements, then only nodes that have their // subVer contained in this set are affected by the alert. Other versions // should still relay it. SetSubVer []string // Relative priority compared to other alerts Priority int32 // A comment on the alert that is not displayed Comment string // The alert message that is displayed to the user StatusBar string // Reserved Reserved string }
Alert contains the data deserialized from the MsgAlert payload.
func NewAlert ¶
func NewAlert(version int32, relayUntil int64, expiration int64, id int32, cancel int32, setCancel []int32, minVer int32, maxVer int32, setSubVer []string, priority int32, comment string, statusBar string) *Alert
NewAlert returns an new Alert with values provided.
func NewAlertFromPayload ¶
NewAlertFromPayload returns an Alert with values deserialized from the serialized payload.
func (*Alert) Deserialize ¶
Deserialize decodes from r into the receiver using the alert protocol encoding format.
type BitcoinNet ¶
type BitcoinNet uint32
BitcoinNet represents which bitcoin network a message belongs to.
const ( // MainNet represents the main bitcoin network. MainNet BitcoinNet = 0xd9b4bef9 // TestNet represents the regression test network. TestNet BitcoinNet = 0xdab5bffa // TestNet3 represents the test network (version 3). TestNet3 BitcoinNet = 0x0709110b // SimNet represents the simulation test network. SimNet BitcoinNet = 0x12141c16 )
Constants used to indicate the message bitcoin network. They can also be used to seek to the next message when a stream's state is unknown, but this package does not provide that functionality since it's generally a better idea to simply disconnect clients that are misbehaving over TCP.
func (BitcoinNet) String ¶
func (n BitcoinNet) String() string
String returns the BitcoinNet in human-readable form.
type BlockBody ¶
type BlockBody struct { Transactions []*MsgTxWithProofs LedgerInfo LedgerInfo SmartContracts []*SmartContract Outs []*OutState UpdateActions []*UpdateAction }
BlockBody defines the data structure of block body.
func (*BlockBody) BlockBodyHash ¶
BlockBodyHash returns the block body hash.
func (*BlockBody) ToBytesArray ¶
ToBytesArray will serialize the block body to bytes array.
type BlockHeader ¶
type BlockHeader struct { Version int32 ShardIndex shard.Index Height int64 PrevBlockHeader chainhash.Hash BlockBodyHash chainhash.Hash OutsMerkleRoot merkle.MerkleHash ShardLedgerMerkleRoot merkle.MerkleHash IsEmptyBlock bool TimeStamp int64 // TODO: Add seed into block header. // TODO: Add proof that the node which created this block is eligible to create it. DepositTxsOuts []OutPoint WithdrawTxsOuts []OutPoint // ReshardSeed is used to indicate re-sharding. // Update ReshardSeed if relevant shard needs to do re-sharding; otherwise, it remains the same with // the prevHeader. ReshardSeed []byte Pk []byte LastSeedSig []byte //Use to verify seed HeaderSig []byte Seed chainhash.Hash //redunt,can calculate from LastSeedSig,Round ReduceActions []*ReduceAction }
BlockHeader implements the Message interface and represents a MultiVAC block header message. It is used to broadcast block header when a new block is accepted.
func NewBlockHeader ¶
func NewBlockHeader(version int32, shardIndex shard.Index, height int64, prevHash *chainhash.Hash, blockBodyHash *chainhash.Hash, outsMerkleRoot *merkle.MerkleHash, shardLedgerMerkleRoot *merkle.MerkleHash, depositTxsOuts []OutPoint, withdrawTxsOuts []OutPoint) *BlockHeader
NewBlockHeader returns a new BlockHeader using the provided version, previous block hash, merkle root hash, difficulty bits, and nonce used to generate the block with defaults for the remaining fields.
func (BlockHeader) BlockHeaderHash ¶
func (h BlockHeader) BlockHeaderHash() chainhash.Hash
BlockHeaderHash computes the block identifier hash for the given block header. TODO:(guotao) use more grace way to hash without HeaderSig
func (*BlockHeader) BtcDecode ¶
func (h *BlockHeader) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation. See Deserialize for decoding block headers stored to disk, such as in a database, as opposed to decoding block headers from the wire.
func (*BlockHeader) BtcEncode ¶
func (h *BlockHeader) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation. See Serialize for encoding block headers to be stored to disk, such as in a database, as opposed to encoding block headers for the wire.
func (*BlockHeader) Command ¶
func (h *BlockHeader) Command() string
Command returns command block header.
func (*BlockHeader) Deserialize ¶
func (h *BlockHeader) Deserialize(r io.Reader) error
Deserialize decodes a block header from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field.
func (*BlockHeader) GetShardIndex ¶
func (h *BlockHeader) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*BlockHeader) IsEqualTo ¶
func (h *BlockHeader) IsEqualTo(header *BlockHeader) bool
IsEqualTo compares two blockheads to see if they are equal
func (*BlockHeader) MaxPayloadLength ¶
func (h *BlockHeader) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns max playload .
func (*BlockHeader) Serialize ¶
func (h *BlockHeader) Serialize(w io.Writer) error
Serialize encodes a block header from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field.
func (*BlockHeader) String ¶
func (h *BlockHeader) String() string
func (*BlockHeader) ToBytesArray ¶
func (h *BlockHeader) ToBytesArray() []byte
ToBytesArray serialize the block header to byte array.
type BlockLocator ¶
BlockLocator defines the data structure of block located.
func NewBlockLocator ¶
func NewBlockLocator(shardIdx shard.Index, fromHeight int64, toHeight int64) *BlockLocator
NewBlockLocator creates a blocklocator.
func (*BlockLocator) String ¶
func (msg *BlockLocator) String() string
type BloomUpdateType ¶
type BloomUpdateType uint8
BloomUpdateType specifies how the filter is updated when a match is found
const ( // BloomUpdateNone indicates the filter is not adjusted when a match is // found. BloomUpdateNone BloomUpdateType = 0 // BloomUpdateAll indicates if the filter matches any data element in a // public key script, the outpoint is serialized and inserted into the // filter. BloomUpdateAll BloomUpdateType = 1 // BloomUpdateP2PubkeyOnly indicates if the filter matches a data // element in a public key script and the script is of the standard // pay-to-pubkey or multisig, the outpoint is serialized and inserted // into the filter. BloomUpdateP2PubkeyOnly BloomUpdateType = 2 )
type ByzAgreementValue ¶
type ByzAgreementValue struct { BlockHash chainhash.Hash // leader indicates the public key of corresponding peer // TODO(liang): use byte array with const length, instead of string Leader string }
ByzAgreementValue defines the data structure of Byz Agreement Value.
func (ByzAgreementValue) Serialize ¶
func (b ByzAgreementValue) Serialize() ([]byte, error)
Serialize the byz agreement value.
func (ByzAgreementValue) String ¶
func (b ByzAgreementValue) String() string
String returns the format string of ByzAgreementValue.
type ClipTreeData ¶
type ClipTreeData struct { Size int64 StartIndex int64 IsLeftOutNil bool IsRightOutNil bool Outs []*OutState LeftMerklePath *merkle.MerklePath RightMerklePath *merkle.MerklePath }
ClipTreeData 矿工将重建剪枝树所需要的必要信息打包到SlimBlock数据结构发送给指定的存储节点.
func (*ClipTreeData) Rebuild ¶
func (clipTreeData *ClipTreeData) Rebuild(root merkle.MerkleHash, shard shard.Index) (*merkle.FullMerkleTree, error)
Rebuild storage node rebuilds the merkle tree by the given clipTreeData.
type ConsensusMsg ¶
type ConsensusMsg struct { Credential *Credential `rlp:"nil"` CredentialWithBA *CredentialWithBA `rlp:"nil"` ByzAgreementValue *ByzAgreementValue `rlp:"nil"` }
ConsensusMsg defines the data structure of consensus message.
func (ConsensusMsg) Serialize ¶
func (c ConsensusMsg) Serialize() ([]byte, error)
Serialize serialize the message.
type Credential ¶
Credential defines the data structure of credential.
func NewCredential ¶
func NewCredential(round, step int32) *Credential
NewCredential returns a credential .
func (Credential) Serialize ¶
func (c Credential) Serialize() ([]byte, error)
Serialize serialize the credential.
type CredentialWithBA ¶
type CredentialWithBA struct { ShardIndex shard.Index Round int32 Step int32 B byte V ByzAgreementValue }
CredentialWithBA defines the data structure of credential with BA.
func NewCredentialWithBA ¶
func NewCredentialWithBA(shardIndex shard.Index, round, step int32, b byte, v ByzAgreementValue) *CredentialWithBA
NewCredentialWithBA returns CredentialWithBA with given params.
func (CredentialWithBA) Serialize ¶
func (c CredentialWithBA) Serialize() ([]byte, error)
Serialize serialize the credential with Byz agreement.,
type GCMessage ¶
type GCMessage struct { ShardIndex shard.Index Seed []byte SignedCredential *SignedMsg `rlp:"nil"` SignedVal *SignedMsg `rlp:"nil"` Block *MsgBlock `rlp:"nil"` InShardProof []byte }
GCMessage defines a type of message GC.
func (*GCMessage) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*GCMessage) GetByzAgreementValue ¶
func (m *GCMessage) GetByzAgreementValue() *ByzAgreementValue
GetByzAgreementValue returns the ByzAgreementValue of the message.
func (*GCMessage) GetInShardProofs ¶
GetInShardProofs returns the message's InShardProof
func (*GCMessage) GetShardIndex ¶
GetShardIndex returns the shardIndex.
func (*GCMessage) GetSignedCredential ¶
GetSignedCredential returns the message's SignedCredential.
func (*GCMessage) IsValidated ¶
IsValidated returns whether the message is legal.
func (GCMessage) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type HeartBeatMsg ¶
type HeartBeatMsg struct { Pk []byte // the miner's public key TimeStamp Timestamp Proof []byte // the proof of a mine Signature []byte // the signature of TimeStamp }
HeartBeatMsg is a type of message heartbeat.
func (*HeartBeatMsg) BtcDecode ¶
func (msg *HeartBeatMsg) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decode the message. TODO(jylu)
func (*HeartBeatMsg) BtcEncode ¶
func (msg *HeartBeatMsg) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. TODO(jylu)
func (*HeartBeatMsg) Command ¶
func (msg *HeartBeatMsg) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*HeartBeatMsg) Deserialize ¶
func (msg *HeartBeatMsg) Deserialize(r io.Reader) error
Deserialize deserialize the data. TODO(jylu)
func (*HeartBeatMsg) MaxPayloadLength ¶
func (msg *HeartBeatMsg) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type InvGroup ¶
InvGroup is group of inventory.
func NewInvGroup ¶
NewInvGroup create a inventory group.
type InvType ¶
type InvType uint32
InvType represents the allowed types of inventory vectors. See InvVect.
type InvVect ¶
InvVect defines a bitcoin inventory vector which is used to describe data, as specified by the Type field, that a peer wants, has, or does not have to another peer.
type LeaderProposalMessage ¶
type LeaderProposalMessage struct { ShardIndex shard.Index InShardProof []byte Block *MsgBlock `rlp:"nil"` BlockHash chainhash.Hash SignedHash []byte LastSeedSig []byte SignedCredential *SignedMsg `rlp:"nil"` }
LeaderProposalMessage is a message for broadcasting potential leader in current round.
func (*LeaderProposalMessage) BtcDecode ¶
func (msg *LeaderProposalMessage) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*LeaderProposalMessage) BtcEncode ¶
func (msg *LeaderProposalMessage) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*LeaderProposalMessage) Command ¶
func (msg *LeaderProposalMessage) Command() string
Command returns the protocol command string for the message.
func (*LeaderProposalMessage) GetInShardProofs ¶
func (msg *LeaderProposalMessage) GetInShardProofs() [][]byte
GetInShardProofs returns message's InShardProof.
func (*LeaderProposalMessage) GetRound ¶
func (msg *LeaderProposalMessage) GetRound() int
GetRound to return msg.round which in msg.SignedCredentialWithBA.Credential.round.
func (*LeaderProposalMessage) GetShardIndex ¶
func (msg *LeaderProposalMessage) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*LeaderProposalMessage) GetSignedCredential ¶
func (msg *LeaderProposalMessage) GetSignedCredential() *SignedMsg
GetSignedCredential returns the SignedCredential.
func (*LeaderProposalMessage) GetStep ¶
func (msg *LeaderProposalMessage) GetStep() int
GetStep to return message's step.
func (*LeaderProposalMessage) IsValidated ¶
func (msg *LeaderProposalMessage) IsValidated() error
IsValidated Verify the signature of ByzantineValue.
func (*LeaderProposalMessage) MaxPayloadLength ¶
func (msg *LeaderProposalMessage) MaxPayloadLength(_ uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
func (*LeaderProposalMessage) Sign ¶
func (msg *LeaderProposalMessage) Sign(sk []byte) (err error)
Sign Message.
func (*LeaderProposalMessage) String ¶
func (msg *LeaderProposalMessage) String() string
type LeaderVoteMessage ¶
type LeaderVoteMessage struct { ShardIndex shard.Index InShardProof []byte SignedVal *SignedMsg `rlp:"nil"` Block *MsgBlock `rlp:"nil"` SignedCredential *SignedMsg `rlp:"nil"` }
LeaderVoteMessage is a type of message LeaderVoteMessage.
func (*LeaderVoteMessage) BtcDecode ¶
func (m *LeaderVoteMessage) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*LeaderVoteMessage) BtcEncode ¶
func (m *LeaderVoteMessage) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*LeaderVoteMessage) Command ¶
func (m *LeaderVoteMessage) Command() string
Command returns the protocol command string for the message.
func (*LeaderVoteMessage) GetByzAgreementValue ¶
func (m *LeaderVoteMessage) GetByzAgreementValue() *ByzAgreementValue
GetByzAgreementValue returns the ByzAgreementValue.
func (*LeaderVoteMessage) GetInShardProofs ¶
func (m *LeaderVoteMessage) GetInShardProofs() [][]byte
GetInShardProofs returns message's InShardProof.
func (*LeaderVoteMessage) GetRound ¶
func (m *LeaderVoteMessage) GetRound() int
GetRound returns the round of message.
func (*LeaderVoteMessage) GetShardIndex ¶
func (m *LeaderVoteMessage) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*LeaderVoteMessage) GetSignedCredential ¶
func (m *LeaderVoteMessage) GetSignedCredential() *SignedMsg
GetSignedCredential returns the SignedCredential.
func (*LeaderVoteMessage) GetStep ¶
func (m *LeaderVoteMessage) GetStep() int
GetStep returns the step of message.
func (*LeaderVoteMessage) IsValidated ¶
func (m *LeaderVoteMessage) IsValidated() (err error)
IsValidated Verify the signature of ByzantineValue.
func (*LeaderVoteMessage) MaxPayloadLength ¶
func (m *LeaderVoteMessage) MaxPayloadLength(_ uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
func (*LeaderVoteMessage) Sign ¶
func (m *LeaderVoteMessage) Sign(sk []byte) (err error)
Sign Message
func (*LeaderVoteMessage) String ¶
func (m *LeaderVoteMessage) String() string
String returns the format string for LeaderVoteMessage.
type LedgerInfo ¶
type LedgerInfo struct { // How many blocks has been included in the ledger. Size int64 ShardsHeights []*shard.IndexAndHeight }
LedgerInfo defines the data structure of ledger info.
func (*LedgerInfo) GetShardHeight ¶
func (ledger *LedgerInfo) GetShardHeight(shardIndex shard.Index) int64
GetShardHeight returns the height for a certain shard. If there's no info for this shard, then return 0.
func (*LedgerInfo) SetShardHeight ¶
func (ledger *LedgerInfo) SetShardHeight(shardIndex shard.Index, height int64)
SetShardHeight set the shardheight.
type MTVCoinData ¶
MTVCoinData is the OutPoint data for transfer tx.
type MTVDepositData ¶
type MTVDepositData struct { Value *big.Int // Height is the block height at which out is effective. Height int64 // BindingAddress is used to grant mining auth to specified user. BindingAddress multivacaddress.Address }
MTVDepositData is the OutPoint data for deposit tx
func OutToDepositData ¶
func OutToDepositData(op *OutPoint) (*MTVDepositData, error)
OutToDepositData converts OutPoint to MTVDepositData.
func (*MTVDepositData) ToData ¶
func (mdd *MTVDepositData) ToData() []byte
ToData serializes MTVDepositData to bytes by using rlp.
type MTVWithdrawData ¶
MTVWithdrawData is the OutPoint data for withdraw tx.
func OutToWithdrawData ¶
func OutToWithdrawData(op *OutPoint) (*MTVWithdrawData, error)
OutToWithdrawData converts OutPoint to MTVDepositData.
func (*MTVWithdrawData) ToData ¶
func (mwd *MTVWithdrawData) ToData() []byte
ToData converts MTVWithdrawData to bytes by using rlp.
type Message ¶
type Message interface { BtcDecode(io.Reader, uint32, MessageEncoding) error BtcEncode(io.Writer, uint32, MessageEncoding) error Command() string MaxPayloadLength(uint32) uint32 }
Message is an interface that describes a bitcoin message. A type that implements Message has complete control over the representation of its data and may therefore contain additional or fewer fields than those which are used directly in the protocol encoded message.
func ReadMessage ¶
ReadMessage reads, validates, and parses the next bitcoin Message from r for the provided protocol version and bitcoin network. It returns the parsed Message and raw bytes which comprise the message. This function only differs from ReadMessageN in that it doesn't return the number of bytes read. This function is mainly provided for backwards compatibility with the original API, but it's also useful for callers that don't care about byte counts.
func ReadMessageN ¶
ReadMessageN reads, validates, and parses the next bitcoin Message from r for the provided protocol version and bitcoin network. It returns the number of bytes read in addition to the parsed Message and raw bytes which comprise the message. This function is the same as ReadMessage except it also returns the number of bytes read.
func ReadMessageWithEncodingN ¶
func ReadMessageWithEncodingN(r io.Reader, pver uint32, btcnet BitcoinNet, enc MessageEncoding) (int, Message, []byte, error)
ReadMessageWithEncodingN reads, validates, and parses the next bitcoin Message from r for the provided protocol version and bitcoin network. It returns the number of bytes read in addition to the parsed Message and raw bytes which comprise the message. This function is the same as ReadMessageN except it allows the caller to specify which message encoding is to to consult when decoding wire messages.
type MessageEncoding ¶
type MessageEncoding uint32
MessageEncoding represents the wire message encoding format to be used.
const ( // BaseEncoding encodes all messages in the default format specified // for the Bitcoin wire protocol. BaseEncoding MessageEncoding = 1 << iota // WitnessEncoding encodes all messages other than transaction messages // using the default Bitcoin wire protocol specification. For transaction // messages, the new encoding format detailed in BIP0144 will be used. WitnessEncoding )
type MessageError ¶
type MessageError struct { Func string // Function name Description string // Human readable description of the issue }
MessageError describes an issue with a message. An example of some potential issues are messages from the wrong bitcoin network, invalid commands, mismatched checksums, and exceeding max payloads.
This provides a mechanism for the caller to type assert the error to differentiate between general io errors such as io.EOF and issues that resulted from malformed messages.
func (*MessageError) Error ¶
func (e *MessageError) Error() string
Error satisfies the error interface and prints human-readable errors.
type MsgAddr ¶
type MsgAddr struct {
AddrList []*NetAddress
}
MsgAddr implements the Message interface and represents a bitcoin addr message. It is used to provide a list of known active peers on the network. An active peer is considered one that has transmitted a message within the last 3 hours. Nodes which have not transmitted in that time frame should be forgotten. Each message is limited to a maximum number of addresses, which is currently 1000. As a result, multiple messages must be used to relay the full list.
Use the AddAddress function to build up the list of known addresses when sending an addr message to another peer.
func NewMsgAddr ¶
func NewMsgAddr() *MsgAddr
NewMsgAddr returns a new bitcoin addr message that conforms to the Message interface. See MsgAddr for details.
func (*MsgAddr) AddAddress ¶
func (msg *MsgAddr) AddAddress(na *NetAddress) error
AddAddress adds a known active peer to the message.
func (*MsgAddr) AddAddresses ¶
func (msg *MsgAddr) AddAddresses(netAddrs ...*NetAddress) error
AddAddresses adds multiple known active peers to the message.
func (*MsgAddr) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgAddr) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgAddr) ClearAddresses ¶
func (msg *MsgAddr) ClearAddresses()
ClearAddresses removes all addresses from the message.
func (*MsgAddr) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgAddr) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgAlert ¶
type MsgAlert struct { // SerializedPayload is the alert payload serialized as a string so that the // version can change but the Alert can still be passed on by older // clients. SerializedPayload []byte // Signature is the ECDSA signature of the message. Signature []byte // Deserialized Payload Payload *Alert }
MsgAlert implements the Message interface and defines a bitcoin alert message.
This is a signed message that provides notifications that the client should display if the signature matches the key. bitcoind/bitcoin-qt only checks against a signature from the core developers.
func NewMsgAlert ¶
NewMsgAlert returns a new bitcoin alert message that conforms to the Message interface. See MsgAlert for details.
func (*MsgAlert) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgAlert) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgAlert) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgAlert) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgBinaryBA ¶
MsgBinaryBA indicates binary Byzantine agreement message
func NewMessageBinaryBA ¶
func NewMessageBinaryBA(inshardProof []byte, signedMsg *SignedMsg) *MsgBinaryBA
NewMessageBinaryBA create a MsgBinaryBA with given params.
func (*MsgBinaryBA) BtcDecode ¶
func (m *MsgBinaryBA) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*MsgBinaryBA) BtcEncode ¶
func (m *MsgBinaryBA) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgBinaryBA) Command ¶
func (m *MsgBinaryBA) Command() string
Command returns the protocol command string for the message.
func (*MsgBinaryBA) GetBValue ¶
func (m *MsgBinaryBA) GetBValue() byte
GetBValue returns the B value from credentialWithBA
func (*MsgBinaryBA) GetByzAgreementValue ¶
func (m *MsgBinaryBA) GetByzAgreementValue() ByzAgreementValue
GetByzAgreementValue get the agreement value from credential.
func (*MsgBinaryBA) GetInShardProofs ¶
func (m *MsgBinaryBA) GetInShardProofs() [][]byte
GetInShardProofs returns message's InShardProof.
func (*MsgBinaryBA) GetRawB ¶
func (m *MsgBinaryBA) GetRawB() []byte
GetRawB get B of credentialwithBA.
func (*MsgBinaryBA) GetRawV ¶
func (m *MsgBinaryBA) GetRawV() []byte
GetRawV get V of credentialwithBA.
func (*MsgBinaryBA) GetShardIndex ¶
func (m *MsgBinaryBA) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*MsgBinaryBA) GetSignedCredential ¶
func (m *MsgBinaryBA) GetSignedCredential() *SignedMsg
GetSignedCredential returns the SignedCredential.
func (*MsgBinaryBA) IsValidated ¶
func (m *MsgBinaryBA) IsValidated() error
IsValidated Verify the signature of ByzantineValue.
func (*MsgBinaryBA) MaxPayloadLength ¶
func (m *MsgBinaryBA) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type MsgBinaryBAFin ¶
type MsgBinaryBAFin struct {
*MsgBinaryBA
}
MsgBinaryBAFin indicates last step binary Byzantine agreement message.
func NewMessageBinaryBAFin ¶
func NewMessageBinaryBAFin(message *MsgBinaryBA) *MsgBinaryBAFin
NewMessageBinaryBAFin create a MsgBinaryBAFin with given MsgBinaryBA with steps less than 0.
func (*MsgBinaryBAFin) BtcDecode ¶
func (m *MsgBinaryBAFin) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*MsgBinaryBAFin) BtcEncode ¶
func (m *MsgBinaryBAFin) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgBinaryBAFin) Command ¶
func (m *MsgBinaryBAFin) Command() string
Command returns the protocol command string for the message.
type MsgBlock ¶
type MsgBlock struct { Header BlockHeader Body *BlockBody }
MsgBlock implements the Message interface and represents a bitcoin block message. It is used to deliver block and transaction information in response to a getdata message (MsgGetData) for a given block hash.
func NewBlock ¶
func NewBlock( shardIndex shard.Index, height int64, prevBlockHeader chainhash.Hash, shardLedgerRoot merkle.MerkleHash, outsMerkleRoot merkle.MerkleHash, txs []*MsgTxWithProofs, ledgerInfo *LedgerInfo, isEmptyBlock bool, timeStamp int64, reshardSeed []byte, sc []*SmartContract, outs []*OutState, updateActions []*UpdateAction, reduceActions []*ReduceAction) *MsgBlock
NewBlock creates valid new block base given data. Note. This function should be updated when block struct changes.
func (*MsgBlock) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation. See Deserialize for decoding blocks stored to disk, such as in a database, as opposed to decoding blocks from the wire.
func (*MsgBlock) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation. See Serialize for encoding blocks to be stored to disk, such as in a database, as opposed to encoding blocks for the wire.
func (*MsgBlock) Deserialize ¶
Deserialize decodes a block from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field in the block. This function differs from BtcDecode in that BtcDecode decodes from the bitcoin wire protocol as it was sent across the network. The wire encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored block at all. As of the time this comment was written, the encoded block is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgBlock) GetShardIndex ¶
GetShardIndex returns the shardIndex.
func (*MsgBlock) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver.
func (*MsgBlock) Serialize ¶
Serialize encodes the block to w using a format that suitable for long-term storage such as a database while respecting the Version field in the block. This function differs from BtcEncode in that BtcEncode encodes the block to the bitcoin wire protocol in order to be sent across the network. The wire encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored block at all. As of the time this comment was written, the encoded block is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgBlock) SerializeNoWitness ¶
SerializeNoWitness encodes a block to w using an identical format to Serialize, with all (if any) witness data stripped from all transactions. This method is provided in additon to the regular Serialize, in order to allow one to selectively encode transaction witness data to non-upgraded peers which are unaware of the new encoding.
func (*MsgBlock) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the block.
func (*MsgBlock) SerializeSizeStripped ¶
SerializeSizeStripped returns the number of bytes it would take to serialize the block, excluding any witness data (if any).
type MsgBlockConfirmation ¶
type MsgBlockConfirmation struct { ShardIndex shard.Index Round int32 Step int32 V ByzAgreementValue // Header 当前re-shard轮公示出来的block header Header *BlockHeader `rlp:"nil"` Confirms []*MsgBinaryBAFin }
MsgBlockConfirmation indicates binary Byzantine agreement message.
func NewMessageBlockConfirmation ¶
func NewMessageBlockConfirmation(shard shard.Index, round, step int32, v *ByzAgreementValue, header *BlockHeader, confirms []*MsgBinaryBAFin) *MsgBlockConfirmation
NewMessageBlockConfirmation create a new block confirmation message。
func (*MsgBlockConfirmation) BtcDecode ¶
func (msg *MsgBlockConfirmation) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*MsgBlockConfirmation) BtcEncode ¶
func (msg *MsgBlockConfirmation) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgBlockConfirmation) Command ¶
func (msg *MsgBlockConfirmation) Command() string
Command returns the protocol command string for the message.
func (*MsgBlockConfirmation) GetByzAgreementValue ¶
func (msg *MsgBlockConfirmation) GetByzAgreementValue() ByzAgreementValue
GetByzAgreementValue get the byz agreement value.
func (*MsgBlockConfirmation) GetInShardProofs ¶
func (msg *MsgBlockConfirmation) GetInShardProofs() [][]byte
GetInShardProofs returns message's InShardProof.
func (*MsgBlockConfirmation) GetRawV ¶
func (msg *MsgBlockConfirmation) GetRawV() []byte
GetRawV get the V value.
func (*MsgBlockConfirmation) GetRound ¶
func (msg *MsgBlockConfirmation) GetRound() int
GetRound get the round of message.
func (*MsgBlockConfirmation) GetShardIndex ¶
func (msg *MsgBlockConfirmation) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*MsgBlockConfirmation) GetSignedCredential ¶
func (msg *MsgBlockConfirmation) GetSignedCredential() *SignedMsg
GetSignedCredential returns the SignedCredential.
func (*MsgBlockConfirmation) GetStep ¶
func (msg *MsgBlockConfirmation) GetStep() int
GetStep get the step of message.
func (*MsgBlockConfirmation) GetVoters ¶
func (msg *MsgBlockConfirmation) GetVoters() [][]byte
GetVoters will return all pk of voters.
func (*MsgBlockConfirmation) IsValidated ¶
func (msg *MsgBlockConfirmation) IsValidated() error
IsValidated judged the following conditions: 1. Header and Header.Sig 2. Cur round seed. 3. Confirms:
- bbaMsg and cred Signature(pk)
- bbaMsg.Index, Round, Step, ByzAgreementValue
BUT STILL THE FOLLOWING NOT JUDGED: 1. Header.PrevBlockHeader ? 2. Header.PrevSeedSig ? 3. Header.PK is Potential leader and is InShard ? 4. len(confirms) >= threshold ? 5. every BBAMsg.PK is InShard and alive ?
func (*MsgBlockConfirmation) MaxPayloadLength ¶
func (msg *MsgBlockConfirmation) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
func (*MsgBlockConfirmation) String ¶
func (msg *MsgBlockConfirmation) String() string
type MsgFeeFilter ¶
type MsgFeeFilter struct {
MinFee int64
}
MsgFeeFilter implements the Message interface and represents a bitcoin feefilter message. It is used to request the receiving peer does not announce any transactions below the specified minimum fee rate.
This message was not added until protocol versions starting with FeeFilterVersion.
func NewMsgFeeFilter ¶
func NewMsgFeeFilter(minfee int64) *MsgFeeFilter
NewMsgFeeFilter returns a new bitcoin feefilter message that conforms to the Message interface. See MsgFeeFilter for details.
func (*MsgFeeFilter) BtcDecode ¶
func (msg *MsgFeeFilter) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgFeeFilter) BtcEncode ¶
func (msg *MsgFeeFilter) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgFeeFilter) Command ¶
func (msg *MsgFeeFilter) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgFeeFilter) MaxPayloadLength ¶
func (msg *MsgFeeFilter) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgFetchDeposit ¶
type MsgFetchDeposit struct { ShardIndex shard.Index Address multivacaddress.Address }
MsgFetchDeposit is a message to request deposit info from storage node.
func (*MsgFetchDeposit) BtcDecode ¶
func (msg *MsgFetchDeposit) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decode the message.
func (*MsgFetchDeposit) BtcEncode ¶
func (msg *MsgFetchDeposit) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgFetchDeposit) Command ¶
func (msg *MsgFetchDeposit) Command() string
Command returns the protocol command string for the message.
func (*MsgFetchDeposit) GetShardIndex ¶
func (msg *MsgFetchDeposit) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*MsgFetchDeposit) MaxPayloadLength ¶
func (msg *MsgFetchDeposit) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type MsgFetchEncode ¶
type MsgFetchEncode struct { Msg Message ShardHeight int64 UserAddress multivacaddress.Address }
MsgFetchEncode is used to encode a fetch msg.
func (*MsgFetchEncode) BtcDecode ¶
func (m *MsgFetchEncode) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decode the message.
func (*MsgFetchEncode) BtcEncode ¶
func (m *MsgFetchEncode) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
type MsgFetchInit ¶
type MsgFetchInit struct { MsgID uint32 ShardIndex shard.Index Address multivacaddress.Address }
MsgFetchInit is a message to request ledger info from storage node.
func (*MsgFetchInit) BtcDecode ¶
func (m *MsgFetchInit) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decode the message.
func (*MsgFetchInit) BtcEncode ¶
func (m *MsgFetchInit) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgFetchInit) Command ¶
func (m *MsgFetchInit) Command() string
Command returns the protocol command string for the message.
func (*MsgFetchInit) GetShardIndex ¶
func (m *MsgFetchInit) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*MsgFetchInit) MaxPayloadLength ¶
func (m *MsgFetchInit) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type MsgFetchSmartContractInfo ¶
type MsgFetchSmartContractInfo struct { MsgID uint32 ContractAddr multivacaddress.Address ShardIndex shard.Index }
MsgFetchSmartContractInfo is a message to request smart contract info from storage node.
func (*MsgFetchSmartContractInfo) BtcDecode ¶
func (msg *MsgFetchSmartContractInfo) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decode the message.
func (*MsgFetchSmartContractInfo) BtcEncode ¶
func (msg *MsgFetchSmartContractInfo) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgFetchSmartContractInfo) Command ¶
func (msg *MsgFetchSmartContractInfo) Command() string
Command returns the protocol command string for the message.
func (*MsgFetchSmartContractInfo) GetShardIndex ¶
func (msg *MsgFetchSmartContractInfo) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*MsgFetchSmartContractInfo) MaxPayloadLength ¶
func (msg *MsgFetchSmartContractInfo) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type MsgFetchTxs ¶
MsgFetchTxs is a message to request transactions from storage node.
func (*MsgFetchTxs) BtcDecode ¶
func (m *MsgFetchTxs) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decode the message.
func (*MsgFetchTxs) BtcEncode ¶
func (m *MsgFetchTxs) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgFetchTxs) Command ¶
func (m *MsgFetchTxs) Command() string
Command returns the protocol command string for the message.
func (*MsgFetchTxs) GetShardIndex ¶
func (m *MsgFetchTxs) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*MsgFetchTxs) MaxPayloadLength ¶
func (m *MsgFetchTxs) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type MsgFilterAdd ¶
type MsgFilterAdd struct {
Data []byte
}
MsgFilterAdd implements the Message interface and represents a bitcoin filteradd message. It is used to add a data element to an existing Bloom filter.
This message was not added until protocol version BIP0037Version.
func NewMsgFilterAdd ¶
func NewMsgFilterAdd(data []byte) *MsgFilterAdd
NewMsgFilterAdd returns a new bitcoin filteradd message that conforms to the Message interface. See MsgFilterAdd for details.
func (*MsgFilterAdd) BtcDecode ¶
func (msg *MsgFilterAdd) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgFilterAdd) BtcEncode ¶
func (msg *MsgFilterAdd) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgFilterAdd) Command ¶
func (msg *MsgFilterAdd) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgFilterAdd) MaxPayloadLength ¶
func (msg *MsgFilterAdd) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgFilterClear ¶
type MsgFilterClear struct{}
MsgFilterClear implements the Message interface and represents a bitcoin filterclear message which is used to reset a Bloom filter.
This message was not added until protocol version BIP0037Version and has no payload.
func NewMsgFilterClear ¶
func NewMsgFilterClear() *MsgFilterClear
NewMsgFilterClear returns a new bitcoin filterclear message that conforms to the Message interface. See MsgFilterClear for details.
func (*MsgFilterClear) BtcDecode ¶
func (msg *MsgFilterClear) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgFilterClear) BtcEncode ¶
func (msg *MsgFilterClear) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgFilterClear) Command ¶
func (msg *MsgFilterClear) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgFilterClear) MaxPayloadLength ¶
func (msg *MsgFilterClear) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgFilterLoad ¶
type MsgFilterLoad struct { Filter []byte HashFuncs uint32 Tweak uint32 Flags BloomUpdateType }
MsgFilterLoad implements the Message interface and represents a bitcoin filterload message which is used to reset a Bloom filter.
This message was not added until protocol version BIP0037Version.
func NewMsgFilterLoad ¶
func NewMsgFilterLoad(filter []byte, hashFuncs uint32, tweak uint32, flags BloomUpdateType) *MsgFilterLoad
NewMsgFilterLoad returns a new bitcoin filterload message that conforms to the Message interface. See MsgFilterLoad for details.
func (*MsgFilterLoad) BtcDecode ¶
func (msg *MsgFilterLoad) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgFilterLoad) BtcEncode ¶
func (msg *MsgFilterLoad) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgFilterLoad) Command ¶
func (msg *MsgFilterLoad) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgFilterLoad) MaxPayloadLength ¶
func (msg *MsgFilterLoad) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgGetAddr ¶
type MsgGetAddr struct{}
MsgGetAddr implements the Message interface and represents a bitcoin getaddr message. It is used to request a list of known active peers on the network from a peer to help identify potential nodes. The list is returned via one or more addr messages (MsgAddr).
This message has no payload.
func NewMsgGetAddr ¶
func NewMsgGetAddr() *MsgGetAddr
NewMsgGetAddr returns a new bitcoin getaddr message that conforms to the Message interface. See MsgGetAddr for details.
func (*MsgGetAddr) BtcDecode ¶
func (msg *MsgGetAddr) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgGetAddr) BtcEncode ¶
func (msg *MsgGetAddr) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgGetAddr) Command ¶
func (msg *MsgGetAddr) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgGetAddr) MaxPayloadLength ¶
func (msg *MsgGetAddr) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgGetShardAddr ¶
MsgGetShardAddr defines the data structure of massage that get shard address.
func (*MsgGetShardAddr) BtcDecode ¶
func (m *MsgGetShardAddr) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*MsgGetShardAddr) BtcEncode ¶
func (m *MsgGetShardAddr) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgGetShardAddr) Command ¶
func (m *MsgGetShardAddr) Command() string
Command returns the protocol command string for the message.
func (*MsgGetShardAddr) MaxPayloadLength ¶
func (m *MsgGetShardAddr) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type MsgPing ¶
type MsgPing struct { // Unique value associated with message that is used to identify // specific ping message. Nonce uint64 }
MsgPing implements the Message interface and represents a bitcoin ping message.
For versions BIP0031Version and earlier, it is used primarily to confirm that a connection is still valid. A transmission error is typically interpreted as a closed connection and that the peer should be removed. For versions AFTER BIP0031Version it contains an identifier which can be returned in the pong message to determine network timing.
The payload for this message just consists of a nonce used for identifying it later.
func NewMsgPing ¶
NewMsgPing returns a new bitcoin ping message that conforms to the Message interface. See MsgPing for details.
func (*MsgPing) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgPing) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgPing) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgPing) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgPong ¶
type MsgPong struct { // Unique value associated with message that is used to identify // specific ping message. Nonce uint64 }
MsgPong implements the Message interface and represents a bitcoin pong message which is used primarily to confirm that a connection is still valid in response to a bitcoin ping message (MsgPing).
This message was not added until protocol versions AFTER BIP0031Version.
func NewMsgPong ¶
NewMsgPong returns a new bitcoin pong message that conforms to the Message interface. See MsgPong for details.
func (*MsgPong) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgPong) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgPong) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgPong) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgReSendSyncReq ¶
type MsgReSendSyncReq struct { }
MsgReSendSyncReq 用于同步过程中重新发送同步请求
func NewReSendSyncReq ¶
func NewReSendSyncReq() *MsgReSendSyncReq
NewReSendSyncReq create a resend sync request message.
func (*MsgReSendSyncReq) BtcDecode ¶
func (msg *MsgReSendSyncReq) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*MsgReSendSyncReq) BtcEncode ¶
func (msg *MsgReSendSyncReq) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgReSendSyncReq) Command ¶
func (msg *MsgReSendSyncReq) Command() string
Command returns the protocol command string for the message.
func (*MsgReSendSyncReq) MaxPayloadLength ¶
func (msg *MsgReSendSyncReq) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type MsgReject ¶
type MsgReject struct { // Cmd is the command for the message which was rejected such as // as CmdBlock or CmdTx. This can be obtained from the Command function // of a Message. Cmd string // RejectCode is a code indicating why the command was rejected. It // is encoded as a uint8 on the wire. Code RejectCode // Reason is a human-readable string with specific details (over and // above the reject code) about why the command was rejected. Reason string // Hash identifies a specific block or transaction that was rejected // and therefore only applies the MsgBlock and MsgTx messages. Hash chainhash.Hash }
MsgReject implements the Message interface and represents a bitcoin reject message.
This message was not added until protocol version RejectVersion.
func NewMsgReject ¶
func NewMsgReject(command string, code RejectCode, reason string) *MsgReject
NewMsgReject returns a new bitcoin reject message that conforms to the Message interface. See MsgReject for details.
func (*MsgReject) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgReject) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgReject) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgReject) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgReturnDeposit ¶
type MsgReturnDeposit struct { ShardIndex shard.Index Deposits []*OutWithProof }
MsgReturnDeposit is deposits data come from storagenode
func (*MsgReturnDeposit) BtcDecode ¶
func (msg *MsgReturnDeposit) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decode the message.
func (*MsgReturnDeposit) BtcEncode ¶
func (msg *MsgReturnDeposit) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgReturnDeposit) Command ¶
func (msg *MsgReturnDeposit) Command() string
Command returns the protocol command string for the message.
func (*MsgReturnDeposit) MaxPayloadLength ¶
func (msg *MsgReturnDeposit) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type MsgReturnInit ¶
type MsgReturnInit struct { ShardIndex shard.Index MsgID uint32 Ledger LedgerInfo RightPath merkle.MerklePath LatestHeader BlockHeader ShardHeight int64 TreeSize int64 Deposits []*OutWithProof }
MsgReturnInit defines a type of message return init.
func (*MsgReturnInit) BtcDecode ¶
func (msg *MsgReturnInit) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decode the message.
func (*MsgReturnInit) BtcEncode ¶
func (msg *MsgReturnInit) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgReturnInit) Command ¶
func (msg *MsgReturnInit) Command() string
Command returns the protocol command string for the message. TODO(zz)
func (*MsgReturnInit) GetShardIndex ¶
func (msg *MsgReturnInit) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*MsgReturnInit) MaxPayloadLength ¶
func (msg *MsgReturnInit) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. TODO?
type MsgReturnShardAddr ¶
type MsgReturnShardAddr struct {
Address []string
}
MsgReturnShardAddr defines the data structure of message return shard address.
func (*MsgReturnShardAddr) BtcDecode ¶
func (m *MsgReturnShardAddr) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*MsgReturnShardAddr) BtcEncode ¶
func (m *MsgReturnShardAddr) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgReturnShardAddr) Command ¶
func (m *MsgReturnShardAddr) Command() string
Command returns the protocol command string for the message.
func (*MsgReturnShardAddr) MaxPayloadLength ¶
func (m *MsgReturnShardAddr) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type MsgReturnTxs ¶
type MsgReturnTxs struct { MsgID uint32 ShardIndex shard.Index Txs []*MsgTxWithProofs SmartContractInfos []*SmartContractInfo }
MsgReturnTxs is a message to return a list of transactions (with proofs) and smart contracts from storage node to miner node.
For each transaction, if a smart contract is included, MsgReturnTxs will return the smart contract as well.
func (*MsgReturnTxs) BtcDecode ¶
func (msg *MsgReturnTxs) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgReturnTxs) BtcEncode ¶
func (msg *MsgReturnTxs) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgReturnTxs) Command ¶
func (msg *MsgReturnTxs) Command() string
Command returns the protocol command string for the message.
func (*MsgReturnTxs) GetShardIndex ¶
func (msg *MsgReturnTxs) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*MsgReturnTxs) MaxPayloadLength ¶
func (msg *MsgReturnTxs) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type MsgSeed ¶
type MsgSeed struct { ShardIndex shard.Index SignedCredential *SignedMsg `rlp:"nil"` LastSeedSig []byte InShardProof []byte }
MsgSeed is the data structure of seed message.
func (*MsgSeed) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgSeed) GetInShardProofs ¶
GetInShardProofs returns message's InShardProof.
func (*MsgSeed) GetShardIndex ¶
GetShardIndex returns the shardIndex.
func (*MsgSeed) GetSignedCredential ¶
GetSignedCredential returns the SignedCredential.
func (*MsgSeed) IsValidated ¶
IsValidated Verify the signature of ByzantineValue.
func (*MsgSeed) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type MsgSendHeaders ¶
type MsgSendHeaders struct{}
MsgSendHeaders implements the Message interface and represents a bitcoin sendheaders message. It is used to request the peer send block headers rather than inventory vectors.
This message has no payload and was not added until protocol versions starting with SendHeadersVersion.
func NewMsgSendHeaders ¶
func NewMsgSendHeaders() *MsgSendHeaders
NewMsgSendHeaders returns a new bitcoin sendheaders message that conforms to the Message interface. See MsgSendHeaders for details.
func (*MsgSendHeaders) BtcDecode ¶
func (msg *MsgSendHeaders) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgSendHeaders) BtcEncode ¶
func (msg *MsgSendHeaders) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgSendHeaders) Command ¶
func (msg *MsgSendHeaders) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgSendHeaders) MaxPayloadLength ¶
func (msg *MsgSendHeaders) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgStartNet ¶
type MsgStartNet struct { }
MsgStartNet ???
func (*MsgStartNet) BtcDecode ¶
func (m *MsgStartNet) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*MsgStartNet) BtcEncode ¶
func (m *MsgStartNet) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encode the message.
func (*MsgStartNet) Command ¶
func (m *MsgStartNet) Command() string
Command returns the command string.
func (*MsgStartNet) MaxPayloadLength ¶
func (m *MsgStartNet) MaxPayloadLength(uint32) uint32
MaxPayloadLength return the mac playload length of MsgStartNet.
type MsgSyncBlock ¶
MsgSyncBlock is a type of message sync block.
func NewMsgSyncBlock ¶
func NewMsgSyncBlock(s shard.Index, block *MsgBlock) *MsgSyncBlock
NewMsgSyncBlock creates a new messagesyncblock.
func (*MsgSyncBlock) BtcDecode ¶
func (msg *MsgSyncBlock) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*MsgSyncBlock) BtcEncode ¶
func (msg *MsgSyncBlock) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgSyncBlock) Command ¶
func (msg *MsgSyncBlock) Command() string
Command returns the protocol command string for the message.
func (*MsgSyncBlock) GetShardIndex ¶
func (msg *MsgSyncBlock) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*MsgSyncBlock) MaxPayloadLength ¶
func (msg *MsgSyncBlock) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type MsgSyncHeaders ¶
type MsgSyncHeaders struct { ReqShardIdx shard.Index Headers []*BlockHeader }
MsgSyncHeaders is used for passing back the requested header content during sync for a given shard.
func NewMsgSyncHeaders ¶
func NewMsgSyncHeaders(s shard.Index, headers []*BlockHeader) *MsgSyncHeaders
NewMsgSyncHeaders creates a new MsgSyncHeaders.
func (*MsgSyncHeaders) BtcDecode ¶
func (msg *MsgSyncHeaders) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*MsgSyncHeaders) BtcEncode ¶
func (msg *MsgSyncHeaders) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgSyncHeaders) Command ¶
func (msg *MsgSyncHeaders) Command() string
Command returns the protocol command string for the message.
func (*MsgSyncHeaders) GetShardIndex ¶
func (msg *MsgSyncHeaders) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*MsgSyncHeaders) MaxPayloadLength ¶
func (msg *MsgSyncHeaders) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type MsgSyncInv ¶
type MsgSyncInv struct { Type SyncInvType ReqShardIdx shard.Index InvGroups []*InvGroup }
MsgSyncInv is the message to send an inventory of header hashes for sync. Depending on different type specified in this struct, it represents: 1. A full list of all header hashes that are available for sync 2. A list of header hashes for a single fetch data request to get full content of a block or header.
func NewMsgSyncInv ¶
func NewMsgSyncInv(s shard.Index, t SyncInvType) *MsgSyncInv
NewMsgSyncInv create a sync inventory message.
func (*MsgSyncInv) AddInvGroup ¶
func (msg *MsgSyncInv) AddInvGroup(shardIdx shard.Index, hashes ...chainhash.Hash)
AddInvGroup add a group inventory.
func (*MsgSyncInv) BtcDecode ¶
func (msg *MsgSyncInv) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*MsgSyncInv) BtcEncode ¶
func (msg *MsgSyncInv) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgSyncInv) Command ¶
func (msg *MsgSyncInv) Command() string
Command returns the protocol command string for the message.
func (*MsgSyncInv) GetShardIndex ¶
func (msg *MsgSyncInv) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*MsgSyncInv) MaxPayloadLength ¶
func (msg *MsgSyncInv) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
func (*MsgSyncInv) String ¶
func (msg *MsgSyncInv) String() string
type MsgSyncReq ¶
type MsgSyncReq struct { // The shard we request sync for. ReqShardIdx shard.Index // The locator of requested blocks/headers for each shard. // Inclusive on both sides, aka: [fromHgt, toHgt] Locators []*BlockLocator }
MsgSyncReq is a message to request sync from another node.
func NewMsgSyncReq ¶
func NewMsgSyncReq(shardIdx shard.Index) *MsgSyncReq
NewMsgSyncReq create a new message MsgSyncReq.
func (*MsgSyncReq) AddBlockLocator ¶
func (msg *MsgSyncReq) AddBlockLocator(shardIdx shard.Index, fromHeight int64, toHeight int64)
AddBlockLocator add a blocklocator with given height.
func (*MsgSyncReq) AddBlockLocatorToRecent ¶
func (msg *MsgSyncReq) AddBlockLocatorToRecent(shardIdx shard.Index, fromHeight int64)
AddBlockLocatorToRecent add a recent blocklocator.
func (*MsgSyncReq) BtcDecode ¶
func (msg *MsgSyncReq) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*MsgSyncReq) BtcEncode ¶
func (msg *MsgSyncReq) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgSyncReq) Command ¶
func (msg *MsgSyncReq) Command() string
Command returns the protocol command string for the message.
func (*MsgSyncReq) GetShardIndex ¶
func (msg *MsgSyncReq) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*MsgSyncReq) MaxPayloadLength ¶
func (msg *MsgSyncReq) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
func (*MsgSyncReq) String ¶
func (msg *MsgSyncReq) String() string
type MsgSyncSlimBlock ¶
MsgSyncSlimBlock is a type of message sync block.
func NewMsgSyncSlimBlock ¶
func NewMsgSyncSlimBlock(s shard.Index, block *SlimBlock) *MsgSyncSlimBlock
NewMsgSyncSlimBlock creates a new messagesyncblock.
func (*MsgSyncSlimBlock) BtcDecode ¶
func (msg *MsgSyncSlimBlock) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*MsgSyncSlimBlock) BtcEncode ¶
func (msg *MsgSyncSlimBlock) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgSyncSlimBlock) Command ¶
func (msg *MsgSyncSlimBlock) Command() string
Command returns the protocol command string for the message.
func (*MsgSyncSlimBlock) GetShardIndex ¶
func (msg *MsgSyncSlimBlock) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*MsgSyncSlimBlock) MaxPayloadLength ¶
func (msg *MsgSyncSlimBlock) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type MsgTx ¶
type MsgTx struct { Version int32 `json:"Version"` Shard shard.Index `json:"Shard"` TxIn []*TxIn `json:"TxIn"` ContractAddress multivacaddress.Address `json:"ContractAddress"` API string `json:"API"` Params []byte `json:"Params"` Nonce uint64 `json:"Nonce"` PublicKey []byte `json:"PublicKey"` SignatureScript []byte `json:"SignatureScript"` StorageNodeAddress multivacaddress.Address `json:"StorageNodeAddress"` Memo string `json:"Memo"` }
MsgTx represents a tx message. Use the AddTxIn and AddTxOut functions to build up the list of transaction inputs and outputs.
func CreateRewardTx ¶
CreateRewardTx creates a standard reward transaction.
func NewMsgTx ¶
NewMsgTx returns a new bitcoin tx message that conforms to the Message interface. The return instance has a default version of TxVersion and there are no transaction inputs or outputs. Also, the lock time is set to zero to indicate the transaction is valid immediately as opposed to some time in future.
func (*MsgTx) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgTx) Deserialize ¶
Deserialize deserialize the message.
func (*MsgTx) GetFee ¶
GetFee Verifies the input and output values and calculates the transaction fee. Returns errors if the input output value is invalid, or fee is negative.
func (*MsgTx) GetShardForTx ¶
GetShardForTx returns the shard of a tx.
func (*MsgTx) IsEnoughForReward ¶
IsEnoughForReward judge whether the tx's value is enough for reward storage node.
func (*MsgTx) IsReduceTx ¶
IsReduceTx determine whether the tx is reduceTx
func (*MsgTx) IsSmartContractTx ¶
IsSmartContractTx determine if tx is a transaction that executes a smart contract
func (*MsgTx) IsTxInShard ¶
IsTxInShard returns if the tx belongs to the given shard.
func (*MsgTx) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgTx) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the block.
func (*MsgTx) SerializeSizeStripped ¶
SerializeSizeStripped returns the number of bytes it would take to serialize the block, excluding any witness data (if any).
func (MsgTx) SerializeWithoutSignatureAndPubKey ¶
SerializeWithoutSignatureAndPubKey serialize the message without
func (*MsgTx) SetSignatureScriptAndPubKey ¶
SetSignatureScriptAndPubKey When signing a transaction, use your private key to sign tx.DoubleSha256WithoutSignatureAndPubKey(), then pass publicKey and the signature into this method. See msgtx.go#Sign for example.
func (*MsgTx) Sign ¶
func (tx *MsgTx) Sign(privateKey *signature.PrivateKey)
Sign the transaction with a private key.
SetSignatureScript is more recommended, and it doesn't need private key. This method is to make testing easier.
func (MsgTx) TotalMtvValue ¶
TotalMtvValue returns the total MTV value of the given tx.
func (*MsgTx) VerifySignature ¶
VerifySignature verify the signature is valid.
func (*MsgTx) VerifyTransaction ¶
VerifyTransaction verifies whether the MsgTx is valid. 1. Its Signatures is correct and signed by same key as all outpoints. 2. All Txin are in same shard as the transation. 3. No duplicate Txins in the transaction. 4. All values are positive. 5. Verify whether the transaction is enough for reward storage node.
func (*MsgTx) VerifyWithdrawTx ¶
VerifyWithdrawTx verifies all withdraw TxIn are DepositOut.
type MsgTxBatch ¶
MsgTxBatch is a message is specifically used to batch Txs.
func (*MsgTxBatch) BtcDecode ¶
func (msg *MsgTxBatch) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*MsgTxBatch) BtcEncode ¶
func (msg *MsgTxBatch) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
func (*MsgTxBatch) Command ¶
func (msg *MsgTxBatch) Command() string
Command returns the protocol command string for the message.
func (*MsgTxBatch) GetShardIndex ¶
func (msg *MsgTxBatch) GetShardIndex() shard.Index
GetShardIndex returns the shardIndex.
func (*MsgTxBatch) MaxPayloadLength ¶
func (msg *MsgTxBatch) MaxPayloadLength(_ uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver.
func (*MsgTxBatch) String ¶
func (msg *MsgTxBatch) String() string
type MsgTxWithProofs ¶
type MsgTxWithProofs struct { Tx MsgTx // Merkle path in the tree of all OutStates in the shard. Proofs []merkle.MerklePath }
MsgTxWithProofs is used for propagating pending transactions between nodes.
func (*MsgTxWithProofs) BtcDecode ¶
func (msg *MsgTxWithProofs) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*MsgTxWithProofs) BtcEncode ¶
func (msg *MsgTxWithProofs) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encode the message.
func (*MsgTxWithProofs) Command ¶
func (msg *MsgTxWithProofs) Command() string
Command returns the command string.
func (*MsgTxWithProofs) Deserialize ¶
func (msg *MsgTxWithProofs) Deserialize(r io.Reader) error
Deserialize deserialize the message.
func (*MsgTxWithProofs) MaxPayloadLength ¶
func (msg *MsgTxWithProofs) MaxPayloadLength(_ uint32) uint32
MaxPayloadLength returns max block playload.
func (*MsgTxWithProofs) Serialize ¶
func (msg *MsgTxWithProofs) Serialize(w io.Writer) error
Serialize serialize the message.
func (*MsgTxWithProofs) ToBytesArray ¶
func (msg *MsgTxWithProofs) ToBytesArray() []byte
ToBytesArray serialize the message and return byte array.
func (*MsgTxWithProofs) VerifyTxWithProof ¶
func (msg *MsgTxWithProofs) VerifyTxWithProof(ledgerMerkleRoot *merkle.MerkleHash) error
VerifyTxWithProof verifies whether the msg is valid. 1. Verifies whether the transaction itself is valid, see MsgTx#verifyTransaction. 2. Verifies all the proofs are valid. 3. Verifies for each TxIn, there's a corresponding proof.
type MsgVerAck ¶
type MsgVerAck struct{}
MsgVerAck defines a bitcoin verack message which is used for a peer to acknowledge a version message (MsgVersion) after it has used the information to negotiate parameters. It implements the Message interface.
This message has no payload.
func NewMsgVerAck ¶
func NewMsgVerAck() *MsgVerAck
NewMsgVerAck returns a new bitcoin verack message that conforms to the Message interface.
func (*MsgVerAck) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation.
func (*MsgVerAck) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgVerAck) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgVerAck) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type MsgVersion ¶
type MsgVersion struct { // Version of the protocol the node is using. ProtocolVersion int32 // Bitfield which identifies the enabled services. Services ServiceFlag // Time the message was generated. This is encoded as an int64 on the wire. Timestamp time.Time // Address of the remote peer. AddrYou NetAddress // Address of the local peer. AddrMe NetAddress // Unique value associated with message that is used to detect self // connections. Nonce uint64 // The user agent that generated messsage. This is a encoded as a varString // on the wire. This has a max length of MaxUserAgentLen. UserAgent string // Last block seen by the generator of the version message. LastBlock int32 // Don't announce transactions to peer. DisableRelayTx bool }
MsgVersion implements the Message interface and represents a bitcoin version message. It is used for a peer to advertise itself as soon as an outbound connection is made. The remote peer then uses this information along with its own to negotiate. The remote peer must then respond with a version message of its own containing the negotiated values followed by a verack message (MsgVerAck). This exchange must take place before any further communication is allowed to proceed.
func NewMsgVersion ¶
func NewMsgVersion(me *NetAddress, you *NetAddress, nonce uint64, lastBlock int32) *MsgVersion
NewMsgVersion returns a new bitcoin version message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgVersion) AddService ¶
func (msg *MsgVersion) AddService(service ServiceFlag)
AddService adds service as a supported service by the peer generating the message.
func (*MsgVersion) AddUserAgent ¶
func (msg *MsgVersion) AddUserAgent(name string, version string, comments ...string) error
AddUserAgent adds a user agent to the user agent string for the version message. The version string is not defined to any strict format, although it is recommended to use the form "major.minor.revision" e.g. "2.6.41".
func (*MsgVersion) BtcDecode ¶
func (msg *MsgVersion) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. The version message is special in that the protocol version hasn't been negotiated yet. As a result, the pver field is ignored and any fields which are added in new versions are optional. This also mean that r must be a *bytes.Buffer so the number of remaining bytes can be ascertained.
This is part of the Message interface implementation.
func (*MsgVersion) BtcEncode ¶
func (msg *MsgVersion) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation.
func (*MsgVersion) Command ¶
func (msg *MsgVersion) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgVersion) HasService ¶
func (msg *MsgVersion) HasService(service ServiceFlag) bool
HasService returns whether the specified service is supported by the peer that generated the message.
func (*MsgVersion) MaxPayloadLength ¶
func (msg *MsgVersion) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type NetAddress ¶
type NetAddress struct { // Last time the address was seen. This is, unfortunately, encoded as a // uint32 on the wire and therefore is limited to 2106. This field is // not present in the bitcoin version message (MsgVersion) nor was it // added until protocol version >= NetAddressTimeVersion. Timestamp time.Time // Bitfield which identifies the services supported by the address. Services ServiceFlag // IP address of the peer. IP net.IP // Port the peer is using. This is encoded in big endian on the wire // which differs from most everything else. Port uint16 }
NetAddress defines information about a peer on the network including the time it was last seen, the services it supports, its IP address, and port.
func NewNetAddress ¶
func NewNetAddress(addr *net.TCPAddr, services ServiceFlag) *NetAddress
NewNetAddress returns a new NetAddress using the provided TCP address and supported services with defaults for the remaining fields.
func NewNetAddressIPPort ¶
func NewNetAddressIPPort(ip net.IP, port uint16, services ServiceFlag) *NetAddress
NewNetAddressIPPort returns a new NetAddress using the provided IP, port, and supported services with defaults for the remaining fields.
func NewNetAddressTimestamp ¶
func NewNetAddressTimestamp( timestamp time.Time, services ServiceFlag, ip net.IP, port uint16) *NetAddress
NewNetAddressTimestamp returns a new NetAddress using the provided timestamp, IP, port, and supported services. The timestamp is rounded to single second precision.
func (*NetAddress) AddService ¶
func (na *NetAddress) AddService(service ServiceFlag)
AddService adds service as a supported service by the peer generating the message.
func (*NetAddress) HasService ¶
func (na *NetAddress) HasService(service ServiceFlag) bool
HasService returns whether the specified service is supported by the address.
type NewRoundStartMessage ¶
type NewRoundStartMessage struct { ShardIndex shard.Index Round int Timestamp time.Time Seed chainhash.Hash Transaction *MsgTx `rlp:"nil"` }
NewRoundStartMessage is the message for starting new round.
func (*NewRoundStartMessage) BtcDecode ¶
func (msg *NewRoundStartMessage) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*NewRoundStartMessage) BtcEncode ¶
func (msg *NewRoundStartMessage) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode encode the message.
func (*NewRoundStartMessage) Command ¶
func (msg *NewRoundStartMessage) Command() string
Command returns the command string.
func (*NewRoundStartMessage) GetRound ¶
func (msg *NewRoundStartMessage) GetRound() int
GetRound returns the round of the message.
func (*NewRoundStartMessage) MaxPayloadLength ¶
func (msg *NewRoundStartMessage) MaxPayloadLength(_ uint32) uint32
MaxPayloadLength returns the max payload length
type OutPoint ¶
type OutPoint struct { Shard shard.Index `json:"Shard"` TxHash chainhash.Hash `json:"TxHash"` Index int `json:"Index"` UserAddress multivacaddress.Address `json:"UserAddress"` Type OutType `json:"OutType"` Data []byte `json:"Data"` ContractAddress multivacaddress.Address `json:"ContractAddress"` }
OutPoint defines a data type that is used to track previous transaction outputs.
func (*OutPoint) Deserialize ¶
Deserialize deserialize the message.
func (*OutPoint) IsBindingLock ¶
IsBindingLock check the binding tx is locked.
func (*OutPoint) IsDepositOut ¶
IsDepositOut returns if it is a deposit out.
func (*OutPoint) IsSmartContractCode ¶
IsSmartContractCode check if it is smart contract code.
func (*OutPoint) IsSmartContractShardInitOut ¶
IsSmartContractShardInitOut check if the out from smart contract.
func (*OutPoint) IsWithdrawOut ¶
IsWithdrawOut returns if it is a withdraw out.
func (*OutPoint) String ¶
TODO: Add pkhash and value into string. String returns the OutPoint in the human-readable form "hash:index".
func (*OutPoint) ToSpentOutState ¶
ToSpentOutState marks a OutPoint to spent state.
func (*OutPoint) ToUnspentOutState ¶
ToUnspentOutState marks a OutPoint to unspent state.
type OutState ¶
OutState is the state of an out point, usually either unused or used except for special out.
func (*OutState) ToBytesArray ¶
ToBytesArray converts OutState to bytes by using rlp.
type OutWithProof ¶
type OutWithProof struct { Out *OutPoint Proof *merkle.MerklePath Height BlockHeight }
OutWithProof contains outpoint and it's merkle path
type ReduceAction ¶
type ReduceAction struct { ToBeReducedOut *OutPoint // OutState that needs to be merged API string // ReduceAction needs to call the smart contract API }
ReduceAction is used to deal with the issue of cross-shard-update
type RejectCode ¶
type RejectCode uint8
RejectCode represents a numeric value by which a remote peer indicates why a message was rejected.
const ( RejectMalformed RejectCode = 0x01 RejectInvalid RejectCode = 0x10 RejectObsolete RejectCode = 0x11 RejectDuplicate RejectCode = 0x12 RejectNonstandard RejectCode = 0x40 RejectDust RejectCode = 0x41 RejectInsufficientFee RejectCode = 0x42 RejectCheckpoint RejectCode = 0x43 )
These constants define the various supported reject codes.
func (RejectCode) String ¶
func (code RejectCode) String() string
String returns the RejectCode in human-readable form.
type RelayHashMsg ¶
RelayHashMsg is a type of relay hash message.
func (*RelayHashMsg) BtcDecode ¶
func (msg *RelayHashMsg) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation. TODO(jylu)
func (*RelayHashMsg) BtcEncode ¶
func (msg *RelayHashMsg) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. TODO(jylu)
func (*RelayHashMsg) Command ¶
func (msg *RelayHashMsg) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*RelayHashMsg) Deserialize ¶
func (msg *RelayHashMsg) Deserialize(r io.Reader) error
Deserialize will deserialize the message. TODO(jylu)
func (*RelayHashMsg) MaxPayloadLength ¶
func (msg *RelayHashMsg) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type Serializable ¶
Serializable defines the interface for serialization.
type ServiceFlag ¶
type ServiceFlag uint64
ServiceFlag identifies services supported by a bitcoin peer.
const ( // SFNodeNetwork is a flag used to indicate a peer is a full node. SFNodeNetwork ServiceFlag = 1 << iota // SFNodeGetUTXO is a flag used to indicate a peer supports the // getutxos and utxos commands (BIP0064). SFNodeGetUTXO // SFNodeBloom is a flag used to indicate a peer supports bloom // filtering. SFNodeBloom // SFNodeWitness is a flag used to indicate a peer supports blocks // and transactions including witness data (BIP0144). SFNodeWitness // SFNodeXthin is a flag used to indicate a peer supports xthin blocks. SFNodeXthin // SFNodeBit5 is a flag used to indicate a peer supports a service // defined by bit 5. SFNodeBit5 // SFNodeCF is a flag used to indicate a peer supports committed // filters (CFs). SFNodeCF // SFNode2X is a flag used to indicate a peer is running the Segwit2X // software. SFNode2X )
func (ServiceFlag) String ¶
func (f ServiceFlag) String() string
String returns the ServiceFlag in human-readable form.
type ShardMessage ¶
ShardMessage defines the shard message interface to describe the message about shard.
type SignedMsg ¶
type SignedMsg struct { Pk []byte // pk is used for identify the signer Signature []byte Message ConsensusMsg }
SignedMsg represents a signed message by a user
type SlimBlock ¶
type SlimBlock struct { ToShard shard.Index Header BlockHeader ClipTreeData *ClipTreeData SmartContracts []*SmartContract UpdateActions []*UpdateAction Transactions []*MsgTxWithProofs LedgerInfo LedgerInfo }
SlimBlock defines the data structure of slimblock.
func GetSlimBlockFromBlockByShard ¶
GetSlimBlockFromBlockByShard 根据分片以及block返回剪枝后的SlimBlock
func GetSlimBlocksFromBlock ¶
GetSlimBlocksFromBlock 矿工将需要打包到SlimBlock的信息从一个块中提取出来.
func (*SlimBlock) BtcDecode ¶
BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface implementation. See Deserialize for decoding blocks stored to disk, such as in a database, as opposed to decoding blocks from the wire.
func (*SlimBlock) BtcEncode ¶
BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation. See Serialize for encoding blocks to be stored to disk, such as in a database, as opposed to encoding blocks for the wire.
func (*SlimBlock) GetShardIndex ¶
GetShardIndex returns the shardIndex.
func (*SlimBlock) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver.
type SmartContract ¶
type SmartContract struct { ContractAddr multivacaddress.Address APIList []string // Store a piece of code which is builded by VM Code []byte }
SmartContract defines the data structure of smart contract.
func (*SmartContract) Equal ¶
func (sc *SmartContract) Equal(s *SmartContract) bool
Equal check whether the two SmartContracts is equal.
func (*SmartContract) SmartContractHash ¶
func (sc *SmartContract) SmartContractHash() chainhash.Hash
SmartContractHash generates the Hash for the SmartContract.
type SmartContractInfo ¶
type SmartContractInfo struct { MsgID uint32 SmartContract *SmartContract // 智能合约数据 ShardIdx shard.Index // 分片编号 CodeOut *OutState // 智能合约代码Out CodeOutProof *merkle.MerklePath // 智能合约代码Out的merkle path ShardInitOut *OutState // 智能合约分片初始化数据 ShardInitOutProof *merkle.MerklePath // 智能合约分片初始化数据的merkle path }
SmartContractInfo defines the data structure of smart contract info.
func (*SmartContractInfo) BtcDecode ¶
func (msg *SmartContractInfo) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode use rlp serialization to decode message.
func (*SmartContractInfo) BtcEncode ¶
func (msg *SmartContractInfo) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode use rlp serialization to encode message.
func (*SmartContractInfo) Command ¶
func (msg *SmartContractInfo) Command() string
Command returns the command string.
func (*SmartContractInfo) MaxPayloadLength ¶
func (msg *SmartContractInfo) MaxPayloadLength(uint32) uint32
MaxPayloadLength returns the max playload of block.
func (*SmartContractInfo) Verify ¶
func (msg *SmartContractInfo) Verify(root *merkle.MerkleHash) error
Verify is to varify the smart contract info is right.
type TxIn ¶
type TxIn struct {
PreviousOutPoint OutPoint `json:"PreviousOutPoint"`
}
TxIn defines a bitcoin transaction input.
type UpdateAction ¶
type UpdateAction struct { OriginOut *OutState OriginOutProof *merkle.MerklePath NewOut *OutState }
UpdateAction 是矿工根据计算结果对存储节点发送的修改数据的请求
type UpdatePeerInfoMessage ¶
type UpdatePeerInfoMessage struct { Shards []shard.Index IsDNS bool IsStorageNode bool StorageNode []string RPCListenerAddress string LocalListenerAddress string }
UpdatePeerInfoMessage is the message for updating shards info.
func (*UpdatePeerInfoMessage) BtcDecode ¶
func (msg *UpdatePeerInfoMessage) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error
BtcDecode decode the message.
func (*UpdatePeerInfoMessage) BtcEncode ¶
func (msg *UpdatePeerInfoMessage) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error
BtcEncode serialize the message.
func (*UpdatePeerInfoMessage) Command ¶
func (msg *UpdatePeerInfoMessage) Command() string
Command returns the command string.
func (*UpdatePeerInfoMessage) GetShards ¶
func (msg *UpdatePeerInfoMessage) GetShards() []shard.Index
GetShards returns shard index slice.
func (*UpdatePeerInfoMessage) MaxPayloadLength ¶
func (msg *UpdatePeerInfoMessage) MaxPayloadLength(_ uint32) uint32
MaxPayloadLength returns the max playlod length.
Source Files ¶
- MsgFetchEncode.go
- blockheader.go
- common.go
- consensus_common.go
- doc.go
- error.go
- gc_message.go
- invvect.go
- leader_proposal_message.go
- leader_vote_message.go
- message.go
- msg_resendsyncreq.go
- msg_returninit.go
- msg_returntxs.go
- msg_syncblock.go
- msg_syncheaders.go
- msg_syncinv.go
- msg_syncreq.go
- msg_syncslimblock.go
- msg_tx_batch.go
- msgaddr.go
- msgalert.go
- msgbinaryba.go
- msgblock.go
- msgblockconfirmations.go
- msgfeefilter.go
- msgfetchdeposit.go
- msgfetchinit.go
- msgfetchsmartcontractinfo.go
- msgfetchtxs.go
- msgfilteradd.go
- msgfilterclear.go
- msgfilterload.go
- msggetaddr.go
- msgheartbeat.go
- msgping.go
- msgpong.go
- msgreject.go
- msgrelayhash.go
- msgreturndeposit.go
- msgseed.go
- msgsendheaders.go
- msgshardaddr.go
- msgslimblock.go
- msgstartnet.go
- msgtx.go
- msgtxwithproof.go
- msgverack.go
- msgversion.go
- netaddress.go
- new_round_start_message.go
- protocol.go
- reduceouts.go
- smartcontract.go
- update_shards_message.go
- updateouts.go