wire

package
Version: v0.0.0-...-dc87987 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2021 License: MIT Imports: 30 Imported by: 38

README

wire

Build Status ISC License GoDoc

Package wire implements the bitcoin wire protocol. A comprehensive suite of tests with 100% test coverage is provided to ensure proper functionality.

There is an associated blog post about the release of this package here.

This package has intentionally been designed so it can be used as a standalone package for any projects needing to interface with bitcoin peers at the wire protocol level.

Installation and Updating

$ go get -u github.com/multivactech/peer-server-test/wire

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.

Reading Messages Example

In order to unmarshal 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:

	// Use the most recent protocol version supported by the package and the
	// main bitcoin network.
	pver := wire.ProtocolVersion
	btcnet := wire.MainNet

	// 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
	}

See the package documentation for details on determining the message type.

Writing Messages Example

In order to marshal 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:

	// Use the most recent protocol version supported by the package and the
	// main bitcoin network.
	pver := wire.ProtocolVersion
	btcnet := wire.MainNet

	// 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
	}

GPG Verification Key

All official release tags are signed by Conformal so users can ensure the code has not been tampered with and is coming from the btcsuite developers. To verify the signature perform the following:

  • Download the public key from the Conformal website at https://opensource.conformal.com/GIT-GPG-KEY-conformal.txt

  • Import the public key into your GPG keyring:

    gpg --import GIT-GPG-KEY-conformal.txt
    
  • Verify the release tag with the following command where TAG_NAME is a placeholder for the specific tag:

    git tag -v TAG_NAME
    

License

Package wire is licensed under the copyfree ISC License.

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

View Source
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.

View Source
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.

View Source
const (
	// SyncInvTypeFullList is to sync inventory full list.
	SyncInvTypeFullList = iota
	// SyncInvTypeGetData is to sync inventory data.
	SyncInvTypeGetData
)
View Source
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
)
View Source
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
)
View Source
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
)
View Source
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.

View Source
const BlockVersion = 1

BlockVersion defines the version of block.

View Source
const CommandSize = 12

CommandSize is the fixed size of all commands in the common bitcoin message header. Shorter commands must be zero padded.

View Source
const DefaultUserAgent = "/btcwire:0.5.0/"

DefaultUserAgent for wire in the stack

View Source
const (
	// InvWitnessFlag denotes that the inventory vector type is requesting,
	// or sending a version which includes witness data.
	InvWitnessFlag = 1 << 30
)
View Source
const MaxAddrPerMsg = 1000

MaxAddrPerMsg is the maximum number of addresses that can be in a single bitcoin addr message (MsgAddr).

View Source
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.

View Source
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.

View Source
const MaxBlocksPerMsg = 500

MaxBlocksPerMsg is the maximum number of blocks allowed per message.

View Source
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
)
View Source
const MaxMessagePayload = (1024 * 1024 * 32) // 32MB

MaxMessagePayload is the maximum bytes a message can be regardless of other individual limits imposed by messages themselves.

View Source
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.

View Source
const MaxUserAgentLen = 256

MaxUserAgentLen is the maximum allowed length for the user agent field in a version message (MsgVersion).

View Source
const (
	// MaxVarIntPayload is the maximum payload size for a variable length integer.
	MaxVarIntPayload = 9
)
View Source
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.

View Source
const (
	// MsgReSendSyncReqMaxPayload is a very arbitrary number
	MsgReSendSyncReqMaxPayload = 4000000
)
View Source
const (
	// MsgSyncBlockMaxPayload is a very arbitrary number
	MsgSyncBlockMaxPayload = MaxBlockPayload
)
View Source
const (
	// MsgSyncHeadersMaxPayload is a very arbitrary number
	MsgSyncHeadersMaxPayload = MaxBlockPayload
)
View Source
const (
	// MsgSyncInvMaxPayload is a very arbitrary number
	MsgSyncInvMaxPayload = 4000000
)
View Source
const (
	// MsgSyncSlimBlockMaxPayload is a very arbitrary number
	MsgSyncSlimBlockMaxPayload = MaxBlockPayload
)

Variables

View Source
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)
)
View Source
var LargeMaxPayloadLength uint32 = 104857600

LargeMaxPayloadLength temporary Max payload length used for all messages.

View Source
var LatestEncoding = WitnessEncoding

LatestEncoding is the most recently specified encoding for the Bitcoin wire protocol.

Functions

func GetMtvValueFromOut

func GetMtvValueFromOut(op *OutPoint) *big.Int

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

func MsgShouldRelay(msg Message) bool

MsgShouldRelay checks if the message needs to relay.

func MtvValueToData

func MtvValueToData(value *big.Int) []byte

MtvValueToData writes the out Value into OutPoint.Data

func RandomUint64

func RandomUint64() (uint64, error)

RandomUint64 returns a cryptographically random uint64 value.

func ReadVarBytes

func ReadVarBytes(r io.Reader, pver uint32, maxAllowed uint32,
	fieldName string) ([]byte, error)

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

func ReadVarInt(r io.Reader, pver uint32) (uint64, error)

ReadVarInt reads a variable length integer from r and returns it as a uint64.

func ReadVarString

func ReadVarString(r io.Reader, pver uint32) (string, error)

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

func VarIntSerializeSize(val uint64) int

VarIntSerializeSize returns the number of bytes it would take to serialize val as a variable length integer.

func WriteMessage

func WriteMessage(w io.Writer, msg Message, pver uint32, btcnet BitcoinNet) error

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

func WriteMessageN(w io.Writer, msg Message, pver uint32, btcnet BitcoinNet) (int, error)

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

func WriteVarBytes(w io.Writer, pver uint32, bytes []byte) error

WriteVarBytes serializes a variable length byte array to w as a varInt containing the number of bytes, followed by the bytes themselves.

func WriteVarInt

func WriteVarInt(w io.Writer, pver uint32, val uint64) error

WriteVarInt serializes val to w using a variable number of bytes depending on its value.

func WriteVarString

func WriteVarString(w io.Writer, pver uint32, str string) error

WriteVarString serializes str to w as a variable length integer containing the length of the string followed by the bytes that represent the string itself.

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

func NewAlertFromPayload(serializedPayload []byte, pver uint32) (*Alert, error)

NewAlertFromPayload returns an Alert with values deserialized from the serialized payload.

func (*Alert) Deserialize

func (alert *Alert) Deserialize(r io.Reader, pver uint32) error

Deserialize decodes from r into the receiver using the alert protocol encoding format.

func (*Alert) Serialize

func (alert *Alert) Serialize(w io.Writer, pver uint32) error

Serialize encodes the alert to w 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

func (body *BlockBody) BlockBodyHash() chainhash.Hash

BlockBodyHash returns the block body hash.

func (*BlockBody) ToBytesArray

func (body *BlockBody) ToBytesArray() []byte

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 BlockHeight

type BlockHeight int64

BlockHeight defines the data structure of block height.

type BlockLocator

type BlockLocator struct {
	ShardIdx   shard.Index
	FromHeight int64
	ToHeight   int64
}

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

type Credential struct {
	Round int32
	Step  int32
}

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) BtcDecode

func (m *GCMessage) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error

BtcDecode decode the message.

func (*GCMessage) BtcEncode

func (m *GCMessage) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error

BtcEncode encodes the receiver to w using the bitcoin protocol encoding.

func (GCMessage) Command

func (GCMessage) Command() string

Command returns the protocol command string for the message.

func (*GCMessage) GetByzAgreementValue

func (m *GCMessage) GetByzAgreementValue() *ByzAgreementValue

GetByzAgreementValue returns the ByzAgreementValue of the message.

func (*GCMessage) GetInShardProofs

func (m *GCMessage) GetInShardProofs() [][]byte

GetInShardProofs returns the message's InShardProof

func (*GCMessage) GetRound

func (m *GCMessage) GetRound() int

GetRound returns the message's round.

func (*GCMessage) GetShardIndex

func (m *GCMessage) GetShardIndex() shard.Index

GetShardIndex returns the shardIndex.

func (*GCMessage) GetSignedCredential

func (m *GCMessage) GetSignedCredential() *SignedMsg

GetSignedCredential returns the message's SignedCredential.

func (*GCMessage) GetStep

func (m *GCMessage) GetStep() int

GetStep returns the message's step.

func (*GCMessage) IsValidated

func (m *GCMessage) IsValidated() (err error)

IsValidated returns whether the message is legal.

func (GCMessage) MaxPayloadLength

func (GCMessage) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum length the payload can be for the receiver.

func (*GCMessage) Sign

func (m *GCMessage) Sign(sk []byte) (err error)

Sign Message.

func (*GCMessage) String

func (m *GCMessage) String() string

String returns the format string for GCMessage.

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.

func (*HeartBeatMsg) Serialize

func (msg *HeartBeatMsg) Serialize(w io.Writer) error

Serialize will serialize the message. TODO(jylu)

type InvGroup

type InvGroup struct {
	Shard        shard.Index
	HeaderHashes []chainhash.Hash
}

InvGroup is group of inventory.

func NewInvGroup

func NewInvGroup(shardIdx shard.Index, hashes ...chainhash.Hash) *InvGroup

NewInvGroup create a inventory group.

func (*InvGroup) String

func (g *InvGroup) String() string

type InvType

type InvType uint32

InvType represents the allowed types of inventory vectors. See InvVect.

func (InvType) String

func (invtype InvType) String() string

String returns the InvType in human-readable form.

type InvVect

type InvVect struct {
	Type InvType        // Type of data
	Hash chainhash.Hash // Hash of the data
}

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.

func NewInvVect

func NewInvVect(typ InvType, hash *chainhash.Hash) *InvVect

NewInvVect returns a new InvVect using the provided type and hash.

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

type MTVCoinData struct {
	Value *big.Int
}

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

type MTVWithdrawData struct {
	Value          *big.Int
	WithdrawHeight int64
}

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

func ReadMessage(r io.Reader, pver uint32, btcnet BitcoinNet) (Message, []byte, error)

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

func ReadMessageN(r io.Reader, pver uint32, btcnet BitcoinNet) (int, Message, []byte, error)

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

func (msg *MsgAddr) 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 (*MsgAddr) BtcEncode

func (msg *MsgAddr) 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 (*MsgAddr) ClearAddresses

func (msg *MsgAddr) ClearAddresses()

ClearAddresses removes all addresses from the message.

func (*MsgAddr) Command

func (msg *MsgAddr) Command() string

Command returns the protocol command string for the message. This is part of the Message interface implementation.

func (*MsgAddr) MaxPayloadLength

func (msg *MsgAddr) 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 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

func NewMsgAlert(serializedPayload []byte, signature []byte) *MsgAlert

NewMsgAlert returns a new bitcoin alert message that conforms to the Message interface. See MsgAlert for details.

func (*MsgAlert) BtcDecode

func (msg *MsgAlert) 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 (*MsgAlert) BtcEncode

func (msg *MsgAlert) 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 (*MsgAlert) Command

func (msg *MsgAlert) Command() string

Command returns the protocol command string for the message. This is part of the Message interface implementation.

func (*MsgAlert) MaxPayloadLength

func (msg *MsgAlert) 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 MsgBinaryBA

type MsgBinaryBA struct {
	InShardProof           []byte
	SignedCredentialWithBA *SignedMsg `rlp:"nil"`
}

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) GetRound

func (m *MsgBinaryBA) GetRound() int

GetRound to return msg.round.

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) GetStep

func (m *MsgBinaryBA) GetStep() int

GetStep returns step.

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.

func (*MsgBinaryBA) Sign

func (m *MsgBinaryBA) Sign(sk []byte) (err error)

Sign Message.

func (MsgBinaryBA) String

func (m MsgBinaryBA) String() string

String returns the format string.

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

func (m *MsgBlock) 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 blocks stored to disk, such as in a database, as opposed to decoding blocks from the wire.

func (*MsgBlock) BtcEncode

func (m *MsgBlock) BtcEncode(w io.Writer, _ uint32, _ 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 blocks to be stored to disk, such as in a database, as opposed to encoding blocks for the wire.

func (*MsgBlock) Command

func (m *MsgBlock) Command() string

Command returns the protocol command string for the message.

func (*MsgBlock) Deserialize

func (m *MsgBlock) Deserialize(r io.Reader) error

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

func (m *MsgBlock) GetShardIndex() shard.Index

GetShardIndex returns the shardIndex.

func (*MsgBlock) MaxPayloadLength

func (m *MsgBlock) MaxPayloadLength(pver uint32) uint32

MaxPayloadLength returns the maximum length the payload can be for the receiver.

func (*MsgBlock) Serialize

func (m *MsgBlock) Serialize(w io.Writer) error

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

func (m *MsgBlock) SerializeNoWitness(w io.Writer) error

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

func (m *MsgBlock) SerializeSize() int

SerializeSize returns the number of bytes it would take to serialize the block.

func (*MsgBlock) SerializeSizeStripped

func (m *MsgBlock) SerializeSizeStripped() int

SerializeSizeStripped returns the number of bytes it would take to serialize the block, excluding any witness data (if any).

func (*MsgBlock) String

func (m *MsgBlock) String() string

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

type MsgFetchTxs struct {
	MsgID       uint32
	NumberOfTxs int
	ShardIndex  shard.Index
	ExistTx     []uint32
}

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

type MsgGetShardAddr struct {
	ShardIndex []shard.Index
}

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

func NewMsgPing(nonce uint64) *MsgPing

NewMsgPing returns a new bitcoin ping message that conforms to the Message interface. See MsgPing for details.

func (*MsgPing) BtcDecode

func (msg *MsgPing) 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 (*MsgPing) BtcEncode

func (msg *MsgPing) 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 (*MsgPing) Command

func (msg *MsgPing) Command() string

Command returns the protocol command string for the message. This is part of the Message interface implementation.

func (*MsgPing) MaxPayloadLength

func (msg *MsgPing) 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 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

func NewMsgPong(nonce uint64) *MsgPong

NewMsgPong returns a new bitcoin pong message that conforms to the Message interface. See MsgPong for details.

func (*MsgPong) BtcDecode

func (msg *MsgPong) 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 (*MsgPong) BtcEncode

func (msg *MsgPong) 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 (*MsgPong) Command

func (msg *MsgPong) Command() string

Command returns the protocol command string for the message. This is part of the Message interface implementation.

func (*MsgPong) MaxPayloadLength

func (msg *MsgPong) 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 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

func (msg *MsgReject) 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 (*MsgReject) BtcEncode

func (msg *MsgReject) 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 (*MsgReject) Command

func (msg *MsgReject) Command() string

Command returns the protocol command string for the message. This is part of the Message interface implementation.

func (*MsgReject) MaxPayloadLength

func (msg *MsgReject) 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 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) BtcDecode

func (m *MsgSeed) BtcDecode(r io.Reader, _ uint32, _ MessageEncoding) error

BtcDecode decode the message.

func (*MsgSeed) BtcEncode

func (m *MsgSeed) BtcEncode(w io.Writer, _ uint32, _ MessageEncoding) error

BtcEncode encodes the receiver to w using the bitcoin protocol encoding.

func (*MsgSeed) Command

func (m *MsgSeed) Command() string

Command returns the protocol command string for the message.

func (*MsgSeed) GetInShardProofs

func (m *MsgSeed) GetInShardProofs() [][]byte

GetInShardProofs returns message's InShardProof.

func (*MsgSeed) GetRound

func (m *MsgSeed) GetRound() int

GetRound get the round of message.

func (*MsgSeed) GetSender

func (m *MsgSeed) GetSender() []byte

GetSender returns the sender's pk.

func (*MsgSeed) GetShardIndex

func (m *MsgSeed) GetShardIndex() shard.Index

GetShardIndex returns the shardIndex.

func (*MsgSeed) GetSignedCredential

func (m *MsgSeed) GetSignedCredential() *SignedMsg

GetSignedCredential returns the SignedCredential.

func (*MsgSeed) GetStep

func (m *MsgSeed) GetStep() int

GetStep get the step of message.

func (*MsgSeed) IsValidated

func (m *MsgSeed) IsValidated() error

IsValidated Verify the signature of ByzantineValue.

func (*MsgSeed) MaxPayloadLength

func (m *MsgSeed) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum length the payload can be for the receiver.

func (*MsgSeed) Sign

func (m *MsgSeed) Sign(sk []byte) error

Sign Message.

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

type MsgSyncBlock struct {
	ReqShardIdx shard.Index
	Block       *MsgBlock
}

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

type MsgSyncSlimBlock struct {
	ReqShardIdx shard.Index
	SlimBlock   *SlimBlock
}

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

func CreateRewardTx(shardIdx shard.Index, height int64, pk chainhash.Hash) *MsgTx

CreateRewardTx creates a standard reward transaction.

func NewMsgTx

func NewMsgTx(version int32, shard shard.Index) *MsgTx

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) AddTxIn

func (tx *MsgTx) AddTxIn(ti *TxIn)

AddTxIn adds a transaction input to the message.

func (*MsgTx) BtcDecode

func (tx *MsgTx) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error

BtcDecode decode the message.

func (*MsgTx) BtcEncode

func (tx *MsgTx) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error

BtcEncode encode the message.

func (*MsgTx) Command

func (tx *MsgTx) Command() string

Command returns the protocol command string for the message. This is part of the Message interface implementation.

func (*MsgTx) Deserialize

func (tx *MsgTx) Deserialize(r io.Reader) error

Deserialize deserialize the message.

func (*MsgTx) GetFee

func (tx *MsgTx) GetFee() (*big.Int, error)

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

func (tx *MsgTx) GetShardForTx() shard.Index

GetShardForTx returns the shard of a tx.

func (*MsgTx) IsEnoughForReward

func (tx *MsgTx) IsEnoughForReward() bool

IsEnoughForReward judge whether the tx's value is enough for reward storage node.

func (*MsgTx) IsReduceTx

func (tx *MsgTx) IsReduceTx() bool

IsReduceTx determine whether the tx is reduceTx

func (*MsgTx) IsRewardTx

func (tx *MsgTx) IsRewardTx() bool

IsRewardTx check if it is reward tx.

func (*MsgTx) IsSmartContractTx

func (tx *MsgTx) IsSmartContractTx() bool

IsSmartContractTx determine if tx is a transaction that executes a smart contract

func (*MsgTx) IsTxInShard

func (tx *MsgTx) IsTxInShard(shardIndex shard.Index) bool

IsTxInShard returns if the tx belongs to the given shard.

func (*MsgTx) MaxPayloadLength

func (tx *MsgTx) MaxPayloadLength(pver uint32) uint32

MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.

func (*MsgTx) Serialize

func (tx *MsgTx) Serialize(w io.Writer) error

Serialize serialize the message.

func (*MsgTx) SerializeSize

func (tx *MsgTx) SerializeSize() int

SerializeSize returns the number of bytes it would take to serialize the block.

func (*MsgTx) SerializeSizeStripped

func (tx *MsgTx) SerializeSizeStripped() int

SerializeSizeStripped returns the number of bytes it would take to serialize the block, excluding any witness data (if any).

func (MsgTx) SerializeWithoutSignatureAndPubKey

func (tx MsgTx) SerializeWithoutSignatureAndPubKey() []byte

SerializeWithoutSignatureAndPubKey serialize the message without

func (*MsgTx) SetSignatureScriptAndPubKey

func (tx *MsgTx) SetSignatureScriptAndPubKey(publicKey signature.PublicKey, sig []byte)

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

func (tx MsgTx) TotalMtvValue() *big.Int

TotalMtvValue returns the total MTV value of the given tx.

func (*MsgTx) TxHash

func (tx *MsgTx) TxHash() chainhash.Hash

TxHash generates the Hash for the transaction.

func (*MsgTx) VerifySignature

func (tx *MsgTx) VerifySignature() bool

VerifySignature verify the signature is valid.

func (*MsgTx) VerifyTransaction

func (tx *MsgTx) VerifyTransaction() error

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

func (tx *MsgTx) VerifyWithdrawTx(blockHeight int64) error

VerifyWithdrawTx verifies all withdraw TxIn are DepositOut.

type MsgTxBatch

type MsgTxBatch struct {
	ShardIndex shard.Index
	Txs        []MsgTx
}

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

func (msg *MsgVerAck) 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 (*MsgVerAck) BtcEncode

func (msg *MsgVerAck) 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 (*MsgVerAck) Command

func (msg *MsgVerAck) Command() string

Command returns the protocol command string for the message. This is part of the Message interface implementation.

func (*MsgVerAck) MaxPayloadLength

func (msg *MsgVerAck) 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 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) BtcDecode

func (o *OutPoint) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error

BtcDecode decode the message.

func (*OutPoint) BtcEncode

func (o *OutPoint) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error

BtcEncode encode the message.

func (*OutPoint) Deserialize

func (o *OutPoint) Deserialize(r io.Reader) error

Deserialize deserialize the message.

func (*OutPoint) IsBindingLock

func (o *OutPoint) IsBindingLock(height int64) bool

IsBindingLock check the binding tx is locked.

func (*OutPoint) IsDepositOut

func (o *OutPoint) IsDepositOut() bool

IsDepositOut returns if it is a deposit out.

func (*OutPoint) IsLock

func (o *OutPoint) IsLock(height int64) bool

IsLock returns if the withdraw out is in locking.

func (*OutPoint) IsSmartContractCode

func (o *OutPoint) IsSmartContractCode() bool

IsSmartContractCode check if it is smart contract code.

func (*OutPoint) IsSmartContractShardInitOut

func (o *OutPoint) IsSmartContractShardInitOut() bool

IsSmartContractShardInitOut check if the out from smart contract.

func (*OutPoint) IsWithdrawOut

func (o *OutPoint) IsWithdrawOut() bool

IsWithdrawOut returns if it is a withdraw out.

func (*OutPoint) Serialize

func (o *OutPoint) Serialize(w io.Writer) error

Serialize serialize the message.

func (*OutPoint) String

func (o *OutPoint) String() string

TODO: Add pkhash and value into string. String returns the OutPoint in the human-readable form "hash:index".

func (*OutPoint) ToSpentOutState

func (o *OutPoint) ToSpentOutState() *OutState

ToSpentOutState marks a OutPoint to spent state.

func (*OutPoint) ToUnspentOutState

func (o *OutPoint) ToUnspentOutState() *OutState

ToUnspentOutState marks a OutPoint to unspent state.

type OutState

type OutState struct {
	OutPoint
	State byte
}

OutState is the state of an out point, usually either unused or used except for special out.

func (*OutState) ToBytesArray

func (out *OutState) ToBytesArray() []byte

ToBytesArray converts OutState to bytes by using rlp.

type OutType

type OutType byte

OutType is the type of tx out.

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

type RelayHashMsg struct {
	Relay   []string
	Request []string
}

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.

func (*RelayHashMsg) Serialize

func (msg *RelayHashMsg) Serialize(w io.Writer) error

Serialize encodes the block to w. TODO(jylu)

type Serializable

type Serializable interface {
	Serialize() ([]byte, error)
}

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

type ShardMessage interface {
	GetShardIndex() shard.Index
}

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

func GetSlimBlockFromBlockByShard(block *MsgBlock, shardIdx shard.Index) (*SlimBlock, error)

GetSlimBlockFromBlockByShard 根据分片以及block返回剪枝后的SlimBlock

func GetSlimBlocksFromBlock

func GetSlimBlocksFromBlock(block *MsgBlock) ([]*SlimBlock, error)

GetSlimBlocksFromBlock 矿工将需要打包到SlimBlock的信息从一个块中提取出来.

func (*SlimBlock) BtcDecode

func (m *SlimBlock) 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 blocks stored to disk, such as in a database, as opposed to decoding blocks from the wire.

func (*SlimBlock) BtcEncode

func (m *SlimBlock) BtcEncode(w io.Writer, _ uint32, _ 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 blocks to be stored to disk, such as in a database, as opposed to encoding blocks for the wire.

func (*SlimBlock) Command

func (m *SlimBlock) Command() string

Command returns the protocol command string for the message.

func (*SlimBlock) GetShardIndex

func (m *SlimBlock) GetShardIndex() shard.Index

GetShardIndex returns the shardIndex.

func (*SlimBlock) MaxPayloadLength

func (m *SlimBlock) MaxPayloadLength(pver uint32) uint32

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 SyncInvType

type SyncInvType int32

SyncInvType defines sync type.

type Timestamp

type Timestamp int64

Timestamp defines the type of time.

type TxIn

type TxIn struct {
	PreviousOutPoint OutPoint `json:"PreviousOutPoint"`
}

TxIn defines a bitcoin transaction input.

func NewTxIn

func NewTxIn(prevOut *OutPoint) *TxIn

NewTxIn returns a new bitcoin transaction input with the provided previous outpoint point and signature script.

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.

Jump to

Keyboard shortcuts

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