api

package
v0.0.0-...-00d0827 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 19 Imported by: 0

README

Staking API

Add a new method

  1. Add a method to StakingService in api.go:
    <method>(context.Context, <parameters>) (<result>, error)
    
  2. Add type constants MessageType<method>Request and MessageType<method>Response to the respective const blocks in types.go.
  3. Add a <method>Request type with the parameter types and a <method>Response type with a <result> Value field and any other types to the respective sections in types.yml. The request and response types must include union: { type: message }.
  4. Run type generation for the api package.
  5. Register the request and response types in the init function in types.go.
  6. Add case *<method>Request: to the method dispatch switch statement in NewMessageHandler in api.go.

Documentation

Index

Constants

View Source
const ServiceTypeStaking api.ServiceType = 0xF100

Variables

This section is empty.

Functions

func NewMessageHandler

func NewMessageHandler(svc StakingService, logger *slog.Logger) p2p.MessageStreamHandler

Types

type AccountStatus

type AccountStatus struct {
	Account    *types.Account `json:"account,omitempty" form:"account" query:"account" validate:"required"`
	Balance    *big.Int       `json:"balance,omitempty" form:"balance" query:"balance" validate:"required"`
	Deposits   *big.Int       `json:"deposits,omitempty" form:"deposits" query:"deposits" validate:"required"`
	Registered *url.TxID      `json:"registered,omitempty" form:"registered" query:"registered" validate:"required"`
	Staked     *TxWhen        `json:"staked,omitempty" form:"staked" query:"staked" validate:"required"`
	LastChange *TxWhen        `json:"lastChange,omitempty" form:"lastChange" query:"lastChange" validate:"required"`
	// contains filtered or unexported fields
}

func (*AccountStatus) Compare

func (a *AccountStatus) Compare(b *AccountStatus) int

func (*AccountStatus) Copy

func (v *AccountStatus) Copy() *AccountStatus

func (*AccountStatus) CopyAsInterface

func (v *AccountStatus) CopyAsInterface() interface{}

func (*AccountStatus) Equal

func (v *AccountStatus) Equal(u *AccountStatus) bool

func (*AccountStatus) IsValid

func (v *AccountStatus) IsValid() error

func (*AccountStatus) MarshalBinary

func (v *AccountStatus) MarshalBinary() ([]byte, error)

func (*AccountStatus) MarshalJSON

func (v *AccountStatus) MarshalJSON() ([]byte, error)

func (*AccountStatus) UnmarshalBinary

func (v *AccountStatus) UnmarshalBinary(data []byte) error

func (*AccountStatus) UnmarshalBinaryFrom

func (v *AccountStatus) UnmarshalBinaryFrom(rd io.Reader) error

func (*AccountStatus) UnmarshalJSON

func (v *AccountStatus) UnmarshalJSON(data []byte) error

type AccountStatusOptions

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

func (*AccountStatusOptions) Copy

func (*AccountStatusOptions) CopyAsInterface

func (v *AccountStatusOptions) CopyAsInterface() interface{}

func (*AccountStatusOptions) Equal

func (*AccountStatusOptions) IsValid

func (v *AccountStatusOptions) IsValid() error

func (*AccountStatusOptions) MarshalBinary

func (v *AccountStatusOptions) MarshalBinary() ([]byte, error)

func (*AccountStatusOptions) UnmarshalBinary

func (v *AccountStatusOptions) UnmarshalBinary(data []byte) error

func (*AccountStatusOptions) UnmarshalBinaryFrom

func (v *AccountStatusOptions) UnmarshalBinaryFrom(rd io.Reader) error

type AccountStatusRequest

type AccountStatusRequest struct {
	AccountStatusOptions
	Account *url.URL `json:"account,omitempty" form:"account" query:"account" validate:"required"`
	// contains filtered or unexported fields
}

func (*AccountStatusRequest) Copy

func (*AccountStatusRequest) CopyAsInterface

func (v *AccountStatusRequest) CopyAsInterface() interface{}

func (*AccountStatusRequest) Equal

func (*AccountStatusRequest) IsValid

func (v *AccountStatusRequest) IsValid() error

func (*AccountStatusRequest) MarshalBinary

func (v *AccountStatusRequest) MarshalBinary() ([]byte, error)

func (*AccountStatusRequest) MarshalJSON

func (v *AccountStatusRequest) MarshalJSON() ([]byte, error)

func (*AccountStatusRequest) Type

func (*AccountStatusRequest) UnmarshalBinary

func (v *AccountStatusRequest) UnmarshalBinary(data []byte) error

func (*AccountStatusRequest) UnmarshalBinaryFrom

func (v *AccountStatusRequest) UnmarshalBinaryFrom(rd io.Reader) error

func (*AccountStatusRequest) UnmarshalFieldsFrom

func (v *AccountStatusRequest) UnmarshalFieldsFrom(reader *encoding.Reader) error

func (*AccountStatusRequest) UnmarshalJSON

func (v *AccountStatusRequest) UnmarshalJSON(data []byte) error

type AccountStatusResponse

type AccountStatusResponse struct {
	Value *AccountStatus `json:"value,omitempty" form:"value" query:"value" validate:"required"`
	// contains filtered or unexported fields
}

func (*AccountStatusResponse) Copy

func (*AccountStatusResponse) CopyAsInterface

func (v *AccountStatusResponse) CopyAsInterface() interface{}

func (*AccountStatusResponse) Equal

func (*AccountStatusResponse) IsValid

func (v *AccountStatusResponse) IsValid() error

func (*AccountStatusResponse) MarshalBinary

func (v *AccountStatusResponse) MarshalBinary() ([]byte, error)

func (*AccountStatusResponse) MarshalJSON

func (v *AccountStatusResponse) MarshalJSON() ([]byte, error)

func (*AccountStatusResponse) Type

func (*AccountStatusResponse) UnmarshalBinary

func (v *AccountStatusResponse) UnmarshalBinary(data []byte) error

func (*AccountStatusResponse) UnmarshalBinaryFrom

func (v *AccountStatusResponse) UnmarshalBinaryFrom(rd io.Reader) error

func (*AccountStatusResponse) UnmarshalFieldsFrom

func (v *AccountStatusResponse) UnmarshalFieldsFrom(reader *encoding.Reader) error

func (*AccountStatusResponse) UnmarshalJSON

func (v *AccountStatusResponse) UnmarshalJSON(data []byte) error

type Message

type Message = message.Message

type MessageClient

type MessageClient struct {
	Transport message.Transport
}

func (*MessageClient) AccountStatus

func (c *MessageClient) AccountStatus(ctx context.Context, account *url.URL, opts AccountStatusOptions) (*AccountStatus, error)

AccountStatus implements api.StakingService.AccountStatus.

type MessageType

type MessageType = message.Type
const (
	MessageTypeAccountStatusRequest MessageType = 0xF101 + iota
)

Request types

const (
	MessageTypeAccountStatusResponse MessageType = 0xF121 + iota
)

Response types

type StakingService

type StakingService interface {
	AccountStatus(context.Context, *url.URL, AccountStatusOptions) (*AccountStatus, error)
}

type TxWhen

type TxWhen struct {
	TxID       *url.TxID            `json:"txID,omitempty" form:"txID" query:"txID" validate:"required"`
	Executed   *light.EventMetadata `json:"executed,omitempty" form:"executed" query:"executed" validate:"required"`
	MajorBlock uint64               `json:"majorBlock,omitempty" form:"majorBlock" query:"majorBlock" validate:"required"`
	// contains filtered or unexported fields
}

func (*TxWhen) Copy

func (v *TxWhen) Copy() *TxWhen

func (*TxWhen) CopyAsInterface

func (v *TxWhen) CopyAsInterface() interface{}

func (*TxWhen) Equal

func (v *TxWhen) Equal(u *TxWhen) bool

func (*TxWhen) IsValid

func (v *TxWhen) IsValid() error

func (*TxWhen) MarshalBinary

func (v *TxWhen) MarshalBinary() ([]byte, error)

func (*TxWhen) UnmarshalBinary

func (v *TxWhen) UnmarshalBinary(data []byte) error

func (*TxWhen) UnmarshalBinaryFrom

func (v *TxWhen) UnmarshalBinaryFrom(rd io.Reader) error

Jump to

Keyboard shortcuts

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