rpc

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JSONRPCEndpoint = "/faucet"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChallengeReply

type ChallengeReply struct {
	Salt       []byte `json:"salt"`
	Difficulty uint16 `json:"difficulty"`
}

type FaucetAddressReply

type FaucetAddressReply struct {
	Address string `json:"address"`
}

type JSONRPCClient

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

func NewJSONRPCClient

func NewJSONRPCClient(uri string) *JSONRPCClient

New creates a new client object.

func (*JSONRPCClient) Challenge

func (cli *JSONRPCClient) Challenge(ctx context.Context) ([]byte, uint16, error)

func (*JSONRPCClient) FaucetAddress

func (cli *JSONRPCClient) FaucetAddress(ctx context.Context) (string, error)

func (*JSONRPCClient) SolveChallenge

func (cli *JSONRPCClient) SolveChallenge(ctx context.Context, addr string, salt []byte, solution []byte) (ids.ID, uint64, error)

type JSONRPCServer

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

func NewJSONRPCServer

func NewJSONRPCServer(m Manager) *JSONRPCServer

func (*JSONRPCServer) Challenge

func (j *JSONRPCServer) Challenge(req *http.Request, _ *struct{}, reply *ChallengeReply) (err error)

func (*JSONRPCServer) FaucetAddress

func (j *JSONRPCServer) FaucetAddress(req *http.Request, _ *struct{}, reply *FaucetAddressReply) (err error)

func (*JSONRPCServer) SolveChallenge

func (j *JSONRPCServer) SolveChallenge(req *http.Request, args *SolveChallengeArgs, reply *SolveChallengeReply) error

type Manager

type Manager interface {
	GetFaucetAddress(context.Context) (ed25519.PublicKey, error)
	GetChallenge(context.Context) ([]byte, uint16, error)
	SolveChallenge(context.Context, ed25519.PublicKey, []byte, []byte) (ids.ID, uint64, error)
}

type SolveChallengeArgs

type SolveChallengeArgs struct {
	Address  string `json:"address"`
	Salt     []byte `json:"salt"`
	Solution []byte `json:"solution"`
}

type SolveChallengeReply

type SolveChallengeReply struct {
	TxID   ids.ID `json:"txID"`
	Amount uint64 `json:"amount"`
}

Jump to

Keyboard shortcuts

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