bssapi

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Generic RPC commands
	CmdPingRequest  = "bssapi-ping-request"
	CmdPingResponse = "bssapi-ping-response"

	// Custom RPC commands
	CmdPopPayoutRequest                     protocol.Command = "bssapi-pop-payout-request"
	CmdPopPayoutResponse                    protocol.Command = "bssapi-pop-payout-response"
	CmdL2KeystoneRequest                    protocol.Command = "bssapi-l2-keystone-request"
	CmdL2KeystoneResponse                   protocol.Command = "bssapi-l2-keystone-response"
	CmdBTCFinalityByRecentKeystonesRequest  protocol.Command = "bssapi-btc-finality-by-recent-keystones-request"
	CmdBTCFinalityByRecentKeystonesResponse protocol.Command = "bssapi-btc-finality-by-recent-keystones-response"
	CmdBTCFinalityByKeystonesRequest        protocol.Command = "bssapi-btc-finality-by-keystones-request"
	CmdBTCFinalityByKeystonesResponse       protocol.Command = "bssapi-btc-finality-by-keystones-response"
	CmdBTCFinalityNotification              protocol.Command = "bssapi-btc-finality-notification"
	CmdBTCNewBlockNotification              protocol.Command = "bssapi-btc-new-block-notification"
)
View Source
const (
	APIVersion = 1
)

Variables

View Source
var (
	APIVersionRoute         = fmt.Sprintf("v%d", APIVersion)
	RouteWebsocket          = fmt.Sprintf("/%s/ws", APIVersionRoute)
	DefaultListen           = "localhost:8081"
	DefaultPrometheusListen = "localhost:2112"
	DefaultURL              = "ws://" + DefaultListen + RouteWebsocket
)

Functions

func APICommands

func APICommands() map[protocol.Command]reflect.Type

func Call

func Call(ctx context.Context, c *protocol.Conn, payload any) (protocol.Command, string, any, error)

Call executes a blocking RPC call. Note that this requires the client to provide a ReadConn in a for loop in order to receive commands. This may be fixed in the future but seems simple enough to just leave alone for now. The need for the ReadConn loop is because apiCmd is not exported.

func Read

Read reads a command from an APIConn. This is used server side.

func ReadConn

func ReadConn(ctx context.Context, c *protocol.Conn) (protocol.Command, string, any, error)

ReadConn reads a command from a protocol.Conn. This is used client side.

func Write

func Write(ctx context.Context, c protocol.APIConn, id string, payload any) error

Write writes a command to an APIConn. This is used server side.

func WriteConn

func WriteConn(ctx context.Context, c *protocol.Conn, id string, payload any) error

WriteConn writes a command to a protocol.Conn. This is used client side.

Types

type BTCFinalityByKeystonesRequest

type BTCFinalityByKeystonesRequest struct {
	L2Keystones []hemi.L2Keystone `json:"l2_keystones"`
}

type BTCFinalityByKeystonesResponse

type BTCFinalityByKeystonesResponse struct {
	L2BTCFinalities []hemi.L2BTCFinality `json:"l2_btc_finalities"`
	Error           *protocol.Error      `json:"error,omitempty"`
}

type BTCFinalityByRecentKeystonesRequest

type BTCFinalityByRecentKeystonesRequest struct {
	NumRecentKeystones uint32 `json:"num_recent_keystones"`
}

type BTCFinalityByRecentKeystonesResponse

type BTCFinalityByRecentKeystonesResponse struct {
	L2BTCFinalities []hemi.L2BTCFinality `json:"l2_btc_finalities"`
	Error           *protocol.Error      `json:"error,omitempty"`
}

type BTCFinalityNotification

type BTCFinalityNotification struct{}

type BTCNewBlockNotification

type BTCNewBlockNotification struct{}

type L2KeystoneRequest

type L2KeystoneRequest struct {
	L2Keystone hemi.L2Keystone
}

type L2KeystoneResponse

type L2KeystoneResponse struct {
	Error *protocol.Error `json:"error,omitempty"`
}

type OptimismKeystone

type OptimismKeystone hemi.L2Keystone // dop only

type PingRequest

type PingRequest protocol.PingRequest

type PingResponse

type PingResponse protocol.PingResponse

type PopPayout

type PopPayout struct {
	MinerAddress common.Address `json:"miner_address"`
	Amount       *big.Int       `json:"amount"`
}

type PopPayoutsRequest

type PopPayoutsRequest struct {
	L2BlockForPayout api.ByteSlice `json:"l2_block_for_payout"`

	// these are unused at this point, they will be used in the future to determine the
	// total payout to miners
	PopDifficultyNumerator   uint64 `json:"popDifficultyNumerator,omitempty"`
	PopDifficultyDenominator uint64 `json:"popDifficultyDenominator,omitempty"`
}

type PopPayoutsResponse

type PopPayoutsResponse struct {
	PopPayouts []PopPayout `json:"pop_payouts"`

	// unused for now
	PopScore uint64 `json:"pop_score,omitempty"`

	Error *protocol.Error `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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