dapp

package
v0.0.0-...-3c905e5 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: BSD-3-Clause Imports: 13 Imported by: 42

Documentation

Overview

Package dapp 系统基础dapp包

Index

Constants

View Source
const (
	// TxIndexFrom transaction index from
	TxIndexFrom = 1
	// TxIndexTo transaction index to
	TxIndexTo = 2

	//ExecLocalSameTime Exec 的时候 同时执行 ExecLocal
	ExecLocalSameTime = int64(1)
)

Variables

This section is empty.

Functions

func CheckAddress

func CheckAddress(cfg *types.ChainConfig, addr string, height int64) error

CheckAddress check address

func ExecAddress

func ExecAddress(name string) string

ExecAddress return exec address

func HeightIndexStr

func HeightIndexStr(height, index int64) string

HeightIndexStr height and index format string

func IsDriverAddress

func IsDriverAddress(addr string, height int64) bool

IsDriverAddress whether or not execdrivers by address

func KVExpiredCheckerList

func KVExpiredCheckerList() []string

KVExpiredCheckerList gets names of dapp which has registered kv checker

func Register

func Register(cfg *types.ChainConfig, name string, create DriverCreate, height int64)

Register register dcriver height in name

func RegisterKVExpiredChecker

func RegisterKVExpiredChecker(name string, f KVChecker)

RegisterKVExpiredChecker registers dapp kv checker

Types

type Driver

type Driver interface {
	SetStateDB(dbm.KV)
	SetCoinsAccount(*account.DB)
	GetCoinsAccount() *account.DB
	SetLocalDB(dbm.KVDB)
	//当前交易执行器名称
	GetCurrentExecName() string
	//驱动的名字,这个名称是固定的
	GetDriverName() string
	//执行器的别名(一个驱动(code),允许创建多个执行器,类似evm一份代码可以创建多个合约)
	GetName() string
	GetExecutorAPI() api.ExecutorAPI
	//设置执行器的真实名称
	SetName(string)
	SetCurrentExecName(string)
	Allow(tx *types.Transaction, index int) error
	IsFriend(selfexec []byte, writekey []byte, othertx *types.Transaction) bool
	GetActionName(tx *types.Transaction) string
	SetEnv(height, blocktime int64, difficulty uint64)
	SetBlockInfo([]byte, []byte, int64)
	CheckTx(tx *types.Transaction, index int) error
	Exec(tx *types.Transaction, index int) (*types.Receipt, error)
	ExecLocal(tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error)
	ExecDelLocal(tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error)
	Query(funcName string, params []byte) (types.Message, error)
	IsFree() bool
	SetAPI(client.QueueProtocolAPI)
	SetExecutorAPI(queueapi client.QueueProtocolAPI, chainapi types.ChainClient)
	SetTxs(txs []*types.Transaction)
	SetReceipt(receipts []*types.ReceiptData)

	//GetTxs and TxGroup
	GetTxs() []*types.Transaction
	GetTxGroup(index int) ([]*types.Transaction, error)
	GetPayloadValue() types.Message
	GetFuncMap() map[string]reflect.Method
	GetExecutorType() types.ExecutorType
	CheckReceiptExecOk() bool
	ExecutorOrder() int64
	Upgrade() (*types.LocalDBSet, error)
}

Driver defines some interface

func LoadDriver

func LoadDriver(name string, height int64) (driver Driver, err error)

LoadDriver load driver

func LoadDriverAllow

func LoadDriverAllow(qclent client.QueueProtocolAPI, tx *types.Transaction, index int, height int64) (driver Driver)

LoadDriverAllow load driver allow

func LoadDriverWithClient

func LoadDriverWithClient(qclent client.QueueProtocolAPI, name string, height int64) (driver Driver, err error)

LoadDriverWithClient load

type DriverBase

type DriverBase struct {
	// contains filtered or unexported fields
}

DriverBase defines driverbase type

func (*DriverBase) AddRollbackKV

func (d *DriverBase) AddRollbackKV(tx *types.Transaction, execer []byte, kvs []*types.KeyValue) []*types.KeyValue

AddRollbackKV add rollback kv

func (*DriverBase) Allow

func (d *DriverBase) Allow(tx *types.Transaction, index int) error

Allow default behavior: same name or parallel chain

func (*DriverBase) AllowIsSame

func (d *DriverBase) AllowIsSame(execer []byte) bool

AllowIsSame allow issame drivername

func (*DriverBase) AllowIsUserDot1

func (d *DriverBase) AllowIsUserDot1(execer []byte) bool

AllowIsUserDot1 user.evm

func (*DriverBase) AllowIsUserDot2

func (d *DriverBase) AllowIsUserDot2(execer []byte) bool

AllowIsUserDot2 user.evm.xxx

func (*DriverBase) CheckReceiptExecOk

func (d *DriverBase) CheckReceiptExecOk() bool

CheckReceiptExecOk default return true to check if receipt ty is ok, for specific plugin can overwrite it self

func (*DriverBase) CheckSignatureData

func (d *DriverBase) CheckSignatureData(tx *types.Transaction, index int) bool

CheckSignatureData check signature data

func (*DriverBase) CheckTx

func (d *DriverBase) CheckTx(tx *types.Transaction, index int) error

CheckTx default:,tx.To address points to the contract address

func (*DriverBase) DelRollbackKV

func (d *DriverBase) DelRollbackKV(tx *types.Transaction, execer []byte) ([]*types.KeyValue, error)

DelRollbackKV del rollback kv when exec_del_local

func (*DriverBase) Exec

func (d *DriverBase) Exec(tx *types.Transaction, index int) (receipt *types.Receipt, err error)

Exec call the check exectx subclass, you can also do it without calling , implement your own checktx

func (*DriverBase) ExecDelLocal

func (d *DriverBase) ExecDelLocal(tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error)

ExecDelLocal local execdel

func (*DriverBase) ExecLocal

func (d *DriverBase) ExecLocal(tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error)

ExecLocal local exec

func (*DriverBase) ExecutorOrder

func (d *DriverBase) ExecutorOrder() int64

ExecutorOrder 执行顺序, 如果要使用 ExecLocalSameTime 那么会同时执行 ExecLocal

func (*DriverBase) GetAPI

func (d *DriverBase) GetAPI() client.QueueProtocolAPI

GetAPI return queue protocol api

func (*DriverBase) GetActionName

func (d *DriverBase) GetActionName(tx *types.Transaction) string

GetActionName get action name

func (*DriverBase) GetAddrTxsCount

func (d *DriverBase) GetAddrTxsCount(reqkey *types.ReqKey) (types.Message, error)

GetAddrTxsCount query the transaction count for the specified address ,for statistical

func (*DriverBase) GetBlockTime

func (d *DriverBase) GetBlockTime() int64

GetBlockTime return block time

func (*DriverBase) GetCoinsAccount

func (d *DriverBase) GetCoinsAccount() *account.DB

GetCoinsAccount get coins account

func (*DriverBase) GetCurrentExecName

func (d *DriverBase) GetCurrentExecName() string

GetCurrentExecName defines get current execname

func (*DriverBase) GetDifficulty

func (d *DriverBase) GetDifficulty() uint64

GetDifficulty return difficulty

func (*DriverBase) GetExecutorAPI

func (d *DriverBase) GetExecutorAPI() api.ExecutorAPI

GetExecutorAPI return executor api

func (*DriverBase) GetExecutorType

func (d *DriverBase) GetExecutorType() types.ExecutorType

GetExecutorType defines get executortype func

func (*DriverBase) GetFuncMap

func (d *DriverBase) GetFuncMap() map[string]reflect.Method

GetFuncMap defines get execfuncmap func

func (*DriverBase) GetHeight

func (d *DriverBase) GetHeight() int64

GetHeight return height

func (*DriverBase) GetLastHash

func (d *DriverBase) GetLastHash() []byte

GetLastHash 获取最后区块的hash,主链和平行链不同

func (*DriverBase) GetLocalDB

func (d *DriverBase) GetLocalDB() dbm.KVDB

GetLocalDB return localdb

func (*DriverBase) GetMainHeight

func (d *DriverBase) GetMainHeight() int64

GetMainHeight return height

func (*DriverBase) GetName

func (d *DriverBase) GetName() string

GetName defines return name func

func (*DriverBase) GetParentHash

func (d *DriverBase) GetParentHash() []byte

GetParentHash 获取上一个区块的hash

func (*DriverBase) GetPayloadValue

func (d *DriverBase) GetPayloadValue() types.Message

GetPayloadValue define get payload func

func (*DriverBase) GetPrefixCount

func (d *DriverBase) GetPrefixCount(key *types.ReqKey) (types.Message, error)

GetPrefixCount query the number keys of the specified prefix, for statistical

func (*DriverBase) GetReceipt

func (d *DriverBase) GetReceipt() []*types.ReceiptData

GetReceipt return receipts

func (*DriverBase) GetStateDB

func (d *DriverBase) GetStateDB() dbm.KV

GetStateDB set statedb

func (*DriverBase) GetTxGroup

func (d *DriverBase) GetTxGroup(index int) ([]*types.Transaction, error)

GetTxGroup get txgroup

func (*DriverBase) GetTxs

func (d *DriverBase) GetTxs() []*types.Transaction

GetTxs get transactions

func (*DriverBase) GetTxsByAddr

func (d *DriverBase) GetTxsByAddr(addr *types.ReqAddr) (types.Message, error)

GetTxsByAddr find all transactions in this address by the addr prefix query transaction are placed by default :coins in the query

func (*DriverBase) GetTxsFeeByAddr

func (d *DriverBase) GetTxsFeeByAddr(addr *types.ReqAddr) (types.Message, error)

GetTxsFeeByAddr find all transactions in this address by the addr prefix

func (*DriverBase) IsFree

func (d *DriverBase) IsFree() bool

IsFree return isfree

func (*DriverBase) IsFriend

func (d *DriverBase) IsFriend(myexec, writekey []byte, othertx *types.Transaction) bool

IsFriend defines a isfriend function

func (*DriverBase) Query

func (d *DriverBase) Query(funcname string, params []byte) (msg types.Message, err error)

Query defines query function

func (*DriverBase) SetAPI

func (d *DriverBase) SetAPI(queueapi client.QueueProtocolAPI)

SetAPI set queue protocol api

func (*DriverBase) SetBlockInfo

func (d *DriverBase) SetBlockInfo(parentHash, mainHash []byte, mainHeight int64)

SetBlockInfo 设置区块的信息

func (*DriverBase) SetChild

func (d *DriverBase) SetChild(e Driver)

SetChild set childvalue

func (*DriverBase) SetCoinsAccount

func (d *DriverBase) SetCoinsAccount(acc *account.DB)

SetCoinsAccount sets coins account.

func (*DriverBase) SetCurrentExecName

func (d *DriverBase) SetCurrentExecName(name string)

SetCurrentExecName set current execname

func (*DriverBase) SetEnv

func (d *DriverBase) SetEnv(height, blocktime int64, difficulty uint64)

SetEnv set env

func (*DriverBase) SetExecutorAPI

func (d *DriverBase) SetExecutorAPI(queueapi client.QueueProtocolAPI, chainapi types.ChainClient)

SetExecutorAPI set queue protocol api

func (*DriverBase) SetExecutorType

func (d *DriverBase) SetExecutorType(e types.ExecutorType)

SetExecutorType set exectortype

func (*DriverBase) SetIsFree

func (d *DriverBase) SetIsFree(isFree bool)

SetIsFree set isfree

func (*DriverBase) SetLocalDB

func (d *DriverBase) SetLocalDB(db dbm.KVDB)

SetLocalDB set localdb

func (*DriverBase) SetName

func (d *DriverBase) SetName(name string)

SetName set name

func (*DriverBase) SetReceipt

func (d *DriverBase) SetReceipt(receipts []*types.ReceiptData)

SetReceipt set receipt

func (*DriverBase) SetStateDB

func (d *DriverBase) SetStateDB(db dbm.KV)

SetStateDB set db state

func (*DriverBase) SetTxs

func (d *DriverBase) SetTxs(txs []*types.Transaction)

SetTxs set transactions

func (*DriverBase) Upgrade

func (d *DriverBase) Upgrade() (*types.LocalDBSet, error)

Upgrade default upgrade only print a message

type DriverCreate

type DriverCreate func() Driver

DriverCreate defines a drivercreate function

type KVChecker

type KVChecker func(key, value []byte) bool

KVChecker checks kv stored in db

func LoadKVExpiredChecker

func LoadKVExpiredChecker(name string) (KVChecker, bool)

LoadKVExpiredChecker loads dapp kv checker by dapp name

type KVCreator

type KVCreator struct {
	// contains filtered or unexported fields
}

KVCreator 创建KV的辅助工具

func NewKVCreator

func NewKVCreator(kv db.KV, prefix []byte, rollbackkey []byte) *KVCreator

NewKVCreator 创建创建者 注意: 自动回滚可能会严重影响系统性能

func (*KVCreator) Add

func (c *KVCreator) Add(key, value []byte) *KVCreator

Add add and set to kvdb

func (*KVCreator) AddKVListOnly

func (c *KVCreator) AddKVListOnly(list []*types.KeyValue) *KVCreator

AddKVListOnly only add KVList (can't auto rollback)

func (*KVCreator) AddKVOnly

func (c *KVCreator) AddKVOnly(key, value []byte) *KVCreator

AddKVOnly only add KV(can't auto rollback)

func (*KVCreator) AddList

func (c *KVCreator) AddList(list []*types.KeyValue) *KVCreator

AddList only add KVList

func (*KVCreator) AddListNoPrefix

func (c *KVCreator) AddListNoPrefix(list []*types.KeyValue) *KVCreator

AddListNoPrefix only add KVList

func (*KVCreator) AddNoPrefix

func (c *KVCreator) AddNoPrefix(key, value []byte) *KVCreator

AddNoPrefix 不自动添加prefix

func (*KVCreator) AddRollbackKV

func (c *KVCreator) AddRollbackKV()

AddRollbackKV 添加回滚数据到 KV

func (*KVCreator) AddToLogs

func (c *KVCreator) AddToLogs(logs []*types.ReceiptLog) []*types.ReceiptLog

AddToLogs add not empty log to logs

func (*KVCreator) DelRollbackKV

func (c *KVCreator) DelRollbackKV()

DelRollbackKV 删除rollback kv

func (*KVCreator) Get

func (c *KVCreator) Get(key []byte) ([]byte, error)

Get 从KV中获取 value

func (*KVCreator) GetNoPrefix

func (c *KVCreator) GetNoPrefix(key []byte) ([]byte, error)

GetNoPrefix 从KV中获取 value, 不自动添加前缀

func (*KVCreator) GetRollbackKVList

func (c *KVCreator) GetRollbackKVList() ([]*types.KeyValue, error)

GetRollbackKVList 获取 rollback 到 Key and Vaue

func (*KVCreator) KVList

func (c *KVCreator) KVList() []*types.KeyValue

KVList 读取所有的kv列表

Directories

Path Synopsis
Package coins 系统级coins dapp插件
Package coins 系统级coins dapp插件
autotest
Package autotest 系统级coins dapp自动测试包
Package autotest 系统级coins dapp自动测试包
executor
Package executor coins执行器
Package executor coins执行器
Package commands 系统级dapp相关命令包
Package commands 系统级dapp相关命令包
types
Package types commands中结构体定义
Package types commands中结构体定义
Package init 初始化系统dapp包
Package init 初始化系统dapp包
Package manage manage负责管理配置的插件 1.
Package manage manage负责管理配置的插件 1.
commands
Package commands 管理插件命令
Package commands 管理插件命令
executor
Package executor 管理插件执行器
Package executor 管理插件执行器
types
Package types 管理插件相关的定义
Package types 管理插件相关的定义
Package none 系统级dapp,执行内容为空
Package none 系统级dapp,执行内容为空
executor
Package executor none执行器
Package executor none执行器
types
Package types 管理插件相关的定义
Package types 管理插件相关的定义

Jump to

Keyboard shortcuts

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