Documentation ¶
Index ¶
- Constants
- Variables
- func EstimateFee(txn *Transaction, miners []string, reqPercent ...float32) (uint64, error)
- func GetFeesTable(miners []string, reqPercent ...float32) (map[string]map[string]int64, error)
- func SendTransactionSync(txn *Transaction, miners []string) error
- type Block
- type OptimisticVerifier
- type Ratio
- type RoundBlockHeader
- type SignFunc
- type SignWithWallet
- type SmartContractTxnData
- type StorageAllocation
- type Transaction
- func (t *Transaction) ComputeHashAndSign(signHandler SignFunc) error
- func (t *Transaction) ComputeHashAndSignWithWallet(signHandler SignWithWallet, signingWallet interface{}) error
- func (t *Transaction) ComputeHashData()
- func (t *Transaction) DebugJSON() []byte
- func (t *Transaction) VerifyTransaction(verifyHandler VerifyFunc) (bool, error)
- type TxnReceipt
- type VerifyFunc
Constants ¶
View Source
const ( TxnSuccess = 1 // Indicates the transaction is successful in updating the state or smart contract TxnChargeableError = 2 // Indicates the transaction is successful in updating the state or smart contract TxnFail = 3 // Indicates a transaction has failed to update the state or smart contract )
View Source
const ( NEW_ALLOCATION_REQUEST = "new_allocation_request" NEW_FREE_ALLOCATION = "free_allocation_request" UPDATE_ALLOCATION_REQUEST = "update_allocation_request" LOCK_TOKEN = "lock" UNLOCK_TOKEN = "unlock" ADD_FREE_ALLOCATION_ASSIGNER = "add_free_storage_assigner" // Vesting SC VESTING_TRIGGER = "trigger" VESTING_STOP = "stop" VESTING_UNLOCK = "unlock" VESTING_ADD = "add" VESTING_DELETE = "delete" VESTING_UPDATE_SETTINGS = "vestingsc-update-settings" // Storage SC STORAGESC_FINALIZE_ALLOCATION = "finalize_allocation" STORAGESC_CANCEL_ALLOCATION = "cancel_allocation" STORAGESC_CREATE_ALLOCATION = "new_allocation_request" STORAGESC_CREATE_READ_POOL = "new_read_pool" STORAGESC_READ_POOL_LOCK = "read_pool_lock" STORAGESC_READ_POOL_UNLOCK = "read_pool_unlock" STORAGESC_STAKE_POOL_LOCK = "stake_pool_lock" STORAGESC_STAKE_POOL_UNLOCK = "stake_pool_unlock" STORAGESC_UPDATE_BLOBBER_SETTINGS = "update_blobber_settings" STORAGESC_UPDATE_VALIDATOR_SETTINGS = "update_validator_settings" STORAGESC_UPDATE_ALLOCATION = "update_allocation_request" STORAGESC_WRITE_POOL_LOCK = "write_pool_lock" STORAGESC_WRITE_POOL_UNLOCK = "write_pool_unlock" STORAGESC_UPDATE_SETTINGS = "update_settings" ADD_HARDFORK = "add_hardfork" STORAGESC_COLLECT_REWARD = "collect_reward" STORAGESC_KILL_BLOBBER = "kill_blobber" STORAGESC_KILL_VALIDATOR = "kill_validator" STORAGESC_SHUTDOWN_BLOBBER = "shutdown_blobber" STORAGESC_SHUTDOWN_VALIDATOR = "shutdown_validator" STORAGESC_RESET_BLOBBER_STATS = "reset_blobber_stats" STORAGESC_RESET_ALLOCATION_STATS = "reset_allocation_stats" MINERSC_LOCK = "addToDelegatePool" MINERSC_UNLOCK = "deleteFromDelegatePool" MINERSC_MINER_SETTINGS = "update_miner_settings" MINERSC_SHARDER_SETTINGS = "update_sharder_settings" MINERSC_UPDATE_SETTINGS = "update_settings" MINERSC_UPDATE_GLOBALS = "update_globals" MINERSC_MINER_DELETE = "delete_miner" MINERSC_SHARDER_DELETE = "delete_sharder" MINERSC_COLLECT_REWARD = "collect_reward" MINERSC_KILL_MINER = "kill_miner" MINERSC_KILL_SHARDER = "kill_sharder" // Faucet SC FAUCETSC_UPDATE_SETTINGS = "update-settings" ZCNSC_UPDATE_GLOBAL_CONFIG = "update-global-config" ZCNSC_UPDATE_AUTHORIZER_CONFIG = "update-authorizer-config" ZCNSC_ADD_AUTHORIZER = "add-authorizer" ZCNSC_AUTHORIZER_HEALTH_CHECK = "authorizer-health-check" ZCNSC_DELETE_AUTHORIZER = "delete-authorizer" ZCNSC_COLLECT_REWARD = "collect-rewards" ZCNSC_LOCK = "add-to-delegate-pool" ZCNSC_UNLOCK = "delete-from-delegate-pool" ESTIMATE_TRANSACTION_COST = `/v1/estimate_txn_fee` FEES_TABLE = `/v1/fees_table` )
View Source
const ( TxnTypeSend = 0 // A transaction to send tokens to another account, state is maintained by account TxnTypeLockIn = 2 // A transaction to lock tokens, state is maintained on the account and the parent lock in transaction // Any txn type that refers to a parent txn should have an odd value TxnTypeStorageWrite = 101 // A transaction to write data to the blobber TxnTypeStorageRead = 103 // A transaction to read data from the blobber TxnTypeData = 10 // A transaction to just store a piece of data on the block chain TxnTypeSmartContract = 1000 // A smart contract transaction type )
View Source
const BLOCK_BY_ROUND_URL = "v1/screst/6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d7/block?round="
View Source
const TXN_SUBMIT_URL = "v1/transaction/put"
View Source
const TXN_VERIFY_URL = "v1/transaction/get/confirmation?hash="
Variables ¶
View Source
var ( // ErrInvalidRequest invalid request ErrInvalidRequest = errors.New("[txn] invalid request") // ErrNoAvailableSharder no any available sharder ErrNoAvailableSharder = errors.New("[txn] there is no any available sharder") // ErrNoTxnDetail No transaction detail was found on any of the sharders ErrNoTxnDetail = errors.New("[txn] no transaction detail was found on any of the sharders") // ErrTooLessConfirmation too less sharder to confirm transaction ErrTooLessConfirmation = errors.New("[txn] too less sharders to confirm it") )
Functions ¶
func EstimateFee ¶ added in v1.8.16
func EstimateFee(txn *Transaction, miners []string, reqPercent ...float32) (uint64, error)
EstimateFee estimates transaction fee
func GetFeesTable ¶ added in v1.8.17
GetFeesTable get fee tables
func SendTransactionSync ¶
func SendTransactionSync(txn *Transaction, miners []string) error
Types ¶
type Block ¶ added in v1.8.12
type Block struct { Hash string `json:"hash" gorm:"uniqueIndex:idx_bhash"` Version string `json:"version"` CreationDate int64 `json:"creation_date" gorm:"index:idx_bcreation_date"` Round int64 `json:"round" gorm:"index:idx_bround"` MinerID string `json:"miner_id"` RoundRandomSeed int64 `json:"round_random_seed"` MerkleTreeRoot string `json:"merkle_tree_root"` StateHash string `json:"state_hash"` ReceiptMerkleTreeRoot string `json:"receipt_merkle_tree_root"` NumTxns int `json:"num_txns"` MagicBlockHash string `json:"magic_block_hash"` PrevHash string `json:"prev_hash"` Signature string `json:"signature"` ChainId string `json:"chain_id"` StateChangesCount int `json:"state_changes_count"` RunningTxnCount string `json:"running_txn_count"` RoundTimeoutCount int `json:"round_timeout_count"` }
type OptimisticVerifier ¶ added in v1.8.12
type OptimisticVerifier struct {
// contains filtered or unexported fields
}
func NewOptimisticVerifier ¶ added in v1.8.12
func NewOptimisticVerifier(sharders []string) *OptimisticVerifier
func (*OptimisticVerifier) VerifyTransactionOptimistic ¶ added in v1.8.12
func (v *OptimisticVerifier) VerifyTransactionOptimistic(txnHash string) (*Transaction, error)
type RoundBlockHeader ¶
type RoundBlockHeader struct { Version string `json:"version"` CreationDate int64 `json:"creation_date"` Hash string `json:"block_hash"` PreviousBlockHash string `json:"previous_block_hash"` MinerID string `json:"miner_id"` Round int64 `json:"round"` RoundRandomSeed int64 `json:"round_random_seed"` MerkleTreeRoot string `json:"merkle_tree_root"` StateChangesCount int `json:"state_changes_count"` StateHash string `json:"state_hash"` ReceiptMerkleTreeRoot string `json:"receipt_merkle_tree_root"` NumberOfTxns int64 `json:"num_txns"` }
type SignWithWallet ¶
type SmartContractTxnData ¶
type SmartContractTxnData struct { Name string `json:"name"` InputArgs interface{} `json:"input"` }
type StorageAllocation ¶
type StorageAllocation struct { ID string `json:"id"` DataShards int `json:"data_shards"` ParityShards int `json:"parity_shards"` Size int64 `json:"size"` Expiration int64 `json:"expiration_date"` Owner string `json:"owner_id"` OwnerPublicKey string `json:"owner_public_key"` ReadRatio *Ratio `json:"read_ratio"` WriteRatio *Ratio `json:"write_ratio"` MinLockDemand float64 `json:"min_lock_demand"` }
type Transaction ¶
type Transaction struct { Hash string `json:"hash,omitempty"` Version string `json:"version,omitempty"` ClientID string `json:"client_id,omitempty"` PublicKey string `json:"public_key,omitempty"` ToClientID string `json:"to_client_id,omitempty"` ChainID string `json:"chain_id,omitempty"` TransactionData string `json:"transaction_data"` Value uint64 `json:"transaction_value"` Signature string `json:"signature,omitempty"` CreationDate int64 `json:"creation_date,omitempty"` TransactionType int `json:"transaction_type"` TransactionOutput string `json:"transaction_output,omitempty"` TransactionFee uint64 `json:"transaction_fee"` TransactionNonce int64 `json:"transaction_nonce"` OutputHash string `json:"txn_output_hash"` Status int `json:"transaction_status"` }
Transaction entity that encapsulates the transaction related data and meta data
func NewTransactionEntity ¶
func NewTransactionEntity(clientID string, chainID string, publicKey string, nonce int64) *Transaction
func VerifyTransaction ¶
func VerifyTransaction(txnHash string, sharders []string) (*Transaction, error)
VerifyTransaction query transaction status from sharders, and verify it by mininal confirmation
func VerifyTransactionTrusted ¶ added in v1.8.12
func VerifyTransactionTrusted(txnHash string, sharders []string) (*Transaction, error)
VerifyTransaction query transaction status from sharders, and verify it by mininal confirmation
func (*Transaction) ComputeHashAndSign ¶
func (t *Transaction) ComputeHashAndSign(signHandler SignFunc) error
func (*Transaction) ComputeHashAndSignWithWallet ¶
func (t *Transaction) ComputeHashAndSignWithWallet(signHandler SignWithWallet, signingWallet interface{}) error
func (*Transaction) ComputeHashData ¶
func (t *Transaction) ComputeHashData()
func (*Transaction) DebugJSON ¶ added in v1.3.0
func (t *Transaction) DebugJSON() []byte
func (*Transaction) VerifyTransaction ¶
func (t *Transaction) VerifyTransaction(verifyHandler VerifyFunc) (bool, error)
type TxnReceipt ¶
type TxnReceipt struct {
Transaction *Transaction
}
TxnReceipt - a transaction receipt is a processed transaction that contains the output
func NewTransactionReceipt ¶
func NewTransactionReceipt(t *Transaction) *TxnReceipt
NewTransactionReceipt - create a new transaction receipt
func (*TxnReceipt) GetHashBytes ¶
func (rh *TxnReceipt) GetHashBytes() []byte
GetHashBytes - implement Hashable interface
type VerifyFunc ¶
Click to show internal directories.
Click to hide internal directories.