github.com/turingchain2020/turingchain@v1.1.21/system/dapp/manage/executor/manage.go (about) 1 // Copyright Turing Corp. 2018 All Rights Reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package executor 管理插件执行器 6 package executor 7 8 import ( 9 log "github.com/turingchain2020/turingchain/common/log/log15" 10 drivers "github.com/turingchain2020/turingchain/system/dapp" 11 "github.com/turingchain2020/turingchain/types" 12 ) 13 14 var ( 15 clog = log.New("module", "execs.manage") 16 driverName = "manage" 17 ) 18 19 // Init resister a dirver 20 func Init(name string, cfg *types.TuringchainConfig, sub []byte) { 21 // 需要先 RegisterDappFork才可以Register dapp 22 drivers.Register(cfg, GetName(), newManage, cfg.GetDappFork(driverName, "Enable")) 23 InitExecType() 24 } 25 26 // InitExecType initials coins functions. 27 func InitExecType() { 28 ety := types.LoadExecutorType(driverName) 29 ety.InitFuncList(types.ListMethod(&Manage{})) 30 } 31 32 // GetName return manage name 33 func GetName() string { 34 return newManage().GetName() 35 } 36 37 // Manage defines Manage object 38 type Manage struct { 39 drivers.DriverBase 40 } 41 42 func newManage() drivers.Driver { 43 c := &Manage{} 44 c.SetChild(c) 45 c.SetExecutorType(types.LoadExecutorType(driverName)) 46 return c 47 } 48 49 // GetDriverName return a drivername 50 func (c *Manage) GetDriverName() string { 51 return driverName 52 } 53 54 // CheckTx checkout transaction 55 func (c *Manage) CheckTx(tx *types.Transaction, index int) error { 56 return nil 57 } 58 59 // IsSuperManager is supper manager or not 60 func IsSuperManager(cfg *types.TuringchainConfig, addr string) bool { 61 conf := types.ConfSub(cfg, driverName) 62 for _, m := range conf.GStrList("superManager") { 63 if addr == m { 64 return true 65 } 66 } 67 return false 68 } 69 70 // CheckReceiptExecOk return true to check if receipt ty is ok 71 func (c *Manage) CheckReceiptExecOk() bool { 72 return true 73 }