util

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxReqContentLen = 1 << 23
	MaxTwitterLen    = 280
)

Variables

View Source
var (
	Version             string
	Commit              string
	BuildTime           string
	ErrSignInvalid      = errors.New("invalid signature")
	ErrSignNoAddr       = errors.New("no public address found")
	ErrSignNotMatch     = errors.New("signature address not match")
	ErrHttpEmptyRequest = errors.New("empty http post")
)
View Source
var LogFileName = "server.log"

Functions

func ConvertLongTweetToImg

func ConvertLongTweetToImg(txt string, f *truetype.Font, fontSize float64) (image.Image, error)

func DecryptRandomData

func DecryptRandomData(encryptedData string, passphrase []byte) (*big.Int, error)

func GenerateRandomData

func GenerateRandomData(passphrase []byte) (string, []byte, error)

func IsValidTwitterContent added in v1.0.1

func IsValidTwitterContent(text string) bool

func LogInst

func LogInst() *zerolog.Logger

func ParseTemplates

func ParseTemplates(path string) *template.Template

func ParseTweet added in v1.0.1

func ParseTweet(text string) (int, bool)

ParseTweet calculates the length of a tweet text based on Twitter's specific rules.

func RandomBytesInHex

func RandomBytesInHex(count int) string

func ReadRequest

func ReadRequest(request *http.Request, obj any) error

func SetLogLevel

func SetLogLevel(ll, file string)

func SplitIntoChunks

func SplitIntoChunks(text string, chunkSize int) []string

func TruncateString

func TruncateString(raw, append string) string

func Verify

func Verify(address, message, signedMessage string) (string, error)

Types

type Block added in v1.0.1

type Block struct {
	BaseFeePerGas    string `json:"baseFeePerGas"`
	Difficulty       string `json:"difficulty"`
	ExtraData        string `json:"extraData"`
	GasLimit         string `json:"gasLimit"`
	GasUsed          string `json:"gasUsed"`
	Hash             string `json:"hash"`
	L1BlockNumber    string `json:"l1BlockNumber"`
	LogsBloom        string `json:"logsBloom"`
	Miner            string `json:"miner"`
	MixHash          string `json:"mixHash"`
	Nonce            string `json:"nonce"`
	Number           string `json:"number"`
	ParentHash       string `json:"parentHash"`
	ReceiptsRoot     string `json:"receiptsRoot"`
	SendCount        string `json:"sendCount"`
	SendRoot         string `json:"sendRoot"`
	Sha3Uncles       string `json:"sha3Uncles"`
	Size             string `json:"size"`
	StateRoot        string `json:"stateRoot"`
	Timestamp        string `json:"timestamp"`
	TimeStamp2       *big.Int
	TotalDifficulty  string   `json:"totalDifficulty"`
	Transactions     []string `json:"transactions"`
	TransactionsRoot string   `json:"transactionsRoot"`
	Uncles           []string `json:"uncles"`
}

func GetBlockByNumber added in v1.0.1

func GetBlockByNumber(url string, blockNum *big.Int) (*Block, error)

type JsonResponse added in v1.0.1

type JsonResponse struct {
	Jsonrpc string `json:"jsonrpc"`
	ID      int    `json:"id"`
	Result  Block  `json:"result"`
}

Jump to

Keyboard shortcuts

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