Documentation ¶
Index ¶
- Constants
- func AddressFromPublicKey(pubKey *ecdsa.PublicKey) string
- func DecodeMessageAndSignature(data string) (string, string, error)
- func EncodeMessageAndSignature(message string, signature string) (string, error)
- func HashPersonalMessage(message []byte) []byte
- func HexToBytes(hexStr string) ([]byte, error)
- func RecoverPubKey(hash, signature []byte) (*ecdsa.PublicKey, error)
- func SelectPseudorandomMiner(miners []string, blockHeight int64, appHash []byte, serviceID string) string
- type ClientRatingMsg
- type ClientRegistrationMsg
- type Message
- type MessageContent
- type MinerRegistrationMsg
- type MinerRewardClaimMsg
- type MinerServiceDoneMsg
- type MinerStatusUpdateMsg
- type ServiceRequestMsg
- type ServiceStartingMsg
- type Transaction
Constants ¶
View Source
const ( ClientRegistrationType = 1 ServiceRequestType = 2 ClientRatingMsgType = 3 MinerRegistrationType = 4 MinerServiceDoneType = 5 MinerStatusUpdateType = 6 MinerRewardClaimType = 7 MinerServiceStartingType = 8 )
View Source
const PersonalMessagePrefix = "\x19Ethereum Signed Message:\n"
PersonalMessagePrefix is the prefix used by the eth_sign method in MetaMask.
Variables ¶
This section is empty.
Functions ¶
func AddressFromPublicKey ¶
AddressFromPublicKey derives the Ethereum address from a public key.
func HashPersonalMessage ¶
HashPersonalMessage hashes a message according to the personal_sign spec.
func HexToBytes ¶
HexToBytes converts a hex string to a byte array.
func RecoverPubKey ¶
RecoverPubKey recovers the public key from a hash and a signature.
Types ¶
type ClientRatingMsg ¶
type ClientRatingMsg struct { ReviewedMinerAddr string `json:"miner_addr"` Rating int `json:"rating"` }
func (ClientRatingMsg) ToBytes ¶
func (m ClientRatingMsg) ToBytes() ([]byte, error)
type ClientRegistrationMsg ¶
type ClientRegistrationMsg struct {
ClientName string `json:"client_name"`
}
func (ClientRegistrationMsg) ToBytes ¶
func (m ClientRegistrationMsg) ToBytes() ([]byte, error)
Implement ToBytes for each struct
type Message ¶
func (*Message) DecodeContent ¶
func (m *Message) DecodeContent() (MessageContent, error)
func (Message) MarshalJSON ¶
MarshalJSON customizes the JSON encoding of the Message struct
func (*Message) UnmarshalJSON ¶
UnmarshalJSON customizes the JSON decoding of the Message struct
type MessageContent ¶
type MinerRegistrationMsg ¶
type MinerRegistrationMsg struct { MinerName string `json:"miner_name"` // The name of the miner ServiceTypes []uint64 `json:"service_types"` // An array of service type identifiers IP string `json:"ip"` // The IP address of the miner for network connections Status uint8 `json:"status"` }
func (MinerRegistrationMsg) ToBytes ¶
func (m MinerRegistrationMsg) ToBytes() ([]byte, error)
type MinerRewardClaimMsg ¶
type MinerRewardClaimMsg struct{}
func (MinerRewardClaimMsg) ToBytes ¶
func (m MinerRewardClaimMsg) ToBytes() ([]byte, error)
type MinerServiceDoneMsg ¶
type MinerServiceDoneMsg struct { ServiceID string `json:"service_id"` // Unique identifier for the service ServiceType uint64 `json:"service_type"` // Numeric identifier of the type of service completed }
func (MinerServiceDoneMsg) ToBytes ¶
func (m MinerServiceDoneMsg) ToBytes() ([]byte, error)
type MinerStatusUpdateMsg ¶
type MinerStatusUpdateMsg struct { AddServiceTypes []uint64 `json:"service_types"` RemoveServiceTypes []uint64 `json:"service_types"` Status uint8 `json:"status"` }
func (MinerStatusUpdateMsg) ToBytes ¶
func (m MinerStatusUpdateMsg) ToBytes() ([]byte, error)
type ServiceRequestMsg ¶
func (ServiceRequestMsg) ToBytes ¶
func (m ServiceRequestMsg) ToBytes() ([]byte, error)
type ServiceStartingMsg ¶
type ServiceStartingMsg struct { ServiceID string `json:"service_id"` // Unique identifier for the service MaxTimeoutBlock int64 `json:"max_timeout_block"` // Maximum number of blocks the service should run before automatic termination }
ServiceStartingMsg defines the data structure for initiating a service process.
func (ServiceStartingMsg) ToBytes ¶
func (m ServiceStartingMsg) ToBytes() ([]byte, error)
ToBytes converts the ServiceStartingMsg to a byte slice for easy transmission and storage.
type Transaction ¶
func (*Transaction) FromString ¶
func (t *Transaction) FromString(encodedString string) error
func (Transaction) ToString ¶
func (t Transaction) ToString() (string, error)
Click to show internal directories.
Click to hide internal directories.