pkg

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AMS = "https://amsterdam.mainnet.block-engine.jito.wtf" // Amsterdam endpoint
	FRA = "https://frankfurt.mainnet.block-engine.jito.wtf" // Frankfurt endpoint
	NYC = "https://ny.mainnet.block-engine.jito.wtf"        // New York City endpoint
	TKO = "https://tokyo.mainnet.block-engine.jito.wtf"     // Tokyo endpoint
)

Constants for block engine endpoints

Variables

View Source
var (
	MemoPublicKey = solana.MustPublicKeyFromBase58("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr")
)

Functions

func BatchExtractSigFromTx

func BatchExtractSigFromTx(txs []*solana.Transaction) []solana.Signature

BatchExtractSigFromTx extracts the first signature from each Solana transaction in a batch. It iterates over the provided transactions and accumulates the first signature of each transaction in a slice. It returns a slice of signatures.

func CheckSignatureStatuses

func CheckSignatureStatuses(statuses *rpc.GetSignatureStatusesResult) bool

CheckSignatureStatuses verifies if all signatures in the given status result are non-nil. It returns true if all statuses are non-nil, otherwise returns false.

func ConvertBatchBytesToPublicKey

func ConvertBatchBytesToPublicKey(publicKeys [][]byte) []solana.PublicKey

ConvertBatchBytesToPublicKey converts a batch of byte slices into a slice of Solana public keys.

Parameters: - publicKeys: A slice of byte slices, where each byte slice represents a Solana public key.

Returns: - A slice of Solana public keys.

func ConvertBatchProtobufPacketToTransaction

func ConvertBatchProtobufPacketToTransaction(packets []*packet.Packet) ([]*solana.Transaction, error)

ConvertBatchProtobufPacketToTransaction converts a slice of protobuf packets to a slice of Solana transactions. It iterates over the provided packets, converts each one to a transaction, and accumulates the results in a slice.

func ConvertBatchPublicKeyToString

func ConvertBatchPublicKeyToString(publicKeys []solana.PublicKey) []string

ConvertBatchPublicKeyToString converts a batch of Solana public keys into a slice of strings.

Parameters: - publicKeys: A slice of Solana public keys.

Returns: - A slice of strings where each string is the string representation of the corresponding Solana public key.

func ConvertBatchTransactionToProtobufPacket

func ConvertBatchTransactionToProtobufPacket(transactions []*solana.Transaction) ([]*packet.Packet, error)

ConvertBatchTransactionToProtobufPacket converts a batch of Solana transactions to a slice of protobuf packets. It iterates over each transaction, converts it to a protobuf packet, and accumulates the results in a slice.

func ConvertBytesToPublicKey

func ConvertBytesToPublicKey(publicKey []byte) solana.PublicKey

ConvertBytesToPublicKey converts a single byte slice into a Solana public key.

Parameters: - publicKey: A byte slice representing a Solana public key.

Returns: - The corresponding Solana public key.

func ConvertProtobufPacketToTransaction

func ConvertProtobufPacketToTransaction(packet *packet.Packet) (*solana.Transaction, error)

ConvertProtobufPacketToTransaction converts a protobuf packet to a Solana transaction. It unmarshals the binary data in the packet into a Solana transaction.

func ConvertPublicKeyToString

func ConvertPublicKeyToString(publicKey solana.PublicKey) string

ConvertPublicKeyToString converts a single Solana public key into its string representation.

Parameters: - publicKey: A Solana public key.

Returns: - The string representation of the Solana public key.

func ConvertTransactionToProtobufPacket

func ConvertTransactionToProtobufPacket(transaction *solana.Transaction) (packet.Packet, error)

ConvertTransactionToProtobufPacket converts a Solana transaction to a protobuf packet. It marshals the transaction to binary data and creates a jito_pb.Packet with this data and associated metadata.

func CreateGRPCConnection

func CreateGRPCConnection(
	ctx context.Context,
	chErr chan error,
	grpcAddr string,
	opts ...grpc.DialOption,
) (*grpc.ClientConn, error)

CreateGRPCConnection creates and manages a gRPC connection with specified options and error handling. It takes a context, an error channel, the gRPC address, and additional gRPC dial options. It returns a gRPC client connection or an error if the connection setup fails.

func ExtractSigFromTx

func ExtractSigFromTx(tx *solana.Transaction) solana.Signature

ExtractSigFromTx extracts the first signature from a Solana transaction. It returns the first signature in the transaction's signature list.

func GetEndpoint

func GetEndpoint(location string) string

GetEndpoint returns the endpoint URL for the given location code. It returns an empty string if the location code is not recognized.

func LamportsToSol

func LamportsToSol(lamports *big.Float) *big.Float

LamportsToSol converts a given amount of lamports to SOL. It divides the lamports value by the constant LAMPORTS_PER_SOL and returns the result as a *big.Float.

func ValidateSignatureStatuses

func ValidateSignatureStatuses(statuses *rpc.GetSignatureStatusesResult) error

ValidateSignatureStatuses checks the confirmation status of each signature in the given status result. It returns an error if any signature status is not "processed" or "confirmed".

func ValidateTransaction

func ValidateTransaction(tx *solana.Transaction) bool

ValidateTransaction makes sure the bytes length of your transaction < 1232. If your transaction is bigger, Jito will return an error.

Types

type AuthenticationService

type AuthenticationService struct {
	AuthService auth.AuthServiceClient // Client for authentication service
	GRPCCtx     context.Context        // Context for gRPC operations
	KeyPair     *solana.PrivateKey     // Private key for signing challenges
	BearerToken string                 // Bearer token for authorization
	ExpiresAt   int64                  // Expiration time for the token
	ErrChan     chan error             // Channel for error handling
	// contains filtered or unexported fields
}

AuthenticationService handles the authentication logic for interacting with the gRPC services.

func NewAuthenticationService

func NewAuthenticationService(
	ctx context.Context,
	grpcConn *grpc.ClientConn,
	keyPair *solana.PrivateKey,
) *AuthenticationService

NewAuthenticationService creates a new instance of AuthenticationService.

func (*AuthenticationService) AuthenticateAndRefresh

func (as *AuthenticationService) AuthenticateAndRefresh(role auth.Role) error

AuthenticateAndRefresh handles the authentication and token refresh logic.

Jump to

Keyboard shortcuts

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