v2

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountAddressLength  = 32
	BlockHashLength       = 32
	TransactionHashLength = 32
	ModuleRefLength       = 32
)
View Source
const ModuleVersion0 moduleVersion = 0
View Source
const ModuleVersion1 moduleVersion = 1
View Source
const PayloadTypeSize = 1
View Source
const TransactionHeaderSize uint64 = 60 // 32 + 8 + 8 + 4 + 8.

TransactionHeaderSize describes size of a transaction Header. This is currently always 60 Bytes. Future chain updates might revise this, but this is a big change so this is expected to change seldom.

Variables

View Source
var (
	// InvalidPayloadType indicated that payload type is invalid.
	InvalidPayloadType = errors.New("invalid payload type")
	// InvalidRawPayloadSize indicated that raw payload size is invalid.
	InvalidRawPayloadSize = errors.New("invalid raw payload size")
)

Functions

func HostTLSRoots

func HostTLSRoots() (_ credentials.TransportCredentials, err error)

Types

type AbsoluteBlockHeight

type AbsoluteBlockHeight struct {
	Value uint64
}

AbsoluteBlockHeight this is the number of ancestors of a block since the genesis block. In particular, the chain genesis block has absolute height 0.

type AbsoluteEnergy

type AbsoluteEnergy Energy

AbsoluteEnergy is an amount of Energy that will be exact used.

type AccountAddress

type AccountAddress struct {
	Value [AccountAddressLength]byte
}

AccountAddress an address of an account.

func AccountAddressFromBytes

func AccountAddressFromBytes(b []byte) (AccountAddress, error)

AccountAddressFromBytes creates account address from given bytes.

func AccountAddressFromString

func AccountAddressFromString(s string) (AccountAddress, error)

AccountAddressFromString decodes string to account.

func (*AccountAddress) ToBase58

func (a *AccountAddress) ToBase58() string

ToBase58 encodes account address to string.

type AccountKeys

type AccountKeys struct {
	Keys      map[CredentialIndex]*CredentialData
	Threshold AccountThreshold
}

AccountKeys all account keys indexed by credentials.

type AccountSignatureMap

type AccountSignatureMap struct {
	Signatures map[uint8]*Signature
}

AccountSignatureMap wrapper for a map from indexes to signatures. Needed because protobuf doesn't allow nested maps directly. The keys in the SignatureMap must not exceed 2^8.

type AccountThreshold

type AccountThreshold struct {
	Value uint8
}

AccountThreshold describes the minimum number of credentials that need to sign any transaction coming from an associated account. The values of this type must maintain the property that they are not 0.

type AccountTransaction

type AccountTransaction struct {
	Signature *AccountTransactionSignature
	Header    *AccountTransactionHeader
	Payload   *AccountTransactionPayload
}

AccountTransaction messages which are signed and paid for by the sender account.

func (*AccountTransaction) Send

func (accountTransaction *AccountTransaction) Send(ctx context.Context, client *Client) (*TransactionHash, error)

Send sends BlockItem with AccountTransaction using provided Client and returns TransactionHash.

type AccountTransactionHeader

type AccountTransactionHeader struct {
	// Sender account of the transaction.
	Sender *AccountAddress
	// Sequence number of the transaction.
	SequenceNumber *SequenceNumber
	// Maximum amount of energy the transaction can take to execute.
	EnergyAmount *Energy
	// Size of the transaction Payload. This is used to deserialize the Payload.
	PayloadSize *PayloadSize
	// Latest time the transaction can be included in a block.
	Expiry *TransactionTime
}

AccountTransactionHeader header of an account transaction that contains basic data to check whether the sender and the transaction are valid. The header is shared by all transaction types.

func (*AccountTransactionHeader) Serialize

func (transactionHeader *AccountTransactionHeader) Serialize() []byte

Serialize returns serialized AccountTransactionHeader.

type AccountTransactionPayload

type AccountTransactionPayload struct {
	Payload isAccountTransactionPayload
}

AccountTransactionPayload the payload for an account transaction.

type AccountTransactionSignature

type AccountTransactionSignature struct {
	Signatures map[uint8]*AccountSignatureMap
}

AccountTransactionSignature transaction signature.

type AddEnergy

type AddEnergy struct {
	Energy  Energy
	NumSigs uint32
}

AddEnergy is an amount of Energy that will be added to the base amount. The base amount covers transaction size and signature checking.

type Amount

type Amount struct {
	Value uint64
}

Amount an amount of microCCD.

type AmountFraction added in v0.2.0

type AmountFraction struct {
	// contains filtered or unexported fields
}

A fraction of an amount with a precision of 1/100_000

func AmountFractionFromUInt32 added in v0.2.0

func AmountFractionFromUInt32(value uint32) (AmountFraction, error)

AmountFractionFromUInt32 constructs an AmountFraction from a uint32 value. The value must not exceed 100_000.

func (*AmountFraction) GetValue added in v0.2.0

func (a *AmountFraction) GetValue() uint32

GetValue returns the value of the AmountFraction, e.g. 'partsPerHundredThousand/100_000'.

type BakerAggregationVerifyKey added in v0.2.0

type BakerAggregationVerifyKey struct {
	Value []byte
}

Baker's public key used to check signatures on finalization records. This is only used if the baker has sufficient stake to participate in finalization.

type BakerElectionVerifyKey added in v0.2.0

type BakerElectionVerifyKey struct {
	Value []byte
}

Baker's public key used to check whether they won the lottery or not.

type BakerId

type BakerId struct {
	Value uint64
}

BakerId the ID of a baker, which is the index of its account.

type BakerInfo added in v0.2.0

type BakerInfo struct {

	// Identity of the baker. This is actually the account index of the account controlling the baker.
	BakerId BakerId

	// Baker's public key used to check whether they won the lottery or not.
	ElectionKey BakerElectionVerifyKey

	// Baker's public key used to check that they are indeed the ones who produced the block.
	SignatureKey BakerSignatureVerifyKey

	// Baker's public key used to check signatures on finalization records.
	// This is only used if the baker has sufficient stake to participate in finalization.
	AggregationKey BakerAggregationVerifyKey
}

Information about a baker.

type BakerRewardPeriodInfo added in v0.2.0

type BakerRewardPeriodInfo struct {

	// The baker id and public keys for the baker.
	Baker BakerInfo

	// The effective stake of the baker for the consensus protocol.
	// The returned amount accounts for delegation, capital bounds and leverage bounds.
	EffectiveStake Amount

	// The effective commission rate for the baker that applies for the reward period.
	CommissionRates CommissionRates

	// The amount staked by the baker itself.
	EquityCapital Amount

	// The total amount of capital delegated to this baker pool.
	DelegatedCapital Amount

	// Whether the baker is a finalizer or not.
	IsFinalizer bool
}

Information about a particular baker with respect to the current reward period.

type BakerRewardPeriodInfoStream added in v0.2.0

type BakerRewardPeriodInfoStream struct {
	// contains filtered or unexported fields
}

Return type of GetBakersRewardPeriod. Parses the returned *pb.BakerRewardPeriodInfo to BakerRewardPeriodInfo when Recv() is called.

func (*BakerRewardPeriodInfoStream) Recv added in v0.2.0

Recv retrieves the next BakerRewardPeriodInfo.

type BakerSignatureVerifyKey added in v0.2.0

type BakerSignatureVerifyKey struct {
	Value []byte
}

Baker's public key used to check that they are indeed the ones who produced the block.

type BlockHash

type BlockHash struct {
	Value [BlockHashLength]byte
}

BlockHash hash of a block. This is always 32 bytes long.

func BlockHashFromBytes added in v0.2.0

func BlockHashFromBytes(b []byte) (BlockHash, error)

BlockHashFromBytes creates a BlockHash from given []byte. Length of given []byte must be excactly 32 bytes.

func (*BlockHash) Hex

func (b *BlockHash) Hex() string

Hex encodes block hash to base16 string.

type BlockHashInputAbsoluteHeight

type BlockHashInputAbsoluteHeight struct {
	Value uint64
}

BlockHashInputAbsoluteHeight query for a block at absolute height, if a unique block can be identified at that height.

type BlockHashInputBest

type BlockHashInputBest struct{}

BlockHashInputBest query for the best block.

type BlockHashInputGiven

type BlockHashInputGiven struct {
	Given BlockHash
}

BlockHashInputGiven query for the block specified by the hash. This hash should always be 32 bytes.

type BlockHashInputLastFinal

type BlockHashInputLastFinal struct{}

BlockHashInputLastFinal query for the last finalized block.

type BlockHashInputRelativeHeight

type BlockHashInputRelativeHeight struct {
	GenesisIndex uint32
	Height       uint64
	Restrict     bool
}

BlockHashInputRelativeHeight query for a block at height relative to a genesis index.

type BlockHeight

type BlockHeight struct {
	Value uint64
}

BlockHeight the height of a block relative to the last genesis. This differs from the absolute block height in that it counts height from the last protocol update.

type BlockInfo

type BlockInfo struct {
	Hash                   *BlockHash
	Height                 *AbsoluteBlockHeight
	ParentBlock            *BlockHash
	LastFinalizedBlock     *BlockHash
	GenesisIndex           *GenesisIndex
	EraBlockHeight         *BlockHeight
	ReceiveTime            *Timestamp
	ArriveTime             *Timestamp
	SlotNumber             *Slot
	SlotTime               *Timestamp
	Baker                  *BakerId
	Finalized              bool
	TransactionCount       uint32
	TransactionsEnergyCost *Energy
	TransactionsSize       uint32
	StateHash              *StateHash
	ProtocolVersion        ProtocolVersion
}

BlockInfo information about given block, contains height, timings, transaction count, state, etc.

type BlockItem

type BlockItem struct {
	Hash      *TransactionHash
	BlockItem isBlockItem
}

BlockItem is account transaction or credential deployment or update instruction item.

func ConvertBlockItems

func ConvertBlockItems(input []*pb.BlockItem) []*BlockItem

type Client

type Client struct {
	GrpcClient pb.QueriesClient
	ClientConn *grpc.ClientConn
	// contains filtered or unexported fields
}

Client provides grpc connection with node.

func NewClient

func NewClient(config Config) (_ *Client, err error)

NewClient creates new concordium grpc client.

func (*Client) BanPeer

func (c *Client) BanPeer(ctx context.Context, req *pb.PeerToBan) (err error)

BanPeer ban the given peer. Returns a GRPC error if the action failed.

func (*Client) Close

func (c *Client) Close() error

Close closes client connection.

func (*Client) DumpStart

func (c *Client) DumpStart(ctx context.Context, req *pb.DumpRequest) (err error)

DumpStart start dumping packages into the specified file. Only enabled if the node was built with the `network_dump` feature. Returns a GRPC error if the network dump failed to start.

func (*Client) DumpStop

func (c *Client) DumpStop(ctx context.Context) (err error)

DumpStop stop dumping packages. Only enabled if the node was built with the `network_dump` feature. Returns a GRPC error if the network dump failed to be stopped.

func (*Client) GetAccountInfo

func (c *Client) GetAccountInfo(ctx context.Context, accId *pb.AccountIdentifierInput, b isBlockHashInput) (_ *pb.AccountInfo, err error)

GetAccountInfo retrieve the information about the given account in the given block.

func (*Client) GetAccountList

func (c *Client) GetAccountList(ctx context.Context, req isBlockHashInput) (_ []*AccountAddress, err error)

GetAccountList retrieve the list of accounts that exist at the end of the given block.

func (*Client) GetAccountNonFinalizedTransactions

func (c *Client) GetAccountNonFinalizedTransactions(ctx context.Context, req *AccountAddress) (_ []*TransactionHash, err error)

GetAccountNonFinalizedTransactions get a list of non-finalized transaction hashes for a given account. This endpoint is not expected to return a large amount of data in most cases, but in bad network conditions it might. The stream will end when all the non-finalized transaction hashes have been returned.

func (*Client) GetAccountTransactionSignHash

func (c *Client) GetAccountTransactionSignHash(ctx context.Context, req *pb.PreAccountTransaction) (_ *pb.AccountTransactionSignHash, err error)

GetAccountTransactionSignHash get the hash to be signed for an account transaction. The hash returned should be signed and the signatures included as an AccountTransactionSignature when calling `SendBlockItem`. This is provided as a convenience to support cases where the right SDK is not available for interacting with the node. If an SDK is available then it is strongly recommended to compute this hash off-line using it. That reduces the trust in the node, removes networking failure modes, and will perform better.

func (*Client) GetAncestors

func (c *Client) GetAncestors(ctx context.Context, amount uint64, b isBlockHashInput) (_ []BlockHash, err error)

GetAncestors get a stream of ancestors for the provided block. Starting with the provided block itself, moving backwards until no more ancestors or the requested number of ancestors has been returned.

func (*Client) GetAnonymityRevokers

func (c *Client) GetAnonymityRevokers(ctx context.Context, req isBlockHashInput) (_ pb.Queries_GetAnonymityRevokersClient, err error)

GetAnonymityRevokers get the anonymity revokers registered as of the end of a given block. The stream will end when all the anonymity revokers have been returned.

func (*Client) GetBakerEarliestWinTime added in v0.2.0

func (c *Client) GetBakerEarliestWinTime(ctx context.Context, req *pb.BakerId) (_ Timestamp, err error)

GetBakerEarliestWinTime retrieves the projected earliest time at which a particular baker will be required to bake a block.

  • If the baker is not a baker for the current reward period, this returns a timestamp at the start of the next reward period.
  • If the baker is a baker for the current reward period, the earliest win time is projected from the current round forwward, assuming that each round after the last finalixed round will take the minimum block time. (If blocks take longer, or timeouts occur, the actual time may be later, and the reported time in subsequent queries may reflect this.)
  • At the end of an epoch (or if the baker is not projected to bake before the end of the epoch) the earliest win time for a (current) baker will be projected as the start of the next epoch. This is because the seed for the leader election is updated at the epoch boundary, and so the winners cannot be predicted beyond that.

Note that in some circumstances the returned timestamp can be in the past, especially at the end of an epoch.

This endpoint is only supported for protocol version 6 and onwards.

func (*Client) GetBakerList

func (c *Client) GetBakerList(ctx context.Context, req isBlockHashInput) (_ pb.Queries_GetBakerListClient, err error)

GetBakerList get all the bakers at the end of the given block.

func (*Client) GetBakersRewardPeriod added in v0.2.0

func (c *Client) GetBakersRewardPeriod(ctx context.Context, req isBlockHashInput) (_ BakerRewardPeriodInfoStream, err error)

GetBakersRewardPeriod retrieves all bakers in the reward period of a block.

This endpoint is only supported for protocol version 6 and onwards.

func (*Client) GetBannedPeers

func (c *Client) GetBannedPeers(ctx context.Context) (_ *pb.BannedPeers, err error)

GetBannedPeers get a list of banned peers.

func (*Client) GetBlockCertificates added in v0.2.0

func (c *Client) GetBlockCertificates(ctx context.Context, req isBlockHashInput) (_ *pb.BlockCertificates, err error)

GetBlockCertificates returns the quorum certificate, a timeout certificate (if present) and epoch finalization certificate (if present) for a non-genesis block.

This endpoint is only supported for protocol version 6 and onwards.

func (*Client) GetBlockChainParameters

func (c *Client) GetBlockChainParameters(ctx context.Context, req isBlockHashInput) (_ *pb.ChainParameters, err error)

GetBlockChainParameters get the values of chain parameters in effect in the given block.

func (*Client) GetBlockFinalizationSummary

func (c *Client) GetBlockFinalizationSummary(ctx context.Context, req isBlockHashInput) (_ *pb.BlockFinalizationSummary, err error)

GetBlockFinalizationSummary get the summary of the finalization data in a given block.

func (*Client) GetBlockInfo

func (c *Client) GetBlockInfo(ctx context.Context, req isBlockHashInput) (_ *BlockInfo, err error)

GetBlockInfo get information, such as height, timings, and transaction counts for the given block.

func (*Client) GetBlockItemStatus

func (c *Client) GetBlockItemStatus(ctx context.Context, req TransactionHash) (_ *pb.BlockItemStatus, err error)

GetBlockItemStatus get the status of and information about a specific block item (transaction).

func (*Client) GetBlockItems

func (c *Client) GetBlockItems(ctx context.Context, req isBlockHashInput) (_ []*BlockItem, err error)

GetBlockItems get the items of a block.

func (*Client) GetBlockPendingUpdates

func (c *Client) GetBlockPendingUpdates(ctx context.Context, req isBlockHashInput) (_ pb.Queries_GetBlockPendingUpdatesClient, err error)

GetBlockPendingUpdates get the pending updates to chain parameters at the end of a given block. The stream will end when all the pending updates for a given block have been returned.

func (*Client) GetBlockSpecialEvents

func (c *Client) GetBlockSpecialEvents(ctx context.Context, req isBlockHashInput) (_ pb.Queries_GetBlockSpecialEventsClient, err error)

GetBlockSpecialEvents get a list of transaction events in a given block. The stream will end when all the transaction events for a given block have been returned.

func (*Client) GetBlockTransactionEvents

func (c *Client) GetBlockTransactionEvents(ctx context.Context, req isBlockHashInput) (_ pb.Queries_GetBlockTransactionEventsClient, err error)

GetBlockTransactionEvents returns stream of transaction events in a given block. The stream will end when all the transaction events for a given block have been returned.

func (*Client) GetBlocks

func (c *Client) GetBlocks(ctx context.Context) (_ pb.Queries_GetBlocksClient, err error)

GetBlocks returns a stream of blocks that arrive from the time the query is made onward. This can be used to listen for incoming blocks.

func (*Client) GetBlocksAtHeight

func (c *Client) GetBlocksAtHeight(ctx context.Context, req *pb.BlocksAtHeightRequest) (_ []*BlockHash, err error)

GetBlocksAtHeight get a list of live blocks at a given height.

func (*Client) GetBranches

func (c *Client) GetBranches(ctx context.Context) (_ *pb.Branch, err error)

GetBranches get the current branches of blocks starting from and including the last finalized block.

func (*Client) GetConsensusInfo

func (c *Client) GetConsensusInfo(ctx context.Context) (_ *pb.ConsensusInfo, err error)

GetConsensusInfo get information about the current state of consensus.

func (*Client) GetCryptographicParameters

func (c *Client) GetCryptographicParameters(ctx context.Context, req isBlockHashInput) (_ *pb.CryptographicParameters, err error)

GetCryptographicParameters get the cryptographic parameters in a given block.

func (*Client) GetElectionInfo

func (c *Client) GetElectionInfo(ctx context.Context, req isBlockHashInput) (_ *pb.ElectionInfo, err error)

GetElectionInfo get information related to the baker election for a particular block.

func (*Client) GetFinalizedBlocks

func (c *Client) GetFinalizedBlocks(ctx context.Context) (_ pb.Queries_GetFinalizedBlocksClient, err error)

GetFinalizedBlocks return a stream of blocks that are finalized from the time the query is made onward. This can be used to listen for newly finalized blocks. Note that there is no guarantee that blocks will not be skipped if the client is too slow in processing the stream, however blocks will always be sent by increasing block height.

func (*Client) GetFirstBlockEpoch added in v0.2.0

func (c *Client) GetFirstBlockEpoch(ctx context.Context, req isEpochRequest) (_ BlockHash, err error)

GetFirstBlockEpoch retrieves the block hash of the first finalized block in a specified epoch.

The following errors are possible:

  • `NOT_FOUND` if the query specifies an unknown block.
  • `UNAVAILABLE` if the query is for an epoch that is not finalized in the current genesis index, or is for a future genesis index.
  • `INVALID_ARGUMENT` if the query is for an epoch with no finalized blocks for a past genesis index.
  • `INVALID_ARGUMENT` if the input `EpochRequest` is malformed.
  • `UNIMPLEMENTED` if the endpoint is disabled on the node.

This endpoint is only supported for protocol version 6 and onwards.

func (*Client) GetIdentityProviders

func (c *Client) GetIdentityProviders(ctx context.Context, req isBlockHashInput) (_ pb.Queries_GetIdentityProvidersClient, err error)

GetIdentityProviders get the identity providers registered as of the end of a given block. The stream will end when all the identity providers have been returned.

func (*Client) GetInstanceInfo

func (c *Client) GetInstanceInfo(ctx context.Context, blockHash isBlockHashInput, address ContractAddress) (_ *pb.InstanceInfo, err error)

GetInstanceInfo get info about a smart contract instance as it appears at the end of the given block.

func (*Client) GetInstanceList

func (c *Client) GetInstanceList(ctx context.Context, req isBlockHashInput) (_ []*ContractAddress, err error)

GetInstanceList get a list of addresses for all smart contract instances. The stream will end when all instances that exist in the state at the end of the given block has been returned.

func (*Client) GetInstanceState

func (c *Client) GetInstanceState(ctx context.Context, blockHash isBlockHashInput, address ContractAddress) (_ pb.Queries_GetInstanceStateClient, err error)

GetInstanceState get the exact state of a specific contract instance, streamed as a list of key-value pairs. The list is streamed in lexicographic order of keys.

func (*Client) GetModuleList

func (c *Client) GetModuleList(ctx context.Context, req isBlockHashInput) (_ []*ModuleRef, err error)

GetModuleList get a list of all smart contract modules. The stream will end when all modules that exist in the state at the end of the given block have been returned.

func (*Client) GetModuleSource

func (c *Client) GetModuleSource(ctx context.Context, req *pb.ModuleSourceRequest) (_ *pb.VersionedModuleSource, err error)

GetModuleSource get the source of a smart contract module.

func (*Client) GetNextAccountSequenceNumber

func (c *Client) GetNextAccountSequenceNumber(ctx context.Context, req *AccountAddress) (_ *pb.NextAccountSequenceNumber, err error)

GetNextAccountSequenceNumber get the best guess as to what the next account sequence number should be. If all account transactions are finalized then this information is reliable. Otherwise, this is the best guess, assuming all other transactions will be committed to blocks and eventually finalized.

func (*Client) GetNextUpdateSequenceNumbers

func (c *Client) GetNextUpdateSequenceNumbers(ctx context.Context, req isBlockHashInput) (_ *pb.NextUpdateSequenceNumbers, err error)

GetNextUpdateSequenceNumbers get next available sequence numbers for updating chain parameters after a given block.

func (*Client) GetNodeInfo

func (c *Client) GetNodeInfo(ctx context.Context) (_ *pb.NodeInfo, err error)

GetNodeInfo get information about the node. The `NodeInfo` includes information of * Meta information such as the, version of the node, type of the node, uptime and the local time of the node. * NetworkInfo which yields data such as the node id, packets sent/received, average bytes per second sent/received. * ConsensusInfo. The `ConsensusInfo` returned depends on if the node supports the protocol on chain and whether the node is configured as a baker or not.

func (*Client) GetPassiveDelegationInfo

func (c *Client) GetPassiveDelegationInfo(ctx context.Context, req isBlockHashInput) (_ *pb.PassiveDelegationInfo, err error)

GetPassiveDelegationInfo get information about the passive delegators at the end of a given block.

func (*Client) GetPassiveDelegators

func (c *Client) GetPassiveDelegators(ctx context.Context, req isBlockHashInput) (_ pb.Queries_GetPassiveDelegatorsClient, err error)

GetPassiveDelegators get the registered passive delegators at the end of a given block. In contrast to the `GetPassiveDelegatorsRewardPeriod` which returns delegators that are fixed for the reward period of the block, this endpoint returns the list of delegators that are registered in the block. Any changes to delegators are immediately visible in this list. The stream will end when all the delegators has been returned.

func (*Client) GetPassiveDelegatorsRewardPeriod

func (c *Client) GetPassiveDelegatorsRewardPeriod(ctx context.Context, req isBlockHashInput) (_ pb.Queries_GetPassiveDelegatorsRewardPeriodClient, err error)

GetPassiveDelegatorsRewardPeriod get the fixed passive delegators for the reward period of the given block. In contracts to the `GetPassiveDelegators` which returns delegators registered for the given block, this endpoint returns the fixed delegators contributing stake in the reward period containing the given block. The stream will end when all the delegators has been returned.

func (*Client) GetPeersInfo

func (c *Client) GetPeersInfo(ctx context.Context) (_ *pb.PeersInfo, err error)

GetPeersInfo get a list of the peers that the node is connected to / and `associated` network related information for each peer.

func (*Client) GetPoolDelegators

func (c *Client) GetPoolDelegators(ctx context.Context, req *pb.GetPoolDelegatorsRequest) (_ pb.Queries_GetPoolDelegatorsClient, err error)

GetPoolDelegators get the registered delegators of a given pool at the end of a given block. In contrast to the `GetPoolDelegatorsRewardPeriod` which returns delegators that are fixed for the reward period of the block, this endpoint returns the list of delegators that are registered in the block. Any changes to delegators are immediately visible in this list. The stream will end when all the delegators has been returned.

func (*Client) GetPoolDelegatorsRewardPeriod

func (c *Client) GetPoolDelegatorsRewardPeriod(ctx context.Context, req *pb.GetPoolDelegatorsRequest) (_ pb.Queries_GetPoolDelegatorsRewardPeriodClient, err error)

GetPoolDelegatorsRewardPeriod get the fixed delegators of a given pool for the reward period of the given block. In contracts to the `GetPoolDelegators` which returns delegators registered for the given block, this endpoint returns the fixed delegators contributing stake in the reward period containing the given block. The stream will end when all the delegators has been returned.

func (*Client) GetPoolInfo

func (c *Client) GetPoolInfo(ctx context.Context, req *pb.PoolInfoRequest) (_ *pb.PoolInfoResponse, err error)

GetPoolInfo get information about a given pool at the end of a given block.

func (*Client) GetTokenomicsInfo

func (c *Client) GetTokenomicsInfo(ctx context.Context, req isBlockHashInput) (_ *pb.TokenomicsInfo, err error)

GetTokenomicsInfo get information about tokenomics at the end of a given block.

func (*Client) GetWinningBakersEpoch added in v0.2.0

func (c *Client) GetWinningBakersEpoch(ctx context.Context, req isEpochRequest) (_ WinningBakerStream, err error)

GetWinningBakersEpoch retrieves the list of bakers that won the lottery in a particular historical epoch (i.e. the last finalized block is in a later epoch). This lists the winners for each round in the epoch, starting from the round after the last block in the previous epoch, running to the round before the first block in the next epoch. It also indicates if a block in each round was included in the finalized chain.

The following error cases are possible:

  • `NOT_FOUND` if the query specifies an unknown block.
  • `UNAVAILABLE` if the query is for an epoch that is not finalized in the current genesis index, or is for a future genesis index.
  • `INVALID_ARGUMENT` if the query is for an epoch that is not finalized for a past genesis index.
  • `INVALID_ARGUMENT` if the query is for a genesis index at consensus version 0.
  • `INVALID_ARGUMENT` if the input `EpochRequest` is malformed.
  • `UNIMPLEMENTED` if the endpoint is disabled on the node.

This endpoint is only supported for protocol version 6 and onwards.

func (*Client) InstanceStateLookup

func (c *Client) InstanceStateLookup(ctx context.Context, req *pb.InstanceStateLookupRequest) (_ *pb.InstanceStateValueAtKey, err error)

InstanceStateLookup get the value at a specific key of a contract state. In contrast to `GetInstanceState` this is more efficient, but requires the user to know the specific key to look for.

func (*Client) InvokeInstance

func (c *Client) InvokeInstance(ctx context.Context, payload UpdateContractPayload, input isBlockHashInput, energy Energy, address isAddress) (_ *pb.InvokeInstanceResponse, err error)

InvokeInstance run the smart contract entrypoint in a given context and in the state at the end of the given block.

func (*Client) PeerConnect

func (c *Client) PeerConnect(ctx context.Context, req *pb.IpSocketAddress) (err error)

PeerConnect suggest to a peer to connect to the submitted peer details. This, if successful, adds the peer to the list of given addresses. Otherwise return a GRPC error. Note. The peer might not be connected to instantly, in that case the node will try to establish the connection in near future. This function returns a GRPC status 'Ok' in this case.

func (*Client) PeerDisconnect

func (c *Client) PeerDisconnect(ctx context.Context, req *pb.IpSocketAddress) (err error)

PeerDisconnect disconnect from the peer and remove them from the given addresses list if they are on it. Return if the request was processed successfully. Otherwise, return a GRPC error.

func (*Client) SendBlockItem

func (c *Client) SendBlockItem(ctx context.Context, req *pb.SendBlockItemRequest) (_ *TransactionHash, err error)

SendBlockItem send a block item. A block item is either an `AccountTransaction`, which is a transaction signed and paid for by an account, a `CredentialDeployment`, which creates a new account, or `UpdateInstruction`, which is an instruction to change some parameters of the chain. Update instructions can only be sent by the governance committee. Returns a hash of the block item, which can be used with `GetBlockItemStatus`.

func (*Client) Shutdown

func (c *Client) Shutdown(ctx context.Context) (err error)

Shutdown shut down the node. Return a GRPC error if the shutdown failed.

func (*Client) UnbanPeer

func (c *Client) UnbanPeer(ctx context.Context, req *pb.BannedPeer) (err error)

UnbanPeer unban the banned peer. Returns a GRPC error if the action failed.

type CommissionRates added in v0.2.0

type CommissionRates struct {

	// Fraction of finalization rewards charged by the pool owner.
	Finalization AmountFraction

	// Fraction of baking rewards charged by the pool owner.
	Baking AmountFraction

	// Fraction of transaction rewards charged by the pool owner.
	Transaction AmountFraction
}

Distribution of the rewards for the particular pool.

type Config

type Config struct {
	NodeAddress    string `env:"NODE_ADDRESS"`
	TlsCredentials credentials.TransportCredentials
}

Config contains Concordium configurable values.

type ContractAddress

type ContractAddress struct {
	Index    uint64
	Subindex uint64
}

ContractAddress address of a smart contract instance.

type CredentialData

type CredentialData struct {
	Keys      map[KeyIndex]*KeyPair
	Threshold SignatureThreshold
}

CredentialData describes credential data needed by the account holder to generate proofs to deploy the credential object. This contains all the keys on the credential at the moment of its deployment. If this creates the account then the account starts with exactly these keys.

type CredentialDeployment

type CredentialDeployment struct {
	MessageExpiry *TransactionTime
	Payload       isCredentialDeploymentPayload
}

CredentialDeployment create new accounts. They are not paid for directly by the sender. Instead, bakers are rewarded by the protocol for including them.

type CredentialIndex

type CredentialIndex uint8

CredentialIndex describes index of the credential that is to be used.

type CredentialType

type CredentialType struct {
	Type isCredentialType
}

CredentialType describes type of credential.

type CredentialTypeInitial

type CredentialTypeInitial struct{}

CredentialTypeInitial is a credential type that is submitted by the identity provider on behalf of the user. There is only one initial credential per identity.

type CredentialTypeNormal

type CredentialTypeNormal struct{}

CredentialTypeNormal is one where the identity behind it is only known to the owner of the account, unless the anonymity revocation process was followed.

type DeployModule

type DeployModule struct {
	Payload *DeployModulePayload
}

DeployModule deploys a Wasm module with the given source.

func (DeployModule) Encode

func (deployModule DeployModule) Encode() *RawPayload

type DeployModulePayload

type DeployModulePayload struct {
	DeployModule *VersionedModuleSource
}

DeployModulePayload deploys a Wasm module with the given source.

func (*DeployModulePayload) Decode

func (payload *DeployModulePayload) Decode(source []byte) error

Decode decodes bytes into DeployModulePayload.

func (*DeployModulePayload) Encode

func (payload *DeployModulePayload) Encode() *RawPayload

Encode encodes Payload into RawPayload.

func (*DeployModulePayload) Size

func (payload *DeployModulePayload) Size() int

Size returns the size of the payload in number of bytes.

type Energy

type Energy struct {
	Value uint64
}

Energy is used to count exact execution cost. This cost is then converted to CCD amounts.

type Epoch added in v0.2.0

type Epoch struct {
	Value uint64
}

A chain epoch.

type EpochRequestBlockHash added in v0.2.0

type EpochRequestBlockHash struct {
	// The block to query at.
	BlockHash isBlockHashInput
}

Query for the epoch of a specified block.

type EpochRequestRelativeEpoch added in v0.2.0

type EpochRequestRelativeEpoch struct {
	// The genesis index to query at. The query is restricted to this genesis idex, and
	// will not return results for other indices even if the epoch number is out of bounds.
	GenesisIndex GenesisIndex
	// The epoch number to query at.
	Epoch Epoch
}

Request an epoch by number at a given genesis index.

type ExactSizeTransactionSigner

type ExactSizeTransactionSigner interface {
	TransactionSigner
	// NumberOfKeys returns number of signers.
	NumberOfKeys() uint32
}

ExactSizeTransactionSigner describes TransactionSigner with ability to return number of signers.

type GenesisIndex

type GenesisIndex struct {
	Value uint32
}

GenesisIndex the number of chain restarts via a protocol update. An effected protocol update instruction might not change the protocol version specified in the previous field, but it always increments the genesis index.

type GivenEnergy

type GivenEnergy struct {
	Energy isGivenEnergy
}

GivenEnergy helps handle the fixed costs and allows the user to focus only on the transaction specific ones. The most important case for this are smart contract initialisations and updates.

An upper bound on the amount of energy to spend on a transaction. Transaction costs have two components, one is based on the size of the transaction and the number of signatures, and then there is a transaction specific one.

type InitContract

type InitContract struct {
	Payload *InitContractPayload
}

InitContract contains data needed to initialize a smart contract.

func (InitContract) Encode

func (initContract InitContract) Encode() *RawPayload

type InitContractPayload

type InitContractPayload struct {
	// Deposit this amount of CCD.
	Amount *Amount
	// Reference to the module from which to initialize the instance.
	ModuleRef *ModuleRef
	// Name of the contract in the module.
	InitName *InitName
	// Parameter to invoke the initialization method with.
	Parameter *Parameter
}

InitContractPayload contains data needed to initialize a smart contract.

func (*InitContractPayload) Decode

func (payload *InitContractPayload) Decode(source []byte) error

Decode decodes bytes into InitContractPayload.

func (*InitContractPayload) Encode

func (payload *InitContractPayload) Encode() *RawPayload

Encode encodes Payload into RawPayload.

func (*InitContractPayload) Size

func (payload *InitContractPayload) Size() int

Size returns the size of the payload in number of bytes.

type InitName

type InitName struct {
	Value string
}

InitName the init name of a smart contract function.

type KeyIndex

type KeyIndex uint8

KeyIndex describes index of an account key that is to be used.

type KeyPair

type KeyPair struct {
	// contains filtered or unexported fields
}

KeyPair describes ed25519 key pair.

func NewKeyPairFromSignKey

func NewKeyPairFromSignKey(signKey []byte) (*KeyPair, error)

NewKeyPairFromSignKey creates new KeyPair from `singKey`. You can find this key in `Private Key` field in wallet settings -> `export private key` (key is in hex encoding), or copy from export file from filed `signKey` (key is in hex encoding).

func NewKeyPairFromSignKeyAndVerifyKey

func NewKeyPairFromSignKeyAndVerifyKey(signKey, verifyKey []byte) (*KeyPair, error)

NewKeyPairFromSignKeyAndVerifyKey creates new KeyPair from `singKey` and `verifyKey. You can find these keys in export file in fields `signKey` and `verifyKey` (keys are in hex encoding).

func (*KeyPair) Public

func (keyPair *KeyPair) Public() ed25519.PublicKey

Public return `verifyKey`.

func (*KeyPair) Secret

func (keyPair *KeyPair) Secret() ed25519.PrivateKey

Secret returns `signKey`.

func (*KeyPair) Sign

func (keyPair *KeyPair) Sign(msg []byte) Signature

Sign signs the message with private key and returns a signature.

type Memo

type Memo struct {
	Value []byte
}

Memo a memo which can be included as part of a transfer. Max size is 256 bytes.

type ModuleRef

type ModuleRef struct {
	Value [ModuleRefLength]byte
}

ModuleRef a smart contract module reference. This is always 32 bytes long.

func (*ModuleRef) Hex

func (m *ModuleRef) Hex() string

Hex encodes module ref to base16 string.

type ModuleSourceV0

type ModuleSourceV0 struct {
	Value []byte
}

ModuleSourceV0 v0.

type ModuleSourceV1

type ModuleSourceV1 struct {
	Value []byte
}

ModuleSourceV1 v1.

type Parameter

type Parameter struct {
	Value []byte
}

Parameter to a smart contract initialization or invocation.

type PayloadSize

type PayloadSize struct {
	Value uint32
}

PayloadSize describes size of the transaction Payload. This is used to deserialize the Payload.

type PayloadType

type PayloadType uint8

PayloadType defines Payload type byte.

const (
	// DeployModulePayloadType defines DeployModulePayload type byte.
	DeployModulePayloadType PayloadType = 0
	// InitContractPayloadType defines InitContractPayload type byte.
	InitContractPayloadType PayloadType = 1
	// UpdateContractPayloadType defines UpdateContractPayload type byte.
	UpdateContractPayloadType PayloadType = 2
	// TransferPayloadType defines TransferPayload type byte.
	TransferPayloadType PayloadType = 3
	// RegisterDataPayloadType defines RegisterDataPayload type byte.
	RegisterDataPayloadType PayloadType = 21
	// TransferWithMemoPayloadType defines TransferWithMemoPayload type byte.
	TransferWithMemoPayloadType PayloadType = 22
)

func GetPayloadType

func GetPayloadType(payload AccountTransactionPayload) (PayloadType, error)

GetPayloadType returns PayloadType byte from transmitted AccountTransactionPayload.

type PreAccountTransaction

type PreAccountTransaction struct {
	Header     *AccountTransactionHeader
	Payload    *AccountTransactionPayload
	Encoded    *RawPayload
	HashToSign *TransactionHash
}

PreAccountTransaction describes account transaction before signing.

func (*PreAccountTransaction) Deserialize

func (preAccountTransaction *PreAccountTransaction) Deserialize(source []byte) (err error)

Deserialize parses from bytes PreAccountTransaction.

func (*PreAccountTransaction) Serialize

func (preAccountTransaction *PreAccountTransaction) Serialize() []byte

Serialize returns serialized PreAccountTransaction.

func (*PreAccountTransaction) Sign

func (preAccountTransaction *PreAccountTransaction) Sign(signer TransactionSigner) (*AccountTransaction, error)

Sign signs PreAccountTransaction with TransactionSigner and returns AccountTransaction.

type ProtocolVersion

type ProtocolVersion struct {
	Value int32
}

ProtocolVersion the different versions of the protocol.

type RawPayload

type RawPayload struct {
	Value []byte
}

RawPayload a pre-serialized payload in the binary serialization format defined by the protocol.

func (RawPayload) Decode

func (rawPayload RawPayload) Decode() (*AccountTransactionPayload, error)

Decode decodes the RawPayload into a structured Payload. This also checks that all data is used, i.e., that there are no remaining trailing bytes.

func (RawPayload) Encode

func (rawPayload RawPayload) Encode() *RawPayload

Encode encodes the transaction payload by serializing.

func (RawPayload) Serialize

func (rawPayload RawPayload) Serialize() []byte

Serialize returns serialized encoded payload.

func (RawPayload) Size

func (rawPayload RawPayload) Size() PayloadSize

Size return size of Encoded Payload.

type ReceiveName

type ReceiveName struct {
	Value string
}

ReceiveName the reception name of a smart contract function. Expected format: `<contract_name>.<func_name>`. It must only consist of at most 100 ASCII alphanumeric or punctuation characters, and must contain a '.'.

type RegisterData

type RegisterData struct {
	Payload *RegisterDataPayload
}

RegisterData registers the given data on the chain.

func (RegisterData) Encode

func (registerData RegisterData) Encode() *RawPayload

type RegisterDataPayload

type RegisterDataPayload struct {
	// The data to register.
	Data *RegisteredData
}

RegisterDataPayload registers the given data on the chain.

func (*RegisterDataPayload) Decode

func (payload *RegisterDataPayload) Decode(source []byte) error

Decode decodes bytes into RegisterDataPayload.

func (*RegisterDataPayload) Encode

func (payload *RegisterDataPayload) Encode() *RawPayload

Encode encodes Payload into RawPayload.

func (*RegisterDataPayload) Size

func (payload *RegisterDataPayload) Size() int

Size returns the size of the payload in number of bytes.

type RegisteredData

type RegisteredData struct {
	Value []byte
}

RegisteredData data registered on the chain with a register data transaction.

type Round added in v0.2.0

type Round struct {
	Value uint64
}

A round.

type SequenceNumber

type SequenceNumber struct {
	Value uint64
}

SequenceNumber a sequence number that determines the ordering of transactions from the account. The minimum sequence number is 1.

type Signature

type Signature struct {
	Value []byte
}

Signature a single signature. Used when sending block items to a node with `SendBlockItem`.

type SignatureMap

type SignatureMap struct {
	Signatures map[uint32]*Signature
}

SignatureMap wrapper for a map from indexes to signatures. Needed because protobuf doesn't allow nested maps directly.

type SignatureThreshold

type SignatureThreshold struct {
	Value uint8
}

SignatureThreshold threshold for the number of signatures required. The values of this type must maintain the property that they are not 0.

type Slot

type Slot struct {
	Value uint64
}

Slot a number representing a slot for baking a block.

type StateHash

type StateHash struct {
	Value []byte
}

StateHash hash of the state after some block. This is always 32 bytes long.

type Timestamp

type Timestamp struct {
	Value uint64
}

Timestamp unix timestamp in milliseconds.

type TransactionHash

type TransactionHash struct {
	Value [TransactionHashLength]byte
}

TransactionHash hash of a transaction. This is always 32 bytes long.

func ComputeTransactionSignHash

func ComputeTransactionSignHash(header *AccountTransactionHeader, payload *AccountTransactionPayload) *TransactionHash

ComputeTransactionSignHash computes the transaction sign hash from an AccountTransactionHeader and AccountTransactionPayload.

func (*TransactionHash) Hex

func (t *TransactionHash) Hex() string

Hex encodes transaction hash to base16 string.

type TransactionSigner

type TransactionSigner interface {
	// SignTransactionHash signs transaction hash and returns signatures in AccountTransactionSignature type.
	SignTransactionHash(hashToSign *TransactionHash) (*AccountTransactionSignature, error)
}

TransactionSigner is an interface for signing transactions.

type TransactionTime

type TransactionTime struct {
	Value uint64
}

TransactionTime specified as seconds since unix epoch.

type Transfer

type Transfer struct {
	Payload *TransferPayload
}

Transfer transfers CCD to an account.

func (Transfer) Encode

func (transfer Transfer) Encode() *RawPayload

type TransferPayload

type TransferPayload struct {
	// Address to send to.
	Receiver *AccountAddress
	// Amount to send.
	Amount *Amount
}

TransferPayload transfers CCD to an account.

func (*TransferPayload) Decode

func (payload *TransferPayload) Decode(source []byte) error

Decode decodes bytes into TransferPayload.

func (*TransferPayload) Encode

func (payload *TransferPayload) Encode() *RawPayload

Encode encodes Payload into RawPayload.

func (*TransferPayload) Size

func (payload *TransferPayload) Size() int

Size returns the size of the payload in number of bytes.

type TransferWithMemo

type TransferWithMemo struct {
	Payload *TransferWithMemoPayload
}

TransferWithMemo payload of a transfer between two accounts with a memo.

func (TransferWithMemo) Encode

func (transferWithMemo TransferWithMemo) Encode() *RawPayload

type TransferWithMemoPayload

type TransferWithMemoPayload struct {
	// Address to send to.
	Receiver *AccountAddress
	// Memo to include in the transfer.
	Memo *Memo
	// Amount to send.
	Amount *Amount
}

TransferWithMemoPayload payload of a transfer between two accounts with a memo.

func (*TransferWithMemoPayload) Decode

func (payload *TransferWithMemoPayload) Decode(source []byte) error

Decode decodes bytes into TransferWithMemoPayload.

func (*TransferWithMemoPayload) Encode

func (payload *TransferWithMemoPayload) Encode() *RawPayload

Encode encodes Payload into RawPayload.

func (*TransferWithMemoPayload) Size

func (payload *TransferWithMemoPayload) Size() int

Size returns the size of the payload in number of bytes.

type UpdateContract

type UpdateContract struct {
	Payload *UpdateContractPayload
}

UpdateContract updates a smart contract instance by invoking a specific function.

func (UpdateContract) Encode

func (updateContract UpdateContract) Encode() *RawPayload

type UpdateContractPayload

type UpdateContractPayload struct {
	// Send the given amount of CCD together with the message to the
	// contract instance.
	Amount *Amount
	// Address of the contract instance to invoke.
	Address *ContractAddress
	// Name of the method to invoke on the contract.
	ReceiveName *ReceiveName
	// Parameter to send to the contract instance.
	Parameter *Parameter
}

UpdateContractPayload updates a smart contract instance by invoking a specific function.

func (*UpdateContractPayload) Decode

func (payload *UpdateContractPayload) Decode(source []byte) error

Decode decodes bytes into UpdateContractPayload.

func (*UpdateContractPayload) Encode

func (payload *UpdateContractPayload) Encode() *RawPayload

Encode encodes Payload into RawPayload.

func (*UpdateContractPayload) Size

func (payload *UpdateContractPayload) Size() int

Size returns the size of the payload in number of bytes.

type UpdateInstruction

type UpdateInstruction struct {
	Signatures *SignatureMap
	Header     *UpdateInstructionHeader
	Payload    *UpdateInstructionPayload
}

UpdateInstruction messages which can update the chain parameters. Including which keys are allowed to make future update instructions.

type UpdateInstructionHeader

type UpdateInstructionHeader struct {
	SequenceNumber *UpdateSequenceNumber
	EffectiveTime  *TransactionTime
	Timeout        *TransactionTime
}

type UpdateInstructionPayload

type UpdateInstructionPayload struct {
	Payload isUpdateInstructionPayload
}

UpdateInstructionPayload payload.

type UpdateSequenceNumber

type UpdateSequenceNumber struct {
	Value uint64
}

UpdateSequenceNumber determines the ordering of update transactions. Equivalent to `SequenceNumber` for account transactions. Update sequence numbers are per update type and the minimum value is 1.

type VersionedModuleSource

type VersionedModuleSource struct {
	Module isVersionedModuleSource
}

VersionedModuleSource source bytes of a versioned smart contract module.

func (VersionedModuleSource) Size

func (versionedModulePayload VersionedModuleSource) Size() int

Size returns size of module bytes.

type WalletAccount

type WalletAccount struct {
	Address *AccountAddress
	Keys    *AccountKeys
}

WalletAccount an account imported from one of the supported export formats. This structure implements TransactionSigner and ExactSizeTransactionSigner, so it may be used for sending transactions. This structure does not have the encryption key for sending encrypted transfers, it only contains keys for signing transactions.

func NewWalletAccount

func NewWalletAccount(accountAddress AccountAddress, keyPair KeyPair) *WalletAccount

NewWalletAccount created new WalletAccount from AccountAddress and one KeyPair.

func NewWalletAccountFromFile

func NewWalletAccountFromFile(pathToFile string) (*WalletAccount, error)

NewWalletAccountFromFile created new WalletAccount from `<account_address>.export` file.

func (*WalletAccount) AddKeyPair

func (walletAccount *WalletAccount) AddKeyPair(pair KeyPair)

AddKeyPair adds KeyPair to WalletAccount and updates threshold fields.

func (*WalletAccount) NumberOfKeys

func (walletAccount *WalletAccount) NumberOfKeys() uint32

NumberOfKeys returns number of signing keys.

func (*WalletAccount) SignTransactionHash

func (walletAccount *WalletAccount) SignTransactionHash(hashToSign *TransactionHash) (*AccountTransactionSignature, error)

SignTransactionHash returns signed TransactionHash.

type WinningBaker added in v0.2.0

type WinningBaker struct {
	// The round number.
	Round Round
	// The baker that won the round.
	Winner BakerId
	// True if the baker produced a block in this round on the finalized chain, and false otherwise.
	Present bool
}

Details of which baker won the lottery in a given round in consensus version 1.

type WinningBakerStream added in v0.2.0

type WinningBakerStream struct {
	// contains filtered or unexported fields
}

Return type of GetWinningBakersEpoch. Parses the returned *pb.WinningBaker to WinningBaker when Recv() is called.

func (*WinningBakerStream) Recv added in v0.2.0

func (s *WinningBakerStream) Recv() (WinningBaker, error)

Recv retrieves the next WinningBaker.

Jump to

Keyboard shortcuts

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