gohive

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

README

Go-Hive

A from scratch Go package for use with the Hive blockchain; with simplicty and ease of use for the user in mind.

This repo lives at git.sr.ht/~jrswab/go-hive

To submit bugs and/or feature requests please use todo.sr.ht/~jrswab/Go-Hive-Tracker

To stay up to date on Development send an email to ~jrswab/go-hive-dev+subscribe@lists.sr.ht

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountData

type AccountData struct {
	Active                        map[string]interface{} `json:"active"`
	Balance                       string                 `json:"balance"`
	CanVote                       bool                   `json:"can_vote"`
	CommentCount                  int                    `json:"comment_count"`
	Created                       string                 `json:"created"`
	CurationRewards               int                    `json:"curation_rewards"`
	DelegatedVestingShares        string                 `json:"delegated_vesting_shares"`
	DownVoteManaBar               map[string]interface{} `json:"down_vote_manabar"`
	GuestBloggers                 []string               `json:"guest_bloggers"`
	HbdBalance                    string                 `json:"sbd_balance"`
	HbdSeconds                    string                 `json:"sbd_seconds"`
	HbdSecondsLastUpdate          string                 `json:"sbd_seconds_last_update"`
	HbdLastInterestPayment        string                 `json:"sbd_last_interest_payment"`
	ID                            int                    `json:"id"`
	JSONMetadata                  string                 `json:"json_metadata"`
	LastAccountRecovery           string                 `json:"last_account_recovery"`
	LastAccountUpdate             string                 `json:"last_account_update"`
	LastOwnerUpdate               string                 `json:"last_owner_update"`
	LastPost                      string                 `json:"last_post"`
	LastRootPost                  string                 `json:"last_root_post"`
	LastVoteTime                  string                 `json:"last_vote_time"`
	LifetimeVoteCount             int                    `json:"lifetime_vote_count"`
	MarketHistory                 []interface{}          `json:"market_history"`
	MemoKey                       string                 `json:"memo_key"`
	Mined                         bool                   `json:"mined"`
	Name                          string                 `json:"name"`
	NextVestingWithdraw           string                 `json:"next_vesting_withdraw"`
	OtherHistory                  []interface{}          `json:"other_history"`
	Owner                         map[string]interface{} `json:"owner"`
	PendingClaimedAccounts        int                    `json:"pending_claimed_accounts"`
	PostBandwidth                 int                    `json:"post_bandwidth"`
	PostCount                     int                    `json:"post_count"`
	PostHistory                   []interface{}          `json:"post_history"`
	Posting                       interface{}            `json:"posting"`
	PostingJSONMetadata           string                 `json:"posting_json_metadata"`
	PostingRewards                float64                `json:"posting_rewards"`
	ProxiedVsfVotes               interface{}            `json:"proxied_vsf_votes"`
	Proxy                         string                 `json:"proxy"`
	ReceivedVestingShares         string                 `json:"recived_vesting_shares"`
	RecoveryAccount               string                 `json:"recovery_Account"`
	Reputation                    string                 `json:"reputation"`
	ResetAccount                  string                 `json:"reset_account"`
	RewardHBDBalance              string                 `json:"reward_sbd_balance"`
	RewardHiveBalance             string                 `json:"reward_steem_balance"`
	RewardVestingBalance          string                 `json:"reward_vesting_balance"`
	RewardVestingHive             string                 `json:"reward_vesting_steem"`
	SavingsBalance                string                 `json:"savings_balance"`
	SavingsHbdBalance             string                 `json:"savings_sbd_balance"`
	SavingsHbdSeconds             string                 `json:"savings_sbd_seconds"`
	SavingsHbdSecondsLastUpdate   string                 `json:"savings_sbd_seconds_last_update"`
	SavingsHbdLastInterestPayment string                 `json:"savings_sbd_last_interest_payment"`
	TagsUsage                     []string               `json:"tags_usage"`
	TransferHistory               []interface{}          `json:"transfer_history"`
	ToWithdraw                    int                    `json:"to_withdraw"`
	VestingBalance                string                 `json:"vesting_balance"`
	VestingShares                 string                 `json:"vesting_shares"`
	VestingWithdrawRate           string                 `json:"vesting_withdraw_rate"`
	VoteHistory                   []interface{}          `json:"vote_history"`
	VotingPower                   int                    `json:"voting_power"`
	Withdrawn                     int                    `json:"withdrawn"`
	WithdrawRoutes                int                    `json:"withdraw_routes"`
	WitnessesVotedFor             int                    `json:"witnesses_vote_for"`
	WitnessVotes                  []string               `json:"witness_votes"`
}

AccountData holds the output of the GetAccounts method.

type AccountReputation

type AccountReputation struct {
	Account    string `json:"account"`
	Reputation string `json:"reputation"`
}

AccountReputation is a struct for receiving data from GetAccountReputation()

type Caller

type Caller interface {
	CallRaw(*rpc.RPCRequest) (*rpc.RPCResponse, error)
}

Caller interface is used for testing purposes.

type Client

type Client struct {
	URL    string
	Client Caller
}

Client is used to pass data into unexposed functions. When defining a new JSONrpc use the `NewClient()` function for Hive API defaults. To specify an api endpoint execute `NewClient()` with a full URL.

func NewClient

func NewClient(URL ...string) *Client

NewClient creates an struct with Hive defaults. If wish to use a different Hive endpoint (or a different Graphene blockchain pass the URL as a parameter. Otherwise leave the parameters empty. If more than one URL is entered, only the first will be used. Example: hive := NewClient()

func (*Client) GetAccountBandwidth

func (c *Client) GetAccountBandwidth(account string) (int64, error)

GetAccountBandwidth returns the current "forum" average bandwidth for a given account. This currently returns "Could not find method" from api.hive.blog

func (*Client) GetAccountCount

func (c *Client) GetAccountCount() (int64, error)

GetAccountCount returns the current number of accounts on the network.

func (*Client) GetAccountHistory

func (c *Client) GetAccountHistory(acc string, start, limit int) (interface{}, error)

GetAccountHistory returns the history of an account.

func (*Client) GetAccountReputation

func (c *Client) GetAccountReputation(acc string) (int, error)

GetAccountReputation takes accounts name and returns a slice of type AccountReputation. Returns `-1` when error is not nil.

func (*Client) GetAccounts

func (c *Client) GetAccounts(acc ...string) (*[]AccountData, error)

GetAccounts updates a slice of account data for the accounts passed in. At least one account is required. Example: c := a.NewChain()

accData,err := c.GetAccounts("jrswab")

if err != nil {
	fmt.Println(err)
}

fmt.Println(data[0].Balance)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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