-
Notifications
You must be signed in to change notification settings - Fork 48
/
chaincore.go
45 lines (37 loc) · 1.43 KB
/
chaincore.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package agent
import (
"github.com/xuperchain/xupercore/kernel/contract/bridge/pb"
"github.com/xuperchain/xupercore/kernel/engines/xuperos/common"
"github.com/xuperchain/xupercore/kernel/ledger"
"github.com/xuperchain/xupercore/lib/logs"
)
type ChainCoreAgent struct {
log logs.Logger
chainCtx *common.ChainCtx
}
func NewChainCoreAgent(chainCtx *common.ChainCtx) *ChainCoreAgent {
return &ChainCoreAgent{
log: chainCtx.GetLog(),
chainCtx: chainCtx,
}
}
// 查询合约acl
func (t *ChainCoreAgent) GetAccountAddresses(accountName string) ([]string, error) {
return t.chainCtx.Acl.GetAccountAddresses(accountName)
}
// 结合合约acl设置鉴权
func (t *ChainCoreAgent) VerifyContractPermission(initiator string, authRequire []string, contractName, methodName string) (bool, error) {
return t.chainCtx.State.VerifyContractPermission(initiator, authRequire, contractName, methodName)
}
// 结合合约acl设置鉴权
func (t *ChainCoreAgent) VerifyContractOwnerPermission(contractName string, authRequire []string) error {
return t.chainCtx.State.VerifyContractOwnerPermission(contractName, authRequire)
}
// QueryTransaction query confirmed tx
func (t *ChainCoreAgent) QueryTransaction(txid []byte) (*pb.Transaction, error) {
return t.chainCtx.State.QueryTransaction(txid)
}
// QueryBlock query block
func (t *ChainCoreAgent) QueryBlock(blockid []byte) (ledger.BlockHandle, error) {
return t.chainCtx.State.QueryBlock(blockid)
}