Documentation
¶
Overview ¶
Provides functions and data structures to interact with the system nodes in the context of the blockchain network.
Index ¶
- Variables
- func AuthUrl() string
- func CallZauthDelete(serverAddr, token, clientID string) error
- func CallZauthRetreiveKey(serverAddr, token, clientID, peerPublicKey string) (string, error)
- func CallZauthRevoke(serverAddr, token, clientID, peerPublicKey string) error
- func CallZvaultDeletePrimaryKey(serverAddr, token, clientID string) error
- func CallZvaultNewSplit(serverAddr, token, clientID string) error
- func CallZvaultNewWallet(serverAddr, token string) error
- func CallZvaultRetrieveKeys(serverAddr, token, clientID string) (string, error)
- func CallZvaultRetrieveRestrictions(serverAddr, token, peerPublicKey string) (string, error)
- func CallZvaultRetrieveSharedWallets(serverAddr, token string) (string, error)
- func CallZvaultRetrieveWallets(serverAddr, token string) (string, error)
- func CallZvaultRevokeKey(serverAddr, token, clientID, publicKey string) error
- func CallZvaultStoreKeyString(serverAddr, token, privateKey string) error
- func CallZvaultUpdateRestrictions(serverAddr, token, clientID, peerPublicKey string, restrictions []string) error
- func GetClient() *zcncrypto.Wallet
- func GetClientSysKeys(clients ...string) []sys.KeyPair
- func GetNetwork(ctx context.Context) (*conf.Network, error)
- func GetWallet() *zcncrypto.Wallet
- func Id(clients ...string) string
- func Init(ctx context.Context, cfg conf.Config) error
- func InitCache(sharders *NodeHolder)
- func InitSDK(walletJSON string, blockWorker, chainID, signatureScheme string, nonce int64, ...) error
- func InitSDKWithWebApp(params InitSdkOptions) error
- func IsSDKInitialized() bool
- func IsWalletSet() bool
- func MakeSCRestAPICallToSharder(scAddress string, relativePath string, params map[string]string, ...) ([]byte, error)
- func Mnemonic() string
- func Nonce() int64
- func PopulateClient(walletJSON, signatureScheme string) (zcncrypto.Wallet, error)
- func PrivateKey() string
- func PublicKey(clients ...string) string
- func SetAuthUrl(url string) error
- func SetIsAppFlow(val bool)
- func SetNonce(n int64)
- func SetSdkInitialized(val bool)
- func SetSignatureScheme(signatureScheme string)
- func SetSplitKeyWallet(isSplitKeyWallet bool) error
- func SetTxnFee(f uint64)
- func SetWallet(w zcncrypto.Wallet)
- func SetWalletMode(mode bool)
- func SignatureScheme() string
- func SplitKeyWallet() bool
- func TxnFee() uint64
- func VerifySignature(signature string, msg string) (bool, error)
- func VerifySignatureWith(pubKey, signature, hash string) (bool, error)
- func Wallet() *zcncrypto.Wallet
- func ZauthAuthCommon(serverAddr string) sys.AuthorizeFunc
- func ZauthSignTxn(serverAddr string) sys.AuthorizeFunc
- type AuthMessage
- type AuthResponse
- type Client
- type GetBalanceResponse
- type InitSdkOptions
- type Node
- func (n *Node) GetMinShardersVerify() int
- func (n *Node) GetStableMiners() []string
- func (n *Node) Network() *conf.Network
- func (n *Node) ResetStableMiners()
- func (n *Node) Sharders() *NodeHolder
- func (n *Node) ShouldUpdateNetwork() (bool, *conf.Network, error)
- func (n *Node) UpdateNetwork(network *conf.Network) error
- type NodeHolder
- type NodeStruct
- type NonceCache
- type SCRestAPIHandler
- type SignFunc
Constants ¶
This section is empty.
Variables ¶
var AvailableRestrictions = map[string][]string{
"token_transfers": {"transfer"},
"allocation_file_operations": {
"read_redeem",
"commit_connection",
},
"allocation_storage_operations": {
"new_allocation_request",
"update_allocation_request",
"finalize_allocation",
"cancel_allocation",
"add_free_storage_assigner",
"free_allocation_request",
},
"allocation_token_operations": {
"read_pool_lock",
"read_pool_unlock",
"write_pool_lock",
},
"storage_rewards": {
"collect_reward",
"stake_pool_lock",
"stake_pool_unlock",
},
"storage_operations": {
"challenge_response",
"add_validator",
"add_blobber",
"blobber_health_check",
"validator_health_check",
},
"storage_management": {
"kill_blobber",
"kill_validator",
"shutdown_blobber",
"shutdown_validator",
"update_blobber_settings",
"update_validator_settings",
},
"miner_operations": {
"add_miner",
"add_sharder",
"miner_health_check",
"sharder_health_check",
"contributeMpk",
"shareSignsOrShares",
"wait",
"sharder_keep",
},
"miner_management_operations": {
"delete_miner",
"delete_sharder",
"update_miner_settings",
"kill_miner",
"kill_sharder",
},
"miner_financial_operations": {
"addToDelegatePool",
"deleteFromDelegatePool",
"collect_reward",
},
"token_bridging": {
"mint",
"burn",
},
"authorizer_management_operations": {
"delete-authorizer",
},
"authorizer_operations": {
"add-authorizer",
"authorizer-health-check",
"add-to-delegate-pool",
"delete-from-delegate-pool",
},
}
AvailableRestrictions represents supported restrictions mapping.
var (
IsAppFlow = false
)
var SignFn = func(hash string) (string, error) { ss := zcncrypto.NewSignatureScheme(client.signatureScheme) err := ss.SetPrivateKey(client.wallet.Keys[0].PrivateKey) if err != nil { return "", err } return ss.Sign(hash) }
Functions ¶
func CallZauthDelete ¶ added in v1.19.0
func CallZauthRetreiveKey ¶ added in v1.19.0
func CallZauthRevoke ¶ added in v1.19.0
func CallZvaultDeletePrimaryKey ¶ added in v1.19.0
func CallZvaultNewSplit ¶ added in v1.19.0
func CallZvaultNewWallet ¶ added in v1.19.0
func CallZvaultRetrieveKeys ¶ added in v1.19.0
func CallZvaultRetrieveRestrictions ¶ added in v1.19.0
func CallZvaultRetrieveSharedWallets ¶ added in v1.19.0
func CallZvaultRetrieveWallets ¶ added in v1.19.0
func CallZvaultRevokeKey ¶ added in v1.19.0
func CallZvaultStoreKeyString ¶ added in v1.19.0
func CallZvaultUpdateRestrictions ¶ added in v1.19.0
func GetClientSysKeys ¶
func GetNetwork ¶
GetNetwork gets current network details from 0chain network.
func InitCache ¶
func InitCache(sharders *NodeHolder)
func InitSDK ¶
func InitSDK(walletJSON string, blockWorker, chainID, signatureScheme string, nonce int64, addWallet bool, options ...int) error
InitSDK Initialize the storage SDK
- walletJSON: Client's wallet JSON
- blockWorker: Block worker URL (block worker refers to 0DNS)
- chainID: ID of the blokcchain network
- signatureScheme: Signature scheme that will be used for signing transactions
- preferredBlobbers: List of preferred blobbers to use when creating an allocation. This is usually configured by the client in the configuration files
- nonce: Initial nonce value for the transactions
- fee: Preferred value for the transaction fee, just the first value is taken
func InitSDKWithWebApp ¶ added in v1.18.14
func InitSDKWithWebApp(params InitSdkOptions) error
func IsSDKInitialized ¶
func IsSDKInitialized() bool
func IsWalletSet ¶
func IsWalletSet() bool
func MakeSCRestAPICallToSharder ¶ added in v1.18.14
func PopulateClient ¶
func PrivateKey ¶
func PrivateKey() string
func SetAuthUrl ¶
SetAuthUrl will be called by app to set zauth URL to SDK
func SetIsAppFlow ¶ added in v1.18.14
func SetIsAppFlow(val bool)
func SetSdkInitialized ¶
func SetSdkInitialized(val bool)
func SetSignatureScheme ¶
func SetSignatureScheme(signatureScheme string)
func SetSplitKeyWallet ¶
splitKeyWallet parameter is valid only if SignatureScheme is "BLS0Chain"
func SetWalletMode ¶ added in v1.18.0
func SetWalletMode(mode bool)
SetWalletMode sets current wallet split key mode.
func SignatureScheme ¶
func SignatureScheme() string
func SplitKeyWallet ¶
func SplitKeyWallet() bool
func VerifySignatureWith ¶
func ZauthAuthCommon ¶ added in v1.19.0
func ZauthAuthCommon(serverAddr string) sys.AuthorizeFunc
func ZauthSignTxn ¶ added in v1.19.0
func ZauthSignTxn(serverAddr string) sys.AuthorizeFunc
ZauthSignTxn returns a function that sends a txn signing request to the zauth server
Types ¶
type AuthMessage ¶ added in v1.19.0
type AuthResponse ¶ added in v1.19.0
type AuthResponse struct {
Sig string `json:"sig"`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
maintains client's information
type GetBalanceResponse ¶
type GetBalanceResponse struct { Txn string `json:"txn"` Round int64 `json:"round"` Balance int64 `json:"balance"` Nonce int64 `json:"nonce"` }
func GetBalance ¶
func GetBalance(clientIDs ...string) (*GetBalanceResponse, error)
func (GetBalanceResponse) ToToken ¶
func (b GetBalanceResponse) ToToken() (float64, error)
ToToken converts Balance to ZCN tokens.
type InitSdkOptions ¶ added in v1.18.14
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node Maintains central states of SDK (client's context, network). Initialized through Init function. Use client.GetNode() to get its instance after Init is called.
func GetNode ¶
GetNode Returns Node instance. If this function is called before Init(), error is returned.
func (*Node) GetMinShardersVerify ¶
GetMinShardersVerify Returns minimum sharders used for verification
func (*Node) GetStableMiners ¶
GetStableMiners Returns stable miner urls. Length of stable miners is depedent on config's MinSubmit and number of miners in network.
func (*Node) ResetStableMiners ¶
func (n *Node) ResetStableMiners()
ResetStableMiners resets stable miners as a random permutation of network miners. Length of stable miners is depedent on config's MinSubmit and number of miners in network.
func (*Node) ShouldUpdateNetwork ¶
ShouldUpdateNetwork Gets network details and return it as second value. First value is true iff current network details doesn't match existing network details. Use node.UpdateNetwork() method to set the new network.
type NodeHolder ¶
type NodeHolder struct {
// contains filtered or unexported fields
}
func NewHolder ¶
func NewHolder(nodes []string, consensus int) *NodeHolder
func (*NodeHolder) All ¶
func (h *NodeHolder) All() (res []string)
func (*NodeHolder) Fail ¶
func (h *NodeHolder) Fail(id string)
func (*NodeHolder) Healthy ¶
func (h *NodeHolder) Healthy() (res []string)
func (*NodeHolder) Success ¶
func (h *NodeHolder) Success(id string)
type NodeStruct ¶
type NodeStruct struct {
// contains filtered or unexported fields
}
func NewNode ¶
func NewNode(id string) *NodeStruct
type NonceCache ¶
type NonceCache struct {
// contains filtered or unexported fields
}
var Cache *NonceCache
func (*NonceCache) Evict ¶
func (nc *NonceCache) Evict(clientId string)
func (*NonceCache) GetNextNonce ¶
func (nc *NonceCache) GetNextNonce(clientId string) int64
func (*NonceCache) Set ¶
func (nc *NonceCache) Set(clientId string, nonce int64)
type SCRestAPIHandler ¶
SCRestAPIHandler is a function type to handle the response from the SC Rest API
`response` - the response from the SC Rest API `numSharders` - the number of sharders that responded `err` - the error if any