appmessage

package
v3.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultServices describes the default services that are supported by
	// the server.
	DefaultServices = SFNodeNetwork | SFNodeBloom | SFNodeCF
)
View Source
const MaxAddressesPerMsg = 1000

Variables

View Source
var DefaultUserAgent = fmt.Sprintf("/Metchaind:%s/", version.Version())
View Source
var RPCMessageCommandToString = map[MessageCommand]string{}

Add all RPC commands here

Functions

This section is empty.

Types

type BlockAddedNotificationMessage

type BlockAddedNotificationMessage struct {
	Block *RPCBlock
	// contains filtered or unexported fields
}

BlockAddedNotificationMessage is an appmessage corresponding to its respective RPC message

func NewBlockAddedNotificationMessage

func NewBlockAddedNotificationMessage(block *RPCBlock) *BlockAddedNotificationMessage

NewBlockAddedNotificationMessage returns a instance of the message

func (*BlockAddedNotificationMessage) MessageNumber

func (b *BlockAddedNotificationMessage) MessageNumber() uint64

func (*BlockAddedNotificationMessage) ReceivedAt

func (b *BlockAddedNotificationMessage) ReceivedAt() time.Time

func (*BlockAddedNotificationMessage) SetMessageNumber

func (b *BlockAddedNotificationMessage) SetMessageNumber(messageNumber uint64)

func (*BlockAddedNotificationMessage) SetReceivedAt

func (b *BlockAddedNotificationMessage) SetReceivedAt(receivedAt time.Time)

type EstimateNetworkHashesPerSecondRequestMessage

type EstimateNetworkHashesPerSecondRequestMessage struct {
	StartHash  string
	WindowSize uint32
	// contains filtered or unexported fields
}

EstimateNetworkHashesPerSecondRequestMessage is an appmessage corresponding to its respective RPC message

func NewEstimateNetworkHashesPerSecondRequestMessage

func NewEstimateNetworkHashesPerSecondRequestMessage(startHash string, windowSize uint32) *EstimateNetworkHashesPerSecondRequestMessage

NewEstimateNetworkHashesPerSecondRequestMessage returns a instance of the message

func (*EstimateNetworkHashesPerSecondRequestMessage) Command

Command returns the protocol command string for the message

func (*EstimateNetworkHashesPerSecondRequestMessage) MessageNumber

func (b *EstimateNetworkHashesPerSecondRequestMessage) MessageNumber() uint64

func (*EstimateNetworkHashesPerSecondRequestMessage) ReceivedAt

func (b *EstimateNetworkHashesPerSecondRequestMessage) ReceivedAt() time.Time

func (*EstimateNetworkHashesPerSecondRequestMessage) SetMessageNumber

func (b *EstimateNetworkHashesPerSecondRequestMessage) SetMessageNumber(messageNumber uint64)

func (*EstimateNetworkHashesPerSecondRequestMessage) SetReceivedAt

func (b *EstimateNetworkHashesPerSecondRequestMessage) SetReceivedAt(receivedAt time.Time)

type EstimateNetworkHashesPerSecondResponseMessage

type EstimateNetworkHashesPerSecondResponseMessage struct {
	NetworkHashesPerSecond uint64

	Error *RPCError
	// contains filtered or unexported fields
}

EstimateNetworkHashesPerSecondResponseMessage is an appmessage corresponding to its respective RPC message

func NewEstimateNetworkHashesPerSecondResponseMessage

func NewEstimateNetworkHashesPerSecondResponseMessage(networkHashesPerSecond uint64) *EstimateNetworkHashesPerSecondResponseMessage

NewEstimateNetworkHashesPerSecondResponseMessage returns a instance of the message

func (*EstimateNetworkHashesPerSecondResponseMessage) Command

Command returns the protocol command string for the message

func (*EstimateNetworkHashesPerSecondResponseMessage) MessageNumber

func (b *EstimateNetworkHashesPerSecondResponseMessage) MessageNumber() uint64

func (*EstimateNetworkHashesPerSecondResponseMessage) ReceivedAt

func (b *EstimateNetworkHashesPerSecondResponseMessage) ReceivedAt() time.Time

func (*EstimateNetworkHashesPerSecondResponseMessage) SetMessageNumber

func (b *EstimateNetworkHashesPerSecondResponseMessage) SetMessageNumber(messageNumber uint64)

func (*EstimateNetworkHashesPerSecondResponseMessage) SetReceivedAt

func (b *EstimateNetworkHashesPerSecondResponseMessage) SetReceivedAt(receivedAt time.Time)

type GetBalanceByAddressRequestMessage

type GetBalanceByAddressRequestMessage struct {
	Address string
	// contains filtered or unexported fields
}

GetBalanceByAddressRequestMessage is an appmessage corresponding to its respective RPC message

func NewGetBalanceByAddressRequest

func NewGetBalanceByAddressRequest(address string) *GetBalanceByAddressRequestMessage

NewGetBalanceByAddressRequest returns a instance of the message

func (*GetBalanceByAddressRequestMessage) Command

Command returns the protocol command string for the message

func (*GetBalanceByAddressRequestMessage) MessageNumber

func (b *GetBalanceByAddressRequestMessage) MessageNumber() uint64

func (*GetBalanceByAddressRequestMessage) ReceivedAt

func (b *GetBalanceByAddressRequestMessage) ReceivedAt() time.Time

func (*GetBalanceByAddressRequestMessage) SetMessageNumber

func (b *GetBalanceByAddressRequestMessage) SetMessageNumber(messageNumber uint64)

func (*GetBalanceByAddressRequestMessage) SetReceivedAt

func (b *GetBalanceByAddressRequestMessage) SetReceivedAt(receivedAt time.Time)

type GetBalanceByAddressResponseMessage

type GetBalanceByAddressResponseMessage struct {
	Balance uint64

	Error *RPCError
	// contains filtered or unexported fields
}

GetBalanceByAddressResponseMessage is an appmessage corresponding to its respective RPC message

func NewGetBalanceByAddressResponse

func NewGetBalanceByAddressResponse(Balance uint64) *GetBalanceByAddressResponseMessage

NewGetBalanceByAddressResponse returns an instance of the message

func (*GetBalanceByAddressResponseMessage) Command

Command returns the protocol command string for the message

func (*GetBalanceByAddressResponseMessage) MessageNumber

func (b *GetBalanceByAddressResponseMessage) MessageNumber() uint64

func (*GetBalanceByAddressResponseMessage) ReceivedAt

func (b *GetBalanceByAddressResponseMessage) ReceivedAt() time.Time

func (*GetBalanceByAddressResponseMessage) SetMessageNumber

func (b *GetBalanceByAddressResponseMessage) SetMessageNumber(messageNumber uint64)

func (*GetBalanceByAddressResponseMessage) SetReceivedAt

func (b *GetBalanceByAddressResponseMessage) SetReceivedAt(receivedAt time.Time)

type GetBlockDAGInfoRequestMessage

type GetBlockDAGInfoRequestMessage struct {
	// contains filtered or unexported fields
}

GetBlockDAGInfoRequestMessage is an appmessage corresponding to its respective RPC message

func NewGetBlockDAGInfoRequestMessage

func NewGetBlockDAGInfoRequestMessage() *GetBlockDAGInfoRequestMessage

NewGetBlockDAGInfoRequestMessage returns a instance of the message

func (*GetBlockDAGInfoRequestMessage) Command

Command returns the protocol command string for the message

func (*GetBlockDAGInfoRequestMessage) MessageNumber

func (b *GetBlockDAGInfoRequestMessage) MessageNumber() uint64

func (*GetBlockDAGInfoRequestMessage) ReceivedAt

func (b *GetBlockDAGInfoRequestMessage) ReceivedAt() time.Time

func (*GetBlockDAGInfoRequestMessage) SetMessageNumber

func (b *GetBlockDAGInfoRequestMessage) SetMessageNumber(messageNumber uint64)

func (*GetBlockDAGInfoRequestMessage) SetReceivedAt

func (b *GetBlockDAGInfoRequestMessage) SetReceivedAt(receivedAt time.Time)

type GetBlockDAGInfoResponseMessage

type GetBlockDAGInfoResponseMessage struct {
	NetworkName         string
	BlockCount          uint64
	HeaderCount         uint64
	TipHashes           []string
	VirtualParentHashes []string
	Difficulty          float64
	PastMedianTime      int64
	PruningPointHash    string
	VirtualDAAScore     uint64

	Error *RPCError
	// contains filtered or unexported fields
}

GetBlockDAGInfoResponseMessage is an appmessage corresponding to its respective RPC message

func NewGetBlockDAGInfoResponseMessage

func NewGetBlockDAGInfoResponseMessage() *GetBlockDAGInfoResponseMessage

NewGetBlockDAGInfoResponseMessage returns a instance of the message

func (*GetBlockDAGInfoResponseMessage) Command

Command returns the protocol command string for the message

func (*GetBlockDAGInfoResponseMessage) MessageNumber

func (b *GetBlockDAGInfoResponseMessage) MessageNumber() uint64

func (*GetBlockDAGInfoResponseMessage) ReceivedAt

func (b *GetBlockDAGInfoResponseMessage) ReceivedAt() time.Time

func (*GetBlockDAGInfoResponseMessage) SetMessageNumber

func (b *GetBlockDAGInfoResponseMessage) SetMessageNumber(messageNumber uint64)

func (*GetBlockDAGInfoResponseMessage) SetReceivedAt

func (b *GetBlockDAGInfoResponseMessage) SetReceivedAt(receivedAt time.Time)

type GetBlockTemplateRequestMessage

type GetBlockTemplateRequestMessage struct {
	PayAddress string
	ExtraData  string
	// contains filtered or unexported fields
}

GetBlockTemplateRequestMessage is an appmessage corresponding to its respective RPC message

func NewGetBlockTemplateRequestMessage

func NewGetBlockTemplateRequestMessage(payAddress, extraData string) *GetBlockTemplateRequestMessage

NewGetBlockTemplateRequestMessage returns a instance of the message

func (*GetBlockTemplateRequestMessage) Command

Command returns the protocol command string for the message

func (*GetBlockTemplateRequestMessage) MessageNumber

func (b *GetBlockTemplateRequestMessage) MessageNumber() uint64

func (*GetBlockTemplateRequestMessage) ReceivedAt

func (b *GetBlockTemplateRequestMessage) ReceivedAt() time.Time

func (*GetBlockTemplateRequestMessage) SetMessageNumber

func (b *GetBlockTemplateRequestMessage) SetMessageNumber(messageNumber uint64)

func (*GetBlockTemplateRequestMessage) SetReceivedAt

func (b *GetBlockTemplateRequestMessage) SetReceivedAt(receivedAt time.Time)

type GetBlockTemplateResponseMessage

type GetBlockTemplateResponseMessage struct {
	Block    *RPCBlock
	IsSynced bool

	Error *RPCError
	// contains filtered or unexported fields
}

GetBlockTemplateResponseMessage is an appmessage corresponding to its respective RPC message

func NewGetBlockTemplateResponseMessage

func NewGetBlockTemplateResponseMessage(block *RPCBlock, isSynced bool) *GetBlockTemplateResponseMessage

NewGetBlockTemplateResponseMessage returns a instance of the message

func (*GetBlockTemplateResponseMessage) Command

Command returns the protocol command string for the message

func (*GetBlockTemplateResponseMessage) MessageNumber

func (b *GetBlockTemplateResponseMessage) MessageNumber() uint64

func (*GetBlockTemplateResponseMessage) ReceivedAt

func (b *GetBlockTemplateResponseMessage) ReceivedAt() time.Time

func (*GetBlockTemplateResponseMessage) SetMessageNumber

func (b *GetBlockTemplateResponseMessage) SetMessageNumber(messageNumber uint64)

func (*GetBlockTemplateResponseMessage) SetReceivedAt

func (b *GetBlockTemplateResponseMessage) SetReceivedAt(receivedAt time.Time)

type GetInfoRequestMessage

type GetInfoRequestMessage struct {
	// contains filtered or unexported fields
}

GetInfoRequestMessage is an appmessage corresponding to its respective RPC message

func NewGetInfoRequestMessage

func NewGetInfoRequestMessage() *GetInfoRequestMessage

NewGetInfoRequestMessage returns a instance of the message

func (*GetInfoRequestMessage) Command

func (msg *GetInfoRequestMessage) Command() MessageCommand

Command returns the protocol command string for the message

func (*GetInfoRequestMessage) MessageNumber

func (b *GetInfoRequestMessage) MessageNumber() uint64

func (*GetInfoRequestMessage) ReceivedAt

func (b *GetInfoRequestMessage) ReceivedAt() time.Time

func (*GetInfoRequestMessage) SetMessageNumber

func (b *GetInfoRequestMessage) SetMessageNumber(messageNumber uint64)

func (*GetInfoRequestMessage) SetReceivedAt

func (b *GetInfoRequestMessage) SetReceivedAt(receivedAt time.Time)

type GetInfoResponseMessage

type GetInfoResponseMessage struct {
	P2PID         string
	MempoolSize   uint64
	ServerVersion string
	IsUtxoIndexed bool
	IsSynced      bool

	Error *RPCError
	// contains filtered or unexported fields
}

GetInfoResponseMessage is an appmessage corresponding to its respective RPC message

func NewGetInfoResponseMessage

func NewGetInfoResponseMessage(p2pID string, mempoolSize uint64, serverVersion string, isUtxoIndexed bool, isSynced bool) *GetInfoResponseMessage

NewGetInfoResponseMessage returns a instance of the message

func (*GetInfoResponseMessage) Command

func (msg *GetInfoResponseMessage) Command() MessageCommand

Command returns the protocol command string for the message

func (*GetInfoResponseMessage) MessageNumber

func (b *GetInfoResponseMessage) MessageNumber() uint64

func (*GetInfoResponseMessage) ReceivedAt

func (b *GetInfoResponseMessage) ReceivedAt() time.Time

func (*GetInfoResponseMessage) SetMessageNumber

func (b *GetInfoResponseMessage) SetMessageNumber(messageNumber uint64)

func (*GetInfoResponseMessage) SetReceivedAt

func (b *GetInfoResponseMessage) SetReceivedAt(receivedAt time.Time)

type Message

type Message interface {
	Command() MessageCommand
	MessageNumber() uint64
	SetMessageNumber(index uint64)
	ReceivedAt() time.Time
	SetReceivedAt(receivedAt time.Time)
}

type MessageCommand

type MessageCommand uint32

MessageCommand is a number in the header of a message that represents its type.

const (
	// protocol
	CmdVersion MessageCommand = iota
	CmdVerAck
	CmdRequestAddresses
	CmdAddresses
	CmdReady
	CmdReject
	CmdNotifyNewBlockTemplateResponseMessage
	CmdNewBlockTemplateNotificationMessage
	CmdNotifyNewBlockTemplateRequestMessage
	CmdBlock
	CmdGetBlockTemplateRequestMessage
	CmdSubmitBlockResponseMessage
	CmdSubmitBlockRequestMessage
	CmdGetBlockTemplateResponseMessage
	CmdGetBlockDAGInfoResponseMessage
	CmdGetBlockDAGInfoRequestMessage
	CmdGetBalanceByAddressResponseMessage
	CmdGetBalanceByAddressRequestMessage
	CmdEstimateNetworkHashesPerSecondResponseMessage
	CmdEstimateNetworkHashesPerSecondRequestMessage

	//RPC
	CmdGetInfoRequestMessage
	CmdGetInfoResponseMessage
)

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 Metchain 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 MetchainNet

type MetchainNet uint32
const (
	Mainnet      MetchainNet = 0x3ddcf71d
	MaxInvPerMsg             = 1 << 17
)

type MsgAddresses

type MsgAddresses struct {
	AddressList []*NetAddress
	// contains filtered or unexported fields
}

MsgAddresses implements the Message interface and represents a Metchain Addresses message.

func NewMsgAddresses

func NewMsgAddresses(addressList []*NetAddress) *MsgAddresses

func (*MsgAddresses) Command

func (msg *MsgAddresses) Command() MessageCommand

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

func (*MsgAddresses) MessageNumber

func (b *MsgAddresses) MessageNumber() uint64

func (*MsgAddresses) ReceivedAt

func (b *MsgAddresses) ReceivedAt() time.Time

func (*MsgAddresses) SetMessageNumber

func (b *MsgAddresses) SetMessageNumber(messageNumber uint64)

func (*MsgAddresses) SetReceivedAt

func (b *MsgAddresses) SetReceivedAt(receivedAt time.Time)

type MsgReady

type MsgReady struct {
	// contains filtered or unexported fields
}

MsgReady implements the Message interface and represents a Metchain Ready message. It is used to notify that the peer is ready to receive messages.

This message has no payload.

func NewMsgReady

func NewMsgReady() *MsgReady

NewMsgReady returns a new Metchain Ready message that conforms to the Message interface.

func (*MsgReady) Command

func (msg *MsgReady) Command() MessageCommand

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

func (*MsgReady) MessageNumber

func (b *MsgReady) MessageNumber() uint64

func (*MsgReady) ReceivedAt

func (b *MsgReady) ReceivedAt() time.Time

func (*MsgReady) SetMessageNumber

func (b *MsgReady) SetMessageNumber(messageNumber uint64)

func (*MsgReady) SetReceivedAt

func (b *MsgReady) SetReceivedAt(receivedAt time.Time)

type MsgReject

type MsgReject struct {
	Reason string
	// contains filtered or unexported fields
}

MsgReject implements the Message interface and represents a Metchain Reject message. It is used to notify peers why they are banned.

func NewMsgReject

func NewMsgReject(reason string) *MsgReject

NewMsgReject returns a new Metchain Reject message that conforms to the Message interface.

func (*MsgReject) Command

func (msg *MsgReject) Command() MessageCommand

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

func (*MsgReject) MessageNumber

func (b *MsgReject) MessageNumber() uint64

func (*MsgReject) ReceivedAt

func (b *MsgReject) ReceivedAt() time.Time

func (*MsgReject) SetMessageNumber

func (b *MsgReject) SetMessageNumber(messageNumber uint64)

func (*MsgReject) SetReceivedAt

func (b *MsgReject) SetReceivedAt(receivedAt time.Time)

type MsgRequestAddresses

type MsgRequestAddresses struct {
	IncludeAllSubnetworks bool
	SubnetworkID          *external.DomainSubnetworkID
	// contains filtered or unexported fields
}

MsgRequestAddresses implements the Message interface and represents a Metchain RequestAddresses 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 (MsgAddresses).

This message has no payload.

func NewMsgRequestAddresses

func NewMsgRequestAddresses(includeAllSubnetworks bool, subnetworkID *external.DomainSubnetworkID) *MsgRequestAddresses

NewMsgRequestAddresses returns a new Metchain RequestAddresses message that conforms to the Message interface. See MsgRequestAddresses for details.

func (*MsgRequestAddresses) Command

func (msg *MsgRequestAddresses) Command() MessageCommand

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

func (*MsgRequestAddresses) MessageNumber

func (b *MsgRequestAddresses) MessageNumber() uint64

func (*MsgRequestAddresses) ReceivedAt

func (b *MsgRequestAddresses) ReceivedAt() time.Time

func (*MsgRequestAddresses) SetMessageNumber

func (b *MsgRequestAddresses) SetMessageNumber(messageNumber uint64)

func (*MsgRequestAddresses) SetReceivedAt

func (b *MsgRequestAddresses) SetReceivedAt(receivedAt time.Time)

type MsgVerAck

type MsgVerAck struct {
	// contains filtered or unexported fields
}

func NewMsgVerAck

func NewMsgVerAck() *MsgVerAck

Message interface.

func (*MsgVerAck) Command

func (msg *MsgVerAck) Command() MessageCommand

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

func (*MsgVerAck) MessageNumber

func (b *MsgVerAck) MessageNumber() uint64

func (*MsgVerAck) ReceivedAt

func (b *MsgVerAck) ReceivedAt() time.Time

func (*MsgVerAck) SetMessageNumber

func (b *MsgVerAck) SetMessageNumber(messageNumber uint64)

func (*MsgVerAck) SetReceivedAt

func (b *MsgVerAck) SetReceivedAt(receivedAt time.Time)

type MsgVersion

type MsgVersion struct {

	// Version of the protocol the node is using.
	ProtocolVersion uint32

	// The peer's network (mainnet, testnet, etc.)
	Network string

	// Bitfield which identifies the enabled services.
	Services ServiceFlag

	// Time the message was generated. This is encoded as an int64 on the appmessage.
	Timestamp mstime.Time

	// Address of the local peer.
	Address *NetAddress

	// The peer unique ID
	ID *id.ID

	// The user agent that generated messsage. This is a encoded as a varString
	// on the appmessage. This has a max length of MaxUserAgentLen.
	UserAgent string

	// Don't announce transactions to peer.
	DisableRelayTx bool

	// The subnetwork of the generator of the version message. Should be nil in full nodes
	SubnetworkID *external.DomainSubnetworkID
	// contains filtered or unexported fields
}

func NewMsgVersion

func NewMsgVersion(addr *NetAddress, id *id.ID, network string,
	subnetworkID *external.DomainSubnetworkID, protocolVersion uint32) *MsgVersion

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)

func (*MsgVersion) Command

func (msg *MsgVersion) Command() MessageCommand

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

func (b *MsgVersion) MessageNumber() uint64

func (*MsgVersion) ReceivedAt

func (b *MsgVersion) ReceivedAt() time.Time

func (*MsgVersion) SetMessageNumber

func (b *MsgVersion) SetMessageNumber(messageNumber uint64)

func (*MsgVersion) SetReceivedAt

func (b *MsgVersion) SetReceivedAt(receivedAt time.Time)

type NetAddress

type NetAddress struct {
	// Last time the address was seen.
	Timestamp mstime.Time

	// IP address of the peer.
	IP net.IP

	// Port the peer is using. This is encoded in big endian on the appmessage
	// 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) *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) *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 mstime.Time, 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 millisecond precision.

func (NetAddress) String

func (na NetAddress) String() string

func (*NetAddress) TCPAddress

func (na *NetAddress) TCPAddress() *net.TCPAddr

TCPAddress converts the NetAddress to *net.TCPAddr

type NewBlockTemplateNotificationMessage

type NewBlockTemplateNotificationMessage struct {
	// contains filtered or unexported fields
}

NewBlockTemplateNotificationMessage is an appmessage corresponding to its respective RPC message

func NewNewBlockTemplateNotificationMessage

func NewNewBlockTemplateNotificationMessage() *NewBlockTemplateNotificationMessage

NewNewBlockTemplateNotificationMessage returns an instance of the message

func (*NewBlockTemplateNotificationMessage) Command

Command returns the protocol command string for the message

func (*NewBlockTemplateNotificationMessage) MessageNumber

func (b *NewBlockTemplateNotificationMessage) MessageNumber() uint64

func (*NewBlockTemplateNotificationMessage) ReceivedAt

func (b *NewBlockTemplateNotificationMessage) ReceivedAt() time.Time

func (*NewBlockTemplateNotificationMessage) SetMessageNumber

func (b *NewBlockTemplateNotificationMessage) SetMessageNumber(messageNumber uint64)

func (*NewBlockTemplateNotificationMessage) SetReceivedAt

func (b *NewBlockTemplateNotificationMessage) SetReceivedAt(receivedAt time.Time)

type NotifyNewBlockTemplateRequestMessage

type NotifyNewBlockTemplateRequestMessage struct {
	// contains filtered or unexported fields
}

NotifyNewBlockTemplateRequestMessage is an appmessage corresponding to its respective RPC message

func NewNotifyNewBlockTemplateRequestMessage

func NewNotifyNewBlockTemplateRequestMessage() *NotifyNewBlockTemplateRequestMessage

NewNotifyNewBlockTemplateRequestMessage returns an instance of the message

func (*NotifyNewBlockTemplateRequestMessage) Command

Command returns the protocol command string for the message

func (*NotifyNewBlockTemplateRequestMessage) MessageNumber

func (b *NotifyNewBlockTemplateRequestMessage) MessageNumber() uint64

func (*NotifyNewBlockTemplateRequestMessage) ReceivedAt

func (b *NotifyNewBlockTemplateRequestMessage) ReceivedAt() time.Time

func (*NotifyNewBlockTemplateRequestMessage) SetMessageNumber

func (b *NotifyNewBlockTemplateRequestMessage) SetMessageNumber(messageNumber uint64)

func (*NotifyNewBlockTemplateRequestMessage) SetReceivedAt

func (b *NotifyNewBlockTemplateRequestMessage) SetReceivedAt(receivedAt time.Time)

type NotifyNewBlockTemplateResponseMessage

type NotifyNewBlockTemplateResponseMessage struct {
	Error *RPCError
	// contains filtered or unexported fields
}

NotifyNewBlockTemplateResponseMessage is an appmessage corresponding to its respective RPC message

func NewNotifyNewBlockTemplateResponseMessage

func NewNotifyNewBlockTemplateResponseMessage() *NotifyNewBlockTemplateResponseMessage

NewNotifyNewBlockTemplateResponseMessage returns an instance of the message

func (*NotifyNewBlockTemplateResponseMessage) Command

Command returns the protocol command string for the message

func (*NotifyNewBlockTemplateResponseMessage) MessageNumber

func (b *NotifyNewBlockTemplateResponseMessage) MessageNumber() uint64

func (*NotifyNewBlockTemplateResponseMessage) ReceivedAt

func (b *NotifyNewBlockTemplateResponseMessage) ReceivedAt() time.Time

func (*NotifyNewBlockTemplateResponseMessage) SetMessageNumber

func (b *NotifyNewBlockTemplateResponseMessage) SetMessageNumber(messageNumber uint64)

func (*NotifyNewBlockTemplateResponseMessage) SetReceivedAt

func (b *NotifyNewBlockTemplateResponseMessage) SetReceivedAt(receivedAt time.Time)

type RPCBlock

type RPCBlock struct {
	Header *RPCBlockHeader

	VerboseData *RPCBlockVerboseData
}

RPCBlock is a Metchaind block representation meant to be used over RPC

func DomainBlockToRPCBlock

func DomainBlockToRPCBlock(block *external.DomainBlock) (*RPCBlock, *external.DomainBlock)

type RPCBlockHeader

type RPCBlockHeader struct {
	Version              uint32
	Parents              []*RPCBlockLevelParents
	HashMerkleRoot       string
	AcceptedIDMerkleRoot string
	UTXOCommitment       string
	Timestamp            int64
	Bits                 uint32
	Nonce                uint64
}

RPCBlockHeader is a Metchaind block header representation meant to be used over RPC

type RPCBlockLevelParents

type RPCBlockLevelParents struct {
	ParentHashes []string
}

RPCBlockLevelParents holds parent hashes for one block level

type RPCBlockVerboseData

type RPCBlockVerboseData struct {
	Hash                string
	Difficulty          float64
	SelectedParentHash  string
	TransactionIDs      []string
	IsHeaderOnly        bool
	BlueScore           uint64
	ChildrenHashes      []string
	MergeSetBluesHashes []string
	MergeSetRedsHashes  []string
	IsChainBlock        bool
}

RPCBlockVerboseData holds verbose data about a block

type RPCError

type RPCError struct {
	Message string
}

RPCError represents an error arriving from the RPC

func RPCErrorf

func RPCErrorf(format string, args ...interface{}) *RPCError

RPCErrorf formats according to a format specifier and returns the string as an RPCError.

func (RPCError) Error

func (err RPCError) Error() string

type RejectReason

type RejectReason byte

RejectReason describes the reason why a block sent by SubmitBlock was rejected

const (
	RejectReasonNone         RejectReason = 0
	RejectReasonBlockInvalid RejectReason = 1
	RejectReasonIsInIBD      RejectReason = 2
)

RejectReason constants Not using iota, since in the .proto file those are hardcoded

func (RejectReason) String

func (rr RejectReason) String() string

type ServiceFlag

type ServiceFlag uint64
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

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

type SubmitBlockRequestMessage

type SubmitBlockRequestMessage struct {
	Block             *RPCBlock
	AllowNonDAABlocks bool
	// contains filtered or unexported fields
}

func NewSubmitBlockRequestMessage

func NewSubmitBlockRequestMessage(block *RPCBlock, allowNonDAABlocks bool) *SubmitBlockRequestMessage

NewSubmitBlockRequestMessage returns a instance of the message

func (*SubmitBlockRequestMessage) Command

Command returns the protocol command string for the message

func (*SubmitBlockRequestMessage) MessageNumber

func (b *SubmitBlockRequestMessage) MessageNumber() uint64

func (*SubmitBlockRequestMessage) ReceivedAt

func (b *SubmitBlockRequestMessage) ReceivedAt() time.Time

func (*SubmitBlockRequestMessage) SetMessageNumber

func (b *SubmitBlockRequestMessage) SetMessageNumber(messageNumber uint64)

func (*SubmitBlockRequestMessage) SetReceivedAt

func (b *SubmitBlockRequestMessage) SetReceivedAt(receivedAt time.Time)

type SubmitBlockResponseMessage

type SubmitBlockResponseMessage struct {
	RejectReason RejectReason
	Error        *RPCError
	// contains filtered or unexported fields
}

SubmitBlockResponseMessage is an appmessage corresponding to its respective RPC message

func NewSubmitBlockResponseMessage

func NewSubmitBlockResponseMessage() *SubmitBlockResponseMessage

NewSubmitBlockResponseMessage returns an instance of the message

func (*SubmitBlockResponseMessage) Command

Command returns the protocol command string for the message

func (*SubmitBlockResponseMessage) MessageNumber

func (b *SubmitBlockResponseMessage) MessageNumber() uint64

func (*SubmitBlockResponseMessage) ReceivedAt

func (b *SubmitBlockResponseMessage) ReceivedAt() time.Time

func (*SubmitBlockResponseMessage) SetMessageNumber

func (b *SubmitBlockResponseMessage) SetMessageNumber(messageNumber uint64)

func (*SubmitBlockResponseMessage) SetReceivedAt

func (b *SubmitBlockResponseMessage) SetReceivedAt(receivedAt time.Time)

Jump to

Keyboard shortcuts

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