utils

package
v0.0.0-...-f78fda5 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Copyright (C) THL A29 Limited, a Tencent company. All rights reserved.

SPDX-License-Identifier: Apache-2.0

Copyright (C) THL A29 Limited, a Tencent company. All rights reserved.

SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	HibeMsgKey           = "hibe_msg"
	HibeMsgIdKey         = "tx_id"
	HibeMsgCipherTextKey = "CT"
	HibeParamsKey        = "org_id"
	HibeParamsValueKey   = "params"
)

hibe msg's Keys

View Source
const (
	// System Block Contract keys
	KeyBlockContractWithRWSet   = "withRWSet"
	KeyBlockContractBlockHash   = "blockHash"
	KeyBlockContractBlockHeight = "blockHeight"
	KeyBlockContractTxId        = "txId"

	// System Chain Config Contract keys
	KeyChainConfigContractRoot              = "root"
	KeyChainConfigContractOrgId             = "org_id"
	KeyChainConfigContractNodeId            = "node_id"
	KeyChainConfigContractNewNodeId         = "new_node_id"
	KeyChainConfigContractNodeIds           = "node_ids"
	KeyChainConfigContractBlockHeight       = "block_height"
	KeyChainConfigContractTrustMemberOrgId  = "org_id"
	KeyChainConfigContractTrustMemberInfo   = "member_info"
	KeyChainConfigContractTrustMemberNodeId = "node_id"
	KeyChainConfigContractTrustMemberRole   = "role"

	// CoreConfig keys
	KeyTxSchedulerTimeout         = "tx_scheduler_timeout"
	KeyTxSchedulerValidateTimeout = "tx_scheduler_validate_timeout"

	// BlockConfig keys
	KeyTxTimeOut       = "tx_timeout"
	KeyBlockTxCapacity = "block_tx_capacity"
	KeyBlockSize       = "block_size"
	KeyBlockInterval   = "block_interval"

	// CertManage keys
	KeyCertHashes = "cert_hashes"
	KeyCerts      = "certs"
	KeyCertCrl    = "cert_crl"

	// PrivateCompute keys
	KeyOrderId      = "order_id"
	KeyPrivateDir   = "private_dir"
	KeyContractName = "contract_name"
	KeyCodeHash     = "code_hash"
	KeyResult       = "result"
	KeyCodeHeader   = "code_header"
	KeyVersion      = "version"
	KeyIsDeploy     = "is_deploy"
	KeyRWSet        = "rw_set"
	KeyEvents       = "events"
	KeyReportHash   = "report_hash"
	KeySign         = "sign"
	KeyKey          = "key"
	KeyPayload      = "payload"
	KeyOrgIds       = "org_ids"
	KeySignPairs    = "sign_pairs"
	KeyCaCert       = "ca_cert"
	KeyEnclaveId    = "enclave_id"
	KeyReport       = "report"
	KeyProof        = "proof"
	KeyDeployReq    = "deploy_req"
	KeyPrivateReq   = "private_req"
)

nolint

View Source
const (
	// ArchiveConfig consts
	MysqlDBNamePrefix     = "cm_archived_chain"
	MysqlTableNamePrefix  = "t_block_info"
	RowsPerBlockInfoTable = 100000
)

nolint

View Source
const (
	// SUCCESS ContractResult success code
	SUCCESS uint32 = 0
)

Variables

This section is empty.

Functions

func BytesToI64

func BytesToI64(b []byte) (int64, error)

func BytesToU64

func BytesToU64(b []byte) (uint64, error)

func CheckProposalRequestResp

func CheckProposalRequestResp(resp *common.TxResponse, needContractResult bool) error

func DecryptHibeTx

func DecryptHibeTx(localId string, hibeParams []byte, hibePrvKey []byte, tx *common.Transaction,
	keyType crypto.KeyType) ([]byte, error)

func Exists

func Exists(path string) bool

func GetCertificateId

func GetCertificateId(certPEM []byte, hashType string) ([]byte, error)

func GetCertificateIdFromDER

func GetCertificateIdFromDER(certDER []byte, hashType string) ([]byte, error)

func GetRandTxId

func GetRandTxId() string

func I64ToBytes

func I64ToBytes(i int64) []byte

func InitConfig

func InitConfig(confPath string) error

func IsArchived

func IsArchived(txStatusCode common.TxStatusCode) bool

func IsArchivedString

func IsArchivedString(txStatusCode string) bool

func NewPayload

func NewPayload(opts ...PayloadOption) *commonPb.Payload

func ParseCert

func ParseCert(crtPEM []byte) (*bcx509.Certificate, error)

func ReadHibeParamsWithFilePath

func ReadHibeParamsWithFilePath(hibeParamsFilePath string) ([]byte, error)

ReadHibeParamsWithFilePath Returns the serialized byte array of hibeParams

func ReadHibePrvKeysWithFilePath

func ReadHibePrvKeysWithFilePath(hibePrvKeyFilePath string) ([]byte, error)

ReadHibePrvKeysWithFilePath Returns the serialized byte array of hibePrvKey

func SignPayload

func SignPayload(privateKey crypto.PrivateKey, cert *bcx509.Certificate, payload *common.Payload) ([]byte, error)

func SignPayloadBytes

func SignPayloadBytes(privateKey crypto.PrivateKey, cert *bcx509.Certificate, payloadBytes []byte) ([]byte, error)

func U64ToBytes

func U64ToBytes(i uint64) []byte

Types

type ChainClientConfigModel

type ChainClientConfigModel struct {
	ChainClientConfig chainClientConfigModel `mapstructure:"chain_client"`
}

Config global ChainClientConfigModel

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})

	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
}

type PayloadOption

type PayloadOption func(*commonPb.Payload)

func AddParameter

func AddParameter(parameter *commonPb.KeyValuePair) PayloadOption

AddParameter add one Parameter of payload

func WithChainId

func WithChainId(chainId string) PayloadOption

WithChainId set chainId of payload

func WithContractName

func WithContractName(contractName string) PayloadOption

WithContractName set ContractName of payload

func WithExpirationTime

func WithExpirationTime(expirationTime int64) PayloadOption

WithExpirationTime set ExpirationTime of payload

func WithLimit

func WithLimit(limit []byte) PayloadOption

WithLimit set Limit of payload

func WithMethod

func WithMethod(method string) PayloadOption

WithMethod set Method of payload

func WithParameters

func WithParameters(parameters []*commonPb.KeyValuePair) PayloadOption

WithParameters set Parameters of payload

func WithSequence

func WithSequence(sequence uint64) PayloadOption

WithSequence set Sequence of payload

func WithTimestamp

func WithTimestamp(timestamp int64) PayloadOption

WithTimestamp set Timestamp of payload

func WithTxId

func WithTxId(txId string) PayloadOption

WithTxId set TxId of payload

func WithTxType

func WithTxType(txType commonPb.TxType) PayloadOption

WithTxType set TxType of payload

Jump to

Keyboard shortcuts

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