cmd/cli/acl_query.go

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/*
 * Copyright (c) 2019. Baidu Inc. All Rights Reserved.
 */

package main

import (
	"context"
	"encoding/json"
	"errors"
	"fmt"

	"github.com/spf13/cobra"

	"github.com/xuperchain/xuperunion/global"
	"github.com/xuperchain/xuperunion/pb"
)

// ACLQueryCommand query acl struct
type ACLQueryCommand struct {
	cli          *Cli
	cmd          *cobra.Command
	accountName  string
	contractName string
	methodName   string
}

// NewACLQueryCommand new acl query cmd
func NewACLQueryCommand(cli *Cli) *cobra.Command {
	t := new(ACLQueryCommand)
	t.cli = cli
	t.cmd = &cobra.Command{
		Use:   "query [OPTIONS] account contract method",
		Short: "query an access control list(ACL) for an account or contract method.",
		RunE: func(cmd *cobra.Command, args []string) error {
			ctx := context.TODO()
			return t.queryACL(ctx)
		},
	}
	t.addFlags()

	return t.cmd
}

func (t *ACLQueryCommand) addFlags() {
	t.cmd.Flags().StringVar(&t.accountName, "account", "", "contract account name")
	t.cmd.Flags().StringVar(&t.contractName, "contract", "", "contract name")
	t.cmd.Flags().StringVar(&t.methodName, "method", "", "method name")
}

func (t *ACLQueryCommand) queryACL(ctx context.Context) error {
	client := t.cli.XchainClient()
	aclStatus := &pb.AclStatus{
		Header: &pb.Header{
			Logid: global.Glogid(),
		},
		Bcname:       t.cli.RootOptions.Name,
		AccountName:  t.accountName,
		ContractName: t.contractName,
		MethodName:   t.methodName,
后面还有 31 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。