Documentation ¶
Index ¶
- Variables
- type Account
- type AddAccountInput
- type AddAccountPayload
- type AddPaymentReceiptInput
- type AddPaymentReceiptPayload
- type AddrsAndPorts
- type AnnotatedBalance
- type Block
- type BlockConnection
- type BlockEdge
- type BlockFilterInput
- type BlockProducerTimings
- type BlockchainState
- type ChainReorganizationStatus
- type Client
- func (c Client) ConsensusTip() (*Block, error)
- func (c Client) Execute(ctx context.Context, q string) (*GraphResponse, error)
- func (c Client) GetAccount(publicKey string) (*Account, error)
- func (c Client) GetBestChain() ([]Block, error)
- func (c Client) GetBlock(hash string) (*Block, error)
- func (c Client) GetBlocks(filter string) ([]Block, error)
- func (c Client) GetCurrentHeight() (int64, error)
- func (c Client) GetDaemonStatus(ctx context.Context) (*DaemonStatus, error)
- func (c Client) GetFirstBlock() (*Block, error)
- func (c Client) GetFirstBlocks(n int) ([]Block, error)
- func (c Client) GetLastBlock() (*Block, error)
- func (c Client) GetNextBlock(after string) (*Block, error)
- func (c Client) GetNextBlocks(after string, n int) ([]Block, error)
- func (c Client) GetPendingTransactions() ([]PendingTransaction, error)
- func (c Client) GetSingleBlock(filter string) (*Block, error)
- func (c Client) Query(input string, out interface{}) error
- func (c Client) QueryWithContext(ctx context.Context, input string, out interface{}) error
- func (c *Client) SetDebug(enabled bool)
- type CompletedWork
- type ConsensusConfiguration
- type ConsensusState
- type ConsensusTime
- type CreateHDAccountInput
- type DaemonStatus
- type DeleteAccountInput
- type DeleteAccountPayload
- type EpochLedger
- type FeeTransfer
- type Genesis
- type GenesisAccount
- type GraphError
- type GraphResponse
- type Histogram
- type Histograms
- type Interval
- type LockInput
- type LockPayload
- type NextEpochData
- type PageInfo
- type Peer
- type PendingSnarkWork
- type PendingTransaction
- type ProtocolState
- type ProtocolStateProof
- type RPCPair
- type RPCTimings
- type ReloadAccountsPayload
- type SendDelegationInput
- type SendDelegationPayload
- type SendPaymentInput
- type SendPaymentPayload
- type SetSnarkWorkFee
- type SetSnarkWorkFeePayload
- type SetSnarkWorkerInput
- type SetSnarkWorkerPayload
- type SetStakingInput
- type SetStakingPayload
- type Sign
- type SignatureInput
- type SignedFee
- type SnarkWorker
- type StakingEpochData
- type SyncStatus
- type TransactionStatus
- type Transactions
- type TrustStatusPayload
- type UnlockInput
- type UnlockPayload
- type UserCommand
- type WorkDescription
Constants ¶
This section is empty.
Variables ¶
var ( ErrBlockNotFound = errors.New("block not found") ErrBlockInvalid = errors.New("block is invalid") )
var AllChainReorganizationStatus = []ChainReorganizationStatus{ ChainReorganizationStatusChanged, }
var AllSign = []Sign{ SignPlus, SignMinus, }
var AllSyncStatus = []SyncStatus{ SyncStatusConnecting, SyncStatusListening, SyncStatusOffline, SyncStatusBootstrap, SyncStatusSynced, SyncStatusCatchup, }
var AllTransactionStatus = []TransactionStatus{ TransactionStatusIncluded, TransactionStatusPending, TransactionStatusUnknown, }
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { // The public identity of the account PublicKey string `json:"publicKey"` // The amount of coda owned by the account Balance *AnnotatedBalance `json:"balance"` // A natural number that increases with each transaction (stringified uint32) Nonce *string `json:"nonce"` // Like the `nonce` field, except it includes the scheduled transactions (transactions not yet included in a block) (stringified uint32) InferredNonce *string `json:"inferredNonce"` // The account that you delegated on the staking ledger of the current block's epoch EpochDelegateAccount *Account `json:"epochDelegateAccount"` // Top hash of the receipt chain merkle-list ReceiptChainHash *string `json:"receiptChainHash"` // The public key to which you are delegating - if you are not delegating to anybody, this would return your public key Delegate *string `json:"delegate"` // The account to which you are delegating - if you are not delegating to anybody, this would return your public key DelegateAccount *Account `json:"delegateAccount"` // The list of accounts which are delegating to you (note that the info is recorded in the last epoch so it might not be up to date with the current account status) Delegators []*Account `json:"delegators"` // The list of accounts which are delegating to you in the last epoch (note that the info is recorded in the one before last epoch epoch so it might not be up to date with the current account status) LastEpochDelegators []*Account `json:"lastEpochDelegators"` // The previous epoch lock hash of the chain which you are voting for VotingFor *string `json:"votingFor"` // True if you are actively staking with this account on the current daemon - this may not yet have been updated if the staking key was changed recently StakingActive bool `json:"stakingActive"` // Path of the private key file for this account PrivateKeyPath string `json:"privateKeyPath"` // True if locked, false if unlocked, null if the account isn't tracked by the queried daemon Locked *bool `json:"locked"` }
An account record according to the daemon
type AddAccountInput ¶
type AddAccountInput struct { // Password used to encrypt the new account Password string `json:"password"` }
type AddAccountPayload ¶
type AddPaymentReceiptInput ¶
type AddPaymentReceiptInput struct { // Time that a payment gets added to another clients transaction database (stringified Unix time - number of milliseconds since January 1, 1970) AddedTime string `json:"added_time"` // Serialized payment (base58-encoded janestreet/bin_prot serialization) Payment string `json:"payment"` }
type AddPaymentReceiptPayload ¶
type AddPaymentReceiptPayload struct {
Payment *UserCommand `json:"payment"`
}
type AddrsAndPorts ¶
type AnnotatedBalance ¶
type AnnotatedBalance struct { // The amount of coda owned by the account Total string `json:"total"` // The amount of coda owned by the account whose origin is currently unknown Unknown string `json:"unknown"` // Block height at which balance was measured BlockHeight string `json:"blockHeight"` }
A total balance annotated with the amount that is currently unknown with the invariant: unknown <= total
type Block ¶
type Block struct { // Public key of account that produced this block Creator string `json:"creator"` // Account that produced this block CreatorAccount *Account `json:"creatorAccount"` // Base58Check-encoded hash of the state after this block StateHash string `json:"stateHash"` // Experimental: Bigint field-element representation of stateHash StateHashField string `json:"stateHashField"` ProtocolState *ProtocolState `json:"protocolState"` // Snark proof of blockchain state ProtocolStateProof *ProtocolStateProof `json:"protocolStateProof"` Transactions *Transactions `json:"transactions"` SnarkJobs []*CompletedWork `json:"snarkJobs"` // WinnerAccount that wins this block WinnerAccount *Account `json:"winnerAccount"` }
type BlockConnection ¶
type BlockConnection struct { Edges []*BlockEdge `json:"edges"` Nodes []*Block `json:"nodes"` TotalCount int `json:"totalCount"` PageInfo *PageInfo `json:"pageInfo"` }
Connection as described by the Relay connections spec
type BlockEdge ¶
type BlockEdge struct { // Opaque pagination cursor for a block (base58-encoded janestreet/bin_prot serialization) Cursor string `json:"cursor"` Node *Block `json:"node"` }
Connection Edge as described by the Relay connections spec
type BlockFilterInput ¶
type BlockFilterInput struct { // A public key of a user who has their // transaction in the block, or produced the block RelatedTo string `json:"relatedTo"` }
type BlockProducerTimings ¶
type BlockProducerTimings struct {
Times []*ConsensusTime `json:"times"`
}
type BlockchainState ¶
type BlockchainState struct { // date (stringified Unix time - number of milliseconds since January 1, 1970) Date string `json:"date"` // Base58Check-encoded hash of the snarked ledger SnarkedLedgerHash string `json:"snarkedLedgerHash"` // Base58Check-encoded hash of the staged ledger StagedLedgerHash string `json:"stagedLedgerHash"` }
type ChainReorganizationStatus ¶
type ChainReorganizationStatus string
Status for whenever the blockchain is reorganized
const (
ChainReorganizationStatusChanged ChainReorganizationStatus = "CHANGED"
)
func (ChainReorganizationStatus) IsValid ¶
func (e ChainReorganizationStatus) IsValid() bool
func (ChainReorganizationStatus) MarshalGQL ¶
func (e ChainReorganizationStatus) MarshalGQL(w io.Writer)
func (ChainReorganizationStatus) String ¶
func (e ChainReorganizationStatus) String() string
func (*ChainReorganizationStatus) UnmarshalGQL ¶
func (e *ChainReorganizationStatus) UnmarshalGQL(v interface{}) error
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a GraphQL API client
func NewDefaultClient ¶
NewDefaultClient returns a default client for a given endpoint
func (Client) ConsensusTip ¶
func (Client) GetAccount ¶
GetAccount returns account for a given public key
func (Client) GetBestChain ¶
GetBestChain returns the blocks from the canonical chain
func (Client) GetCurrentHeight ¶
GetCurrentHeight returns the current blockchain height
func (Client) GetDaemonStatus ¶
func (c Client) GetDaemonStatus(ctx context.Context) (*DaemonStatus, error)
GetDaemonStatus returns current node daemon status
func (Client) GetFirstBlock ¶
GetFirstBlock returns the first block available in the chain node
func (Client) GetFirstBlocks ¶
GetFirstBlocks returns the first n blocks
func (Client) GetLastBlock ¶
GetLastBlock returns the last block available in the chain node
func (Client) GetNextBlock ¶
GetNextBlock returns the next block after the given block's hash
func (Client) GetNextBlocks ¶
GetNextBlocks returns a next N blocks after a given block hash
func (Client) GetPendingTransactions ¶ added in v0.9.3
func (c Client) GetPendingTransactions() ([]PendingTransaction, error)
GetPendingTransactions returns pending transactions
func (Client) GetSingleBlock ¶
GetSingleBlock returns a single block record from the result
func (Client) QueryWithContext ¶
QueryWithContext executes the query with context and parses the result
type CompletedWork ¶
type CompletedWork struct { // Public key of the prover Prover string `json:"prover"` // Amount the prover is paid for the snark work Fee string `json:"fee"` // Unique identifier for the snark work purchased WorkIds []int `json:"workIds"` }
Completed snark works
type ConsensusConfiguration ¶
type ConsensusConfiguration struct { Delta int `json:"delta"` K int `json:"k"` C int `json:"c"` CTimesK int `json:"cTimesK"` SlotsPerEpoch int `json:"slotsPerEpoch"` SlotDuration int `json:"slotDuration"` EpochDuration int `json:"epochDuration"` GenesisStateTimestamp string `json:"genesisStateTimestamp"` AcceptableNetworkDelay int `json:"acceptableNetworkDelay"` }
type ConsensusState ¶
type ConsensusState struct { // Length of the blockchain at this block BlockchainLength string `json:"blockchainLength"` // Height of the blockchain at this block BlockHeight string `json:"blockHeight"` EpochCount string `json:"epochCount"` MinWindowDensity string `json:"minWindowDensity"` LastVrfOutput string `json:"lastVrfOutput"` // Total currency in circulation at this block TotalCurrency string `json:"totalCurrency"` StakingEpochData *StakingEpochData `json:"stakingEpochData"` NextEpochData *NextEpochData `json:"nextEpochData"` HasAncestorInSameCheckpointWindow bool `json:"hasAncestorInSameCheckpointWindow"` // Slot in which this block was created Slot string `json:"slot"` // Epoch in which this block was created Epoch string `json:"epoch"` }
type ConsensusTime ¶
type CreateHDAccountInput ¶
type CreateHDAccountInput struct { // Index of the account in hardware wallet Index string `json:"index"` }
type DaemonStatus ¶
type DaemonStatus struct { NumAccounts *int `json:"numAccounts"` BlockchainLength *int `json:"blockchainLength"` HighestBlockLengthReceived int `json:"highestBlockLengthReceived"` UptimeSecs int `json:"uptimeSecs"` LedgerMerkleRoot *string `json:"ledgerMerkleRoot"` StateHash *string `json:"stateHash"` CommitID string `json:"commitId"` ConfDir string `json:"confDir"` Peers []string `json:"peers"` UserCommandsSent int `json:"userCommandsSent"` SnarkWorker *string `json:"snarkWorker"` SnarkWorkFee int `json:"snarkWorkFee"` SyncStatus SyncStatus `json:"syncStatus"` BlockProductionKeys []string `json:"blockProductionKeys"` Histograms *Histograms `json:"histograms"` ConsensusTimeBestTip *ConsensusTime `json:"consensusTimeBestTip"` NextBlockProduction *BlockProducerTimings `json:"nextBlockProduction"` ConsensusTimeNow *ConsensusTime `json:"consensusTimeNow"` ConsensusMechanism string `json:"consensusMechanism"` ConsensusConfiguration *ConsensusConfiguration `json:"consensusConfiguration"` AddrsAndPorts *AddrsAndPorts `json:"addrsAndPorts"` }
type DeleteAccountInput ¶
type DeleteAccountInput struct { // Public key of account to be deleted PublicKey string `json:"publicKey"` }
type DeleteAccountPayload ¶
type DeleteAccountPayload struct { // Public key of the deleted account PublicKey string `json:"publicKey"` }
type EpochLedger ¶
type FeeTransfer ¶
type Genesis ¶
type Genesis struct { Config struct { Timestamp time.Time `json:"genesis_state_timestamp"` } `json:"genesis"` Ledger struct { Name string `json:"name"` NumAccounts int `json:"num_accounts"` Accounts []GenesisAccount `json:"accounts"` } `json:"ledger"` }
func ReadGenesisFile ¶
ReadGenesisFile reads and returns genesis file records
type GenesisAccount ¶
type GraphError ¶
type GraphError struct {
Message string `json:"message"`
}
GraphError contains the GraphQL error message
type GraphResponse ¶
type GraphResponse struct { Errors []GraphError `json:"errors"` Data json.RawMessage `json:"data"` }
GraphResponse contains the GraphQL call response
func (GraphResponse) Decode ¶
func (r GraphResponse) Decode(dst interface{}) error
Decode decodes the graph data into the target interface
type Histograms ¶
type Histograms struct { RPCTimings *RPCTimings `json:"rpcTimings"` ExternalTransitionLatency *Histogram `json:"externalTransitionLatency"` AcceptedTransitionLocalLatency *Histogram `json:"acceptedTransitionLocalLatency"` AcceptedTransitionRemoteLatency *Histogram `json:"acceptedTransitionRemoteLatency"` SnarkWorkerTransitionTime *Histogram `json:"snarkWorkerTransitionTime"` SnarkWorkerMergeTime *Histogram `json:"snarkWorkerMergeTime"` }
type LockInput ¶
type LockInput struct { // Public key specifying which account to lock PublicKey string `json:"publicKey"` }
type LockPayload ¶
type NextEpochData ¶
type NextEpochData struct { Ledger *EpochLedger `json:"ledger"` Seed string `json:"seed"` StartCheckpoint string `json:"startCheckpoint"` LockCheckpoint string `json:"lockCheckpoint"` EpochLength string `json:"epochLength"` }
type PageInfo ¶
type PageInfo struct { HasPreviousPage bool `json:"hasPreviousPage"` HasNextPage bool `json:"hasNextPage"` FirstCursor *string `json:"firstCursor"` LastCursor *string `json:"lastCursor"` }
PageInfo object as described by the Relay connections spec
type PendingSnarkWork ¶
type PendingSnarkWork struct { // Work bundle with one or two snark work WorkBundle []*WorkDescription `json:"workBundle"` }
Snark work bundles that are not available in the pool yet
type PendingTransaction ¶ added in v0.9.3
type PendingTransaction struct { ID string `json:"id"` Hash string `json:"hash"` // If true, this represents a delegation of stake, otherwise it is a payment IsDelegation bool `json:"isDelegation"` // Nonce of the transaction Nonce int `json:"nonce"` // Public key of the sender From string `json:"from"` // Public key of the receiver To string `json:"to"` // Amount that sender is sending to receiver - this is 0 for delegations Amount string `json:"amount"` // Fee that sender is willing to pay for making the transaction Fee string `json:"fee"` // Short arbitrary message provided by the sender Memo string `json:"memo"` // Kind of the transaction Kind string `json:"kind"` }
type ProtocolState ¶
type ProtocolState struct { // Base58Check-encoded hash of the previous state PreviousStateHash string `json:"previousStateHash"` // State which is agnostic of a particular consensus algorithm BlockchainState *BlockchainState `json:"blockchainState"` // State specific to the Codaboros Proof of Stake consensus algorithm ConsensusState *ConsensusState `json:"consensusState"` }
type ProtocolStateProof ¶
type RPCTimings ¶
type RPCTimings struct { GetStagedLedgerAux *RPCPair `json:"getStagedLedgerAux"` AnswerSyncLedgerQuery *RPCPair `json:"answerSyncLedgerQuery"` GetAncestry *RPCPair `json:"getAncestry"` GetTransitionChainProof *RPCPair `json:"getTransitionChainProof"` GetTransitionChain *RPCPair `json:"getTransitionChain"` }
type ReloadAccountsPayload ¶
type ReloadAccountsPayload struct { // True when the reload was successful Success bool `json:"success"` }
type SendDelegationInput ¶
type SendDelegationInput struct { // Should only be set when cancelling transactions, otherwise a nonce is determined automatically Nonce *string `json:"nonce"` // Short arbitrary message provided by the sender Memo *string `json:"memo"` // The global slot number after which this transaction cannot be applied ValidUntil *string `json:"validUntil"` // Fee amount in order to send a stake delegation Fee string `json:"fee"` // Public key of the account being delegated to To string `json:"to"` // Public key of sender of a stake delegation From string `json:"from"` }
type SendDelegationPayload ¶
type SendDelegationPayload struct { // Delegation change that was sent Delegation *UserCommand `json:"delegation"` }
type SendPaymentInput ¶
type SendPaymentInput struct { // Should only be set when cancelling transactions, otherwise a nonce is determined automatically Nonce *string `json:"nonce"` // Short arbitrary message provided by the sender Memo *string `json:"memo"` // The global slot number after which this transaction cannot be applied ValidUntil *string `json:"validUntil"` // Fee amount in order to send payment Fee string `json:"fee"` // Amount of coda to send to to receiver Amount string `json:"amount"` // Public key of recipient of payment To string `json:"to"` // Public key of sender of payment From string `json:"from"` }
type SendPaymentPayload ¶
type SendPaymentPayload struct { // Payment that was sent Payment *UserCommand `json:"payment"` }
type SetSnarkWorkFee ¶
type SetSnarkWorkFee struct { // Fee to get rewarded for producing snark work Fee string `json:"fee"` }
type SetSnarkWorkFeePayload ¶
type SetSnarkWorkFeePayload struct { // Returns the last fee set to do snark work LastFee string `json:"lastFee"` }
type SetSnarkWorkerInput ¶
type SetSnarkWorkerInput struct { // Public key you wish to start snark-working on; null to stop doing any snark work PublicKey *string `json:"publicKey"` }
type SetSnarkWorkerPayload ¶
type SetSnarkWorkerPayload struct { // Returns the last public key that was designated for snark work LastSnarkWorker *string `json:"lastSnarkWorker"` }
type SetStakingInput ¶
type SetStakingInput struct { // Public keys of accounts you wish to stake with - these must be accounts that are in trackedAccounts PublicKeys []string `json:"publicKeys"` }
type SetStakingPayload ¶
type SetStakingPayload struct { // Returns the public keys that were staking funds previously LastStaking []string `json:"lastStaking"` // List of public keys that could not be used to stake because they were locked LockedPublicKeys []string `json:"lockedPublicKeys"` // Returns the public keys that are now staking their funds CurrentStakingKeys []string `json:"currentStakingKeys"` }
type SignatureInput ¶
type SignatureInput struct { // Scalar component of signature Scalar string `json:"scalar"` // Field component of signature Field string `json:"field"` }
A cryptographic signature
type SignedFee ¶
type SignedFee struct { // +/- Sign Sign `json:"sign"` // Fee FeeMagnitude string `json:"feeMagnitude"` }
Signed fee
type SnarkWorker ¶
type StakingEpochData ¶
type StakingEpochData struct { Ledger *EpochLedger `json:"ledger"` Seed string `json:"seed"` StartCheckpoint string `json:"startCheckpoint"` LockCheckpoint string `json:"lockCheckpoint"` EpochLength string `json:"epochLength"` }
type SyncStatus ¶
type SyncStatus string
Sync status of daemon
const ( SyncStatusConnecting SyncStatus = "CONNECTING" SyncStatusListening SyncStatus = "LISTENING" SyncStatusOffline SyncStatus = "OFFLINE" SyncStatusBootstrap SyncStatus = "BOOTSTRAP" SyncStatusSynced SyncStatus = "SYNCED" SyncStatusCatchup SyncStatus = "CATCHUP" )
func (SyncStatus) IsValid ¶
func (e SyncStatus) IsValid() bool
func (SyncStatus) MarshalGQL ¶
func (e SyncStatus) MarshalGQL(w io.Writer)
func (SyncStatus) String ¶
func (e SyncStatus) String() string
func (*SyncStatus) UnmarshalGQL ¶
func (e *SyncStatus) UnmarshalGQL(v interface{}) error
type TransactionStatus ¶
type TransactionStatus string
Status of a transaction
const ( // A transaction that is on the longest chain TransactionStatusIncluded TransactionStatus = "INCLUDED" // A transaction either in the transition frontier or in transaction pool but is not on the longest chain TransactionStatusPending TransactionStatus = "PENDING" // The transaction has either been snarked, reached finality through consensus or has been dropped TransactionStatusUnknown TransactionStatus = "UNKNOWN" )
func (TransactionStatus) IsValid ¶
func (e TransactionStatus) IsValid() bool
func (TransactionStatus) MarshalGQL ¶
func (e TransactionStatus) MarshalGQL(w io.Writer)
func (TransactionStatus) String ¶
func (e TransactionStatus) String() string
func (*TransactionStatus) UnmarshalGQL ¶
func (e *TransactionStatus) UnmarshalGQL(v interface{}) error
type Transactions ¶
type Transactions struct { // List of user commands (payments and stake delegations) included in this block UserCommands []*UserCommand `json:"userCommands"` // List of fee transfers included in this block FeeTransfer []*FeeTransfer `json:"feeTransfer"` // Amount of coda granted to the producer of this block Coinbase string `json:"coinbase"` // Receiver of the block reward CoinbaseReceiver *Account `json:"coinbaseReceiverAccount"` }
Different types of transactions in a block
type TrustStatusPayload ¶
type UnlockInput ¶
type UnlockPayload ¶
type UserCommand ¶
type UserCommand struct { ID string `json:"id"` Hash string `json:"hash"` // If true, this represents a delegation of stake, otherwise it is a payment IsDelegation bool `json:"isDelegation"` // Nonce of the transaction Nonce int `json:"nonce"` // Public key of the sender From string `json:"from"` // Account of the sender FromAccount *Account `json:"fromAccount"` // Public key of the receiver To string `json:"to"` // Account of the receiver ToAccount *Account `json:"toAccount"` // Amount that sender is sending to receiver - this is 0 for delegations Amount string `json:"amount"` // Fee that sender is willing to pay for making the transaction Fee string `json:"fee"` // Short arbitrary message provided by the sender Memo string `json:"memo"` }
type WorkDescription ¶
type WorkDescription struct { // Base58Check-encoded hash of the source ledger SourceLedgerHash string `json:"sourceLedgerHash"` // Base58Check-encoded hash of the target ledger TargetLedgerHash string `json:"targetLedgerHash"` // Total transaction fee that is not accounted for in the transition from source ledger to target ledger FeeExcess *SignedFee `json:"feeExcess"` // Increase in total coinbase reward SupplyIncrease string `json:"supplyIncrease"` // Unique identifier for a snark work WorkID int `json:"workId"` }
Transition from a source ledger to a target ledger with some fee excess and increase in supply