Commit a3f9db50 authored by pengjun's avatar pengjun Committed by vipwzw

cert执行器linter告警整改

parent 0c401767
...@@ -25,17 +25,17 @@ var ( ...@@ -25,17 +25,17 @@ var (
alog = log.New("module", "authority") alog = log.New("module", "authority")
cpuNum = runtime.NumCPU() cpuNum = runtime.NumCPU()
// 默认证书组织名 // OrgName 默认证书组织名
OrgName = "Chain33" OrgName = "Chain33"
// 全局证书校验器 // Author 全局证书校验器
Author = &Authority{} Author = &Authority{}
// 是否开启全局校验开关 // IsAuthEnable 是否开启全局校验开关
IsAuthEnable = false IsAuthEnable = false
) )
// 证书校验器主要结构 // Authority 证书校验器主要结构
type Authority struct { type Authority struct {
// 证书文件路径 // 证书文件路径
cryptoPath string cryptoPath string
...@@ -51,14 +51,14 @@ type Authority struct { ...@@ -51,14 +51,14 @@ type Authority struct {
HistoryCertCache *HistoryCertData HistoryCertCache *HistoryCertData
} }
// 历史变更记录 // HistoryCertData 历史变更记录
type HistoryCertData struct { type HistoryCertData struct {
CryptoCfg *core.AuthConfig CryptoCfg *core.AuthConfig
CurHeight int64 CurHeight int64
NxtHeight int64 NxtHeight int64
} }
// 初始化auth // Init 初始化auth
func (auth *Authority) Init(conf *ty.Authority) error { func (auth *Authority) Init(conf *ty.Authority) error {
if conf == nil || !conf.Enable { if conf == nil || !conf.Enable {
return nil return nil
...@@ -98,7 +98,7 @@ func (auth *Authority) Init(conf *ty.Authority) error { ...@@ -98,7 +98,7 @@ func (auth *Authority) Init(conf *ty.Authority) error {
return nil return nil
} }
// store数据转成authConfig数据 // newAuthConfig store数据转成authConfig数据
func newAuthConfig(store *types.HistoryCertStore) *core.AuthConfig { func newAuthConfig(store *types.HistoryCertStore) *core.AuthConfig {
ret := &core.AuthConfig{} ret := &core.AuthConfig{}
ret.RootCerts = make([][]byte, len(store.Rootcerts)) ret.RootCerts = make([][]byte, len(store.Rootcerts))
...@@ -119,7 +119,7 @@ func newAuthConfig(store *types.HistoryCertStore) *core.AuthConfig { ...@@ -119,7 +119,7 @@ func newAuthConfig(store *types.HistoryCertStore) *core.AuthConfig {
return ret return ret
} }
// 从数据库中的记录数据恢复证书,用于证书回滚 // ReloadCert 从数据库中的记录数据恢复证书,用于证书回滚
func (auth *Authority) ReloadCert(store *types.HistoryCertStore) error { func (auth *Authority) ReloadCert(store *types.HistoryCertStore) error {
if !IsAuthEnable { if !IsAuthEnable {
return nil return nil
...@@ -148,7 +148,7 @@ func (auth *Authority) ReloadCert(store *types.HistoryCertStore) error { ...@@ -148,7 +148,7 @@ func (auth *Authority) ReloadCert(store *types.HistoryCertStore) error {
return nil return nil
} }
// 从新的authdir下的文件更新证书,用于证书更新 // ReloadCertByHeght 从新的authdir下的文件更新证书,用于证书更新
func (auth *Authority) ReloadCertByHeght(currentHeight int64) error { func (auth *Authority) ReloadCertByHeght(currentHeight int64) error {
if !IsAuthEnable { if !IsAuthEnable {
return nil return nil
...@@ -177,7 +177,7 @@ func (auth *Authority) ReloadCertByHeght(currentHeight int64) error { ...@@ -177,7 +177,7 @@ func (auth *Authority) ReloadCertByHeght(currentHeight int64) error {
return nil return nil
} }
// 并发校验证书 // ValidateCerts 并发校验证书
func (auth *Authority) ValidateCerts(task []*types.Signature) bool { func (auth *Authority) ValidateCerts(task []*types.Signature) bool {
//FIXME 有并发校验的场景需要考虑竞争,暂时没有并发校验的场景 //FIXME 有并发校验的场景需要考虑竞争,暂时没有并发校验的场景
done := make(chan struct{}) done := make(chan struct{})
...@@ -239,7 +239,7 @@ func (auth *Authority) task(done <-chan struct{}, taskes <-chan *types.Signature ...@@ -239,7 +239,7 @@ func (auth *Authority) task(done <-chan struct{}, taskes <-chan *types.Signature
} }
} }
// 检验证书 // Validate 检验证书
func (auth *Authority) Validate(signature *types.Signature) error { func (auth *Authority) Validate(signature *types.Signature) error {
// 从proto中解码signature // 从proto中解码signature
cert, err := auth.validator.GetCertFromSignature(signature.Signature) cert, err := auth.validator.GetCertFromSignature(signature.Signature)
...@@ -265,7 +265,7 @@ func (auth *Authority) Validate(signature *types.Signature) error { ...@@ -265,7 +265,7 @@ func (auth *Authority) Validate(signature *types.Signature) error {
return nil return nil
} }
// 历史数据转成store可存储的历史数据 // ToHistoryCertStore 历史数据转成store可存储的历史数据
func (certdata *HistoryCertData) ToHistoryCertStore(store *types.HistoryCertStore) { func (certdata *HistoryCertData) ToHistoryCertStore(store *types.HistoryCertStore) {
if store == nil { if store == nil {
alog.Error("Convert cert data to cert store failed") alog.Error("Convert cert data to cert store failed")
...@@ -291,21 +291,21 @@ func (certdata *HistoryCertData) ToHistoryCertStore(store *types.HistoryCertStor ...@@ -291,21 +291,21 @@ func (certdata *HistoryCertData) ToHistoryCertStore(store *types.HistoryCertStor
store.NxtHeight = certdata.NxtHeight store.NxtHeight = certdata.NxtHeight
} }
// 用户关联的证书私钥信息 // User 用户关联的证书私钥信息
type User struct { type User struct {
ID string ID string
Cert []byte Cert []byte
Key crypto.PrivKey Key crypto.PrivKey
} }
// userloader, SKD加载user使用 // UserLoader SKD加载user使用
type UserLoader struct { type UserLoader struct {
configPath string configPath string
userMap map[string]*User userMap map[string]*User
signType int signType int
} }
// userloader初始化 // Init userloader初始化
func (loader *UserLoader) Init(configPath string, signType string) error { func (loader *UserLoader) Init(configPath string, signType string) error {
loader.configPath = configPath loader.configPath = configPath
loader.userMap = make(map[string]*User) loader.userMap = make(map[string]*User)
...@@ -376,7 +376,7 @@ func (loader *UserLoader) genCryptoPriv(keyBytes []byte) (crypto.PrivKey, error) ...@@ -376,7 +376,7 @@ func (loader *UserLoader) genCryptoPriv(keyBytes []byte) (crypto.PrivKey, error)
return priv, nil return priv, nil
} }
// 根据用户名获取user结构 // Get 根据用户名获取user结构
func (loader *UserLoader) Get(userName string) (*User, error) { func (loader *UserLoader) Get(userName string) (*User, error) {
keyvalue := fmt.Sprintf("%s@%s-cert.pem", userName, OrgName) keyvalue := fmt.Sprintf("%s@%s-cert.pem", userName, OrgName)
user, ok := loader.userMap[keyvalue] user, ok := loader.userMap[keyvalue]
......
...@@ -109,7 +109,7 @@ func certFromX509Cert(cert *x509.Certificate) (certificate, error) { ...@@ -109,7 +109,7 @@ func certFromX509Cert(cert *x509.Certificate) (certificate, error) {
return newCert, nil return newCert, nil
} }
// 将ECDSA的公钥转成SM2公钥 // ParseECDSAPubKey2SM2PubKey 将ECDSA的公钥转成SM2公钥
func ParseECDSAPubKey2SM2PubKey(key *ecdsa.PublicKey) *sm2.PublicKey { func ParseECDSAPubKey2SM2PubKey(key *ecdsa.PublicKey) *sm2.PublicKey {
sm2Key := &sm2.PublicKey{ sm2Key := &sm2.PublicKey{
key.Curve, key.Curve,
......
...@@ -54,7 +54,7 @@ const ( ...@@ -54,7 +54,7 @@ const (
crlsfolder = "crls" crlsfolder = "crls"
) )
// 获取证书文件配置 // GetAuthConfig 获取证书文件配置
func GetAuthConfig(dir string) (*AuthConfig, error) { func GetAuthConfig(dir string) (*AuthConfig, error) {
cacertDir := filepath.Join(dir, cacerts) cacertDir := filepath.Join(dir, cacerts)
intermediatecertsDir := filepath.Join(dir, intermediatecerts) intermediatecertsDir := filepath.Join(dir, intermediatecerts)
......
...@@ -38,7 +38,7 @@ type ecdsaValidator struct { ...@@ -38,7 +38,7 @@ type ecdsaValidator struct {
CRL []*pkix.CertificateList CRL []*pkix.CertificateList
} }
// 创建ecdsa校验器 // NewEcdsaValidator 创建ecdsa校验器
func NewEcdsaValidator() Validator { func NewEcdsaValidator() Validator {
return &ecdsaValidator{} return &ecdsaValidator{}
} }
......
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
ty "github.com/33cn/plugin/plugin/dapp/cert/types" ty "github.com/33cn/plugin/plugin/dapp/cert/types"
) )
// 根据类型获取校验器 // GetLocalValidator 根据类型获取校验器
func GetLocalValidator(authConfig *AuthConfig, signType int) (Validator, error) { func GetLocalValidator(authConfig *AuthConfig, signType int) (Validator, error) {
var lclValidator Validator var lclValidator Validator
var err error var err error
......
...@@ -33,7 +33,7 @@ type gmValidator struct { ...@@ -33,7 +33,7 @@ type gmValidator struct {
CRL []*pkix.CertificateList CRL []*pkix.CertificateList
} }
// 创建国密证书校验器 // NewGmValidator 创建国密证书校验器
func NewGmValidator() Validator { func NewGmValidator() Validator {
return &gmValidator{} return &gmValidator{}
} }
......
...@@ -7,7 +7,7 @@ package core ...@@ -7,7 +7,7 @@ package core
type noneValidator struct { type noneValidator struct {
} }
// 创建none校验器 // NewNoneValidator 创建none校验器
func NewNoneValidator() (Validator, error) { func NewNoneValidator() (Validator, error) {
return &noneValidator{}, nil return &noneValidator{}, nil
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
package core package core
// 证书校验器 // Validator 证书校验器
type Validator interface { type Validator interface {
Setup(config *AuthConfig) error Setup(config *AuthConfig) error
...@@ -13,7 +13,7 @@ type Validator interface { ...@@ -13,7 +13,7 @@ type Validator interface {
GetCertFromSignature(signature []byte) ([]byte, error) GetCertFromSignature(signature []byte) ([]byte, error)
} }
// 校验器配置 // AuthConfig 校验器配置
type AuthConfig struct { type AuthConfig struct {
RootCerts [][]byte RootCerts [][]byte
IntermediateCerts [][]byte IntermediateCerts [][]byte
......
...@@ -17,14 +17,14 @@ import ( ...@@ -17,14 +17,14 @@ import (
) )
const ( const (
// 默认CA名称 // CANAME 默认CA名称
CANAME = "ca" CANAME = "ca"
CONFIGFILENAME = "chain33.cryptogen.toml" CONFIGFILENAME = "chain33.cryptogen.toml"
OUTPUTDIR = "./authdir/crypto" OUTPUTDIR = "./authdir/crypto"
ORGNAME = "Chain33" ORGNAME = "Chain33"
) )
// 证书生成工具配置 // Config 证书生成工具配置
type Config struct { type Config struct {
Name []string Name []string
SignType string SignType string
......
...@@ -7,12 +7,12 @@ package csp ...@@ -7,12 +7,12 @@ package csp
import "crypto" import "crypto"
const ( const (
// ECDSA类型 // ECDSAP256KeyGen ECDSA类型
ECDSAP256KeyGen = 1 ECDSAP256KeyGen = 1
SM2P256KygGen = 2 SM2P256KygGen = 2
) )
// 通用key接口 // Key 通用key接口
type Key interface { type Key interface {
Bytes() ([]byte, error) Bytes() ([]byte, error)
SKI() []byte SKI() []byte
...@@ -21,30 +21,30 @@ type Key interface { ...@@ -21,30 +21,30 @@ type Key interface {
PublicKey() (Key, error) PublicKey() (Key, error)
} }
// 签名器参数接口 // SignerOpts 签名器参数接口
type SignerOpts interface { type SignerOpts interface {
crypto.SignerOpts crypto.SignerOpts
} }
// 证书生成器接口 // CSP 证书生成器接口
type CSP interface { type CSP interface {
KeyGen(opts int) (k Key, err error) KeyGen(opts int) (k Key, err error)
Sign(k Key, digest []byte, opts SignerOpts) (signature []byte, err error) Sign(k Key, digest []byte, opts SignerOpts) (signature []byte, err error)
} }
// key存储接口 // KeyStore key存储接口
type KeyStore interface { type KeyStore interface {
ReadOnly() bool ReadOnly() bool
StoreKey(k Key) (err error) StoreKey(k Key) (err error)
} }
// 签名器接口 // Signer 签名器接口
type Signer interface { type Signer interface {
Sign(k Key, digest []byte, opts SignerOpts) (signature []byte, err error) Sign(k Key, digest []byte, opts SignerOpts) (signature []byte, err error)
} }
// key生成器接口 // KeyGenerator key生成器接口
type KeyGenerator interface { type KeyGenerator interface {
KeyGen(opts int) (k Key, err error) KeyGen(opts int) (k Key, err error)
} }
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
// 创建新的证书生成结构 // New 创建新的证书生成结构
func New(keyStore KeyStore) (CSP, error) { func New(keyStore KeyStore) (CSP, error) {
signers := make(map[reflect.Type]Signer) signers := make(map[reflect.Type]Signer)
signers[reflect.TypeOf(&ecdsaPrivateKey{})] = &ecdsaSigner{} signers[reflect.TypeOf(&ecdsaPrivateKey{})] = &ecdsaSigner{}
......
...@@ -32,12 +32,12 @@ func signECDSA(k *ecdsa.PrivateKey, digest []byte, opts SignerOpts) (signature [ ...@@ -32,12 +32,12 @@ func signECDSA(k *ecdsa.PrivateKey, digest []byte, opts SignerOpts) (signature [
return MarshalECDSASignature(r, s) return MarshalECDSASignature(r, s)
} }
// ECDSA签名结构 // ECDSASignature ECDSA签名结构
type ECDSASignature struct { type ECDSASignature struct {
R, S *big.Int R, S *big.Int
} }
// 编码ECDSA类型签名 // MarshalECDSASignature 编码ECDSA类型签名
func MarshalECDSASignature(r, s *big.Int) ([]byte, error) { func MarshalECDSASignature(r, s *big.Int) ([]byte, error) {
return asn1.Marshal(ECDSASignature{r, s}) return asn1.Marshal(ECDSASignature{r, s})
} }
......
...@@ -22,7 +22,7 @@ import ( ...@@ -22,7 +22,7 @@ import (
var logger = log.New("tools", "cryptogen") var logger = log.New("tools", "cryptogen")
// 创建key存储器 // NewFileBasedKeyStore 创建key存储器
func NewFileBasedKeyStore(pwd []byte, path string, readOnly bool) (KeyStore, error) { func NewFileBasedKeyStore(pwd []byte, path string, readOnly bool) (KeyStore, error) {
ks := &fileBasedKeyStore{} ks := &fileBasedKeyStore{}
return ks, ks.Init(pwd, path, readOnly) return ks, ks.Init(pwd, path, readOnly)
......
...@@ -27,12 +27,12 @@ func signSM2(k *sm2.PrivateKey, digest []byte, opts SignerOpts) (signature []byt ...@@ -27,12 +27,12 @@ func signSM2(k *sm2.PrivateKey, digest []byte, opts SignerOpts) (signature []byt
return MarshalSM2Signature(r, s) return MarshalSM2Signature(r, s)
} }
// SM2签名结构 // SM2Signature SM2签名结构
type SM2Signature struct { type SM2Signature struct {
R, S *big.Int R, S *big.Int
} }
// 编码SM2起签名 // MarshalSM2Signature 编码SM2起签名
func MarshalSM2Signature(r, s *big.Int) ([]byte, error) { func MarshalSM2Signature(r, s *big.Int) ([]byte, error) {
return asn1.Marshal(SM2Signature{r, s}) return asn1.Marshal(SM2Signature{r, s})
} }
......
...@@ -20,7 +20,7 @@ type cspCryptoSigner struct { ...@@ -20,7 +20,7 @@ type cspCryptoSigner struct {
pk interface{} pk interface{}
} }
// 创建签名器 // New 创建签名器
func New(csp lccsp.CSP, key lccsp.Key) (crypto.Signer, error) { func New(csp lccsp.CSP, key lccsp.Key) (crypto.Signer, error) {
if csp == nil { if csp == nil {
return nil, errors.New("bccsp instance must be different from nil") return nil, errors.New("bccsp instance must be different from nil")
......
...@@ -211,7 +211,7 @@ func publicKeyToEncryptedPEM(publicKey interface{}, pwd []byte) ([]byte, error) ...@@ -211,7 +211,7 @@ func publicKeyToEncryptedPEM(publicKey interface{}, pwd []byte) ([]byte, error)
} }
} }
// DER字符转成公钥 // DERToPublicKey DER字符转成公钥
func DERToPublicKey(raw []byte) (pub interface{}, err error) { func DERToPublicKey(raw []byte) (pub interface{}, err error) {
if len(raw) == 0 { if len(raw) == 0 {
return nil, errors.New("Invalid DER. It must be different from nil") return nil, errors.New("Invalid DER. It must be different from nil")
......
...@@ -95,7 +95,7 @@ func newEcdsaCA(baseDir, name string) (*EcdsaCA, error) { ...@@ -95,7 +95,7 @@ func newEcdsaCA(baseDir, name string) (*EcdsaCA, error) {
return ca, nil return ca, nil
} }
// 证书签名 // SignCertificate 证书签名
func (ca *EcdsaCA) SignCertificate(baseDir, name string, sans []string, pub interface{}) (*x509.Certificate, error) { func (ca *EcdsaCA) SignCertificate(baseDir, name string, sans []string, pub interface{}) (*x509.Certificate, error) {
template := x509Template() template := x509Template()
template.KeyUsage = x509.KeyUsageDigitalSignature template.KeyUsage = x509.KeyUsageDigitalSignature
...@@ -116,7 +116,7 @@ func (ca *EcdsaCA) SignCertificate(baseDir, name string, sans []string, pub inte ...@@ -116,7 +116,7 @@ func (ca *EcdsaCA) SignCertificate(baseDir, name string, sans []string, pub inte
return cert, nil return cert, nil
} }
// 生成本地用户 // GenerateLocalUser 生成本地用户
func (ca *EcdsaCA) GenerateLocalUser(baseDir, name string) error { func (ca *EcdsaCA) GenerateLocalUser(baseDir, name string) error {
err := createFolderStructure(baseDir, true) err := createFolderStructure(baseDir, true)
if err != nil { if err != nil {
...@@ -234,7 +234,7 @@ func newSM2CA(baseDir, name string) (*SM2CA, error) { ...@@ -234,7 +234,7 @@ func newSM2CA(baseDir, name string) (*SM2CA, error) {
return ca, nil return ca, nil
} }
// 证书签名 // SignCertificate 证书签名
func (ca *SM2CA) SignCertificate(baseDir, name string, sans []string, pub interface{}) (*x509.Certificate, error) { func (ca *SM2CA) SignCertificate(baseDir, name string, sans []string, pub interface{}) (*x509.Certificate, error) {
template := x509Template() template := x509Template()
template.KeyUsage = x509.KeyUsageDigitalSignature template.KeyUsage = x509.KeyUsageDigitalSignature
...@@ -256,7 +256,7 @@ func (ca *SM2CA) SignCertificate(baseDir, name string, sans []string, pub interf ...@@ -256,7 +256,7 @@ func (ca *SM2CA) SignCertificate(baseDir, name string, sans []string, pub interf
return utils.ParseSm2CertificateToX509(cert), nil return utils.ParseSm2CertificateToX509(cert), nil
} }
// 生成本地用户 // GenerateLocalUser 生成本地用户
func (ca *SM2CA) GenerateLocalUser(baseDir, name string) error { func (ca *SM2CA) GenerateLocalUser(baseDir, name string) error {
err := createFolderStructure(baseDir, true) err := createFolderStructure(baseDir, true)
if err != nil { if err != nil {
......
...@@ -64,7 +64,7 @@ func GetPublicKeySKIFromCert(cert []byte, signType int) (string, error) { ...@@ -64,7 +64,7 @@ func GetPublicKeySKIFromCert(cert []byte, signType int) (string, error) {
return hex.EncodeToString(ski), nil return hex.EncodeToString(ski), nil
} }
// 证书编码进签名 // EncodeCertToSignature 证书编码进签名
func EncodeCertToSignature(signByte []byte, cert []byte) ([]byte, error) { func EncodeCertToSignature(signByte []byte, cert []byte) ([]byte, error) {
certSign := crypto.CertSignature{} certSign := crypto.CertSignature{}
certSign.Signature = append(certSign.Signature, signByte...) certSign.Signature = append(certSign.Signature, signByte...)
...@@ -72,7 +72,7 @@ func EncodeCertToSignature(signByte []byte, cert []byte) ([]byte, error) { ...@@ -72,7 +72,7 @@ func EncodeCertToSignature(signByte []byte, cert []byte) ([]byte, error) {
return asn1.Marshal(certSign) return asn1.Marshal(certSign)
} }
// 从签名中解码证书 // DecodeCertFromSignature 从签名中解码证书
func DecodeCertFromSignature(signByte []byte) ([]byte, []byte, error) { func DecodeCertFromSignature(signByte []byte) ([]byte, []byte, error) {
var certSignature crypto.CertSignature var certSignature crypto.CertSignature
_, err := asn1.Unmarshal(signByte, &certSignature) _, err := asn1.Unmarshal(signByte, &certSignature)
...@@ -83,7 +83,7 @@ func DecodeCertFromSignature(signByte []byte) ([]byte, []byte, error) { ...@@ -83,7 +83,7 @@ func DecodeCertFromSignature(signByte []byte) ([]byte, []byte, error) {
return certSignature.Cert, certSignature.Signature, nil return certSignature.Cert, certSignature.Signature, nil
} }
// pem结构转成byte类型私钥 // PrivKeyByteFromRaw pem结构转成byte类型私钥
func PrivKeyByteFromRaw(raw []byte, signType int) ([]byte, error) { func PrivKeyByteFromRaw(raw []byte, signType int) ([]byte, error) {
block, _ := pem.Decode(raw) block, _ := pem.Decode(raw)
if block == nil { if block == nil {
......
...@@ -20,7 +20,7 @@ func init() { ...@@ -20,7 +20,7 @@ func init() {
ety.InitFuncList(types.ListMethod(&Cert{})) ety.InitFuncList(types.ListMethod(&Cert{}))
} }
// 初始化 // Init 初始化
func Init(name string, sub []byte) { func Init(name string, sub []byte) {
driverName = name driverName = name
var cfg ct.Authority var cfg ct.Authority
...@@ -31,12 +31,12 @@ func Init(name string, sub []byte) { ...@@ -31,12 +31,12 @@ func Init(name string, sub []byte) {
drivers.Register(driverName, newCert, types.GetDappFork(driverName, "Enable")) drivers.Register(driverName, newCert, types.GetDappFork(driverName, "Enable"))
} }
// 获取cert执行器名 // GetName 获取cert执行器名
func GetName() string { func GetName() string {
return newCert().GetName() return newCert().GetName()
} }
// cert执行器 // Cert cert执行器
type Cert struct { type Cert struct {
drivers.DriverBase drivers.DriverBase
} }
...@@ -48,12 +48,12 @@ func newCert() drivers.Driver { ...@@ -48,12 +48,12 @@ func newCert() drivers.Driver {
return c return c
} }
// 获取cert执行器名 // GetDriverName 获取cert执行器名
func (c *Cert) GetDriverName() string { func (c *Cert) GetDriverName() string {
return driverName return driverName
} }
// cert执行器tx证书校验 // CheckTx cert执行器tx证书校验
func (c *Cert) CheckTx(tx *types.Transaction, index int) error { func (c *Cert) CheckTx(tx *types.Transaction, index int) error {
// 基类检查 // 基类检查
err := c.DriverBase.CheckTx(tx, index) err := c.DriverBase.CheckTx(tx, index)
......
...@@ -16,7 +16,7 @@ func calcCertHeightKey(height int64) []byte { ...@@ -16,7 +16,7 @@ func calcCertHeightKey(height int64) []byte {
return []byte(fmt.Sprintf("LODB-cert-%d", height)) return []byte(fmt.Sprintf("LODB-cert-%d", height))
} }
// 启用证书交易执行 // ExecLocal_New 启用证书交易执行
func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if !authority.IsAuthEnable { if !authority.IsAuthEnable {
clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.") clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.")
...@@ -39,7 +39,7 @@ func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receipt ...@@ -39,7 +39,7 @@ func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receipt
return &set, nil return &set, nil
} }
// 更新证书交易执行 // ExecLocal_Update 更新证书交易执行
func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if !authority.IsAuthEnable { if !authority.IsAuthEnable {
clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.") clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.")
...@@ -63,7 +63,7 @@ func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, r ...@@ -63,7 +63,7 @@ func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, r
return &set, nil return &set, nil
} }
// 非证书变更交易执行 // ExecLocal_Normal 非证书变更交易执行
func (c *Cert) ExecLocal_Normal(payload *ct.CertNormal, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (c *Cert) ExecLocal_Normal(payload *ct.CertNormal, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if !authority.IsAuthEnable { if !authority.IsAuthEnable {
clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.") clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.")
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
package types package types
var ( var (
// cert执行器名 // CertX cert执行器名
CertX = "cert" CertX = "cert"
ExecerCert = []byte(CertX) ExecerCert = []byte(CertX)
actionName = map[string]int32{ actionName = map[string]int32{
......
...@@ -7,7 +7,7 @@ package types ...@@ -7,7 +7,7 @@ package types
import "errors" import "errors"
var ( var (
// cert校验失败 // ErrValidateCertFailed cert校验失败
ErrValidateCertFailed = errors.New("ErrValidateCertFailed") ErrValidateCertFailed = errors.New("ErrValidateCertFailed")
ErrGetHistoryCertData = errors.New("ErrGetHistoryCertData") ErrGetHistoryCertData = errors.New("ErrGetHistoryCertData")
ErrUnknowAuthSignType = errors.New("ErrUnknowAuthSignType") ErrUnknowAuthSignType = errors.New("ErrUnknowAuthSignType")
......
...@@ -23,7 +23,7 @@ func init() { ...@@ -23,7 +23,7 @@ func init() {
types.RegisterDappFork(CertX, "Enable", 0) types.RegisterDappFork(CertX, "Enable", 0)
} }
// cert执行器类型结构 // CertType cert执行器类型结构
type CertType struct { type CertType struct {
types.ExecTypeBase types.ExecTypeBase
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment