eoswatcher

package
v0.0.0-...-fc865ac Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateToken

type CreateToken struct {
	User   eos.AccountName `json:"user"`
	Amount uint32          `json:"amount"`
}

type DestroyToken

type DestroyToken struct {
	User   eos.AccountName `json:"user"`
	Amount uint32          `json:"amount"`
	Memo   string          `json:"amount"`
}

type EOSPushEvent

type EOSPushEvent struct {
	TxID eos.SHA256Bytes

	Account   eos.AccountName
	Name      eos.ActionName
	Memo      string
	Amount    uint64
	Symbol    string
	Precision uint8

	BlockNum uint32
	Index    int
}

func (*EOSPushEvent) GetAmount

func (event *EOSPushEvent) GetAmount() uint64

func (*EOSPushEvent) GetBusiness

func (event *EOSPushEvent) GetBusiness() string

func (*EOSPushEvent) GetData

func (event *EOSPushEvent) GetData() ([]byte, error)

func (*EOSPushEvent) GetEventType

func (event *EOSPushEvent) GetEventType() uint32

func (*EOSPushEvent) GetFee

func (event *EOSPushEvent) GetFee() uint64

func (*EOSPushEvent) GetFrom

func (event *EOSPushEvent) GetFrom() byte

func (*EOSPushEvent) GetHeight

func (event *EOSPushEvent) GetHeight() int64

func (*EOSPushEvent) GetPrecision

func (event *EOSPushEvent) GetPrecision() uint8

func (*EOSPushEvent) GetProposal

func (event *EOSPushEvent) GetProposal() string

func (*EOSPushEvent) GetSymbol

func (event *EOSPushEvent) GetSymbol() string

func (*EOSPushEvent) GetTo

func (event *EOSPushEvent) GetTo() byte

func (*EOSPushEvent) GetTranxIx

func (event *EOSPushEvent) GetTranxIx() int

func (*EOSPushEvent) GetTxID

func (event *EOSPushEvent) GetTxID() string

type EOSWatcher

type EOSWatcher struct {
	EosAPI          *eos.API
	ScanBlockHeight uint32

	HeadBlockNum             uint32
	LastIrreversibleBlockNum uint32
	EOSPushEvents            []*EOSPushEvent

	// 签名所用私钥 对应的公钥哈希值
	PubKeyHash string

	// 扫块时,具体提取哪些操作
	ActionAccount     eos.AccountName
	ActionNameDestroy eos.ActionName
	ActionNameCreate  eos.ActionName

	DB *leveldb.DB
}

func NewEosWatcher

func NewEosWatcher(url, pubKeyHash, actionAccount, actionNameDestroy, actionNameCreate, dirName string) *EOSWatcher

func (*EOSWatcher) CreateActionsTx

func (ew *EOSWatcher) CreateActionsTx(action []*eos.Action, duration time.Duration) (*eos.SignedTransaction, error)

根据多个actions等,创建交易

func (*EOSWatcher) CreateSetCodeAction

func (ew *EOSWatcher) CreateSetCodeAction(accountName, wasmFile, abiFile string) ([]*eos.Action, error)

创建部署合约action

func (*EOSWatcher) CreateTransferAction

func (ew *EOSWatcher) CreateTransferAction(account, action, from, to string, amount int64, memo string) (*eos.Action, error)

创建转账action

func (*EOSWatcher) CreateTx

func (ew *EOSWatcher) CreateTx(action *eos.Action, duration time.Duration) (*eos.SignedTransaction, error)

根据action等,创建交易

func (*EOSWatcher) GetEventByTxid

func (ew *EOSWatcher) GetEventByTxid(txid string) (*EOSPushEvent, error)

func (*EOSWatcher) GetPublickeyFromTx

func (ew *EOSWatcher) GetPublickeyFromTx(tx *eos.SignedTransaction, sig *ecc.Signature) (out ecc.PublicKey, err error)

根据multisig下的GetPublickeyFromTx代码,移植过来

func (*EOSWatcher) MergeSignedTx

func (ew *EOSWatcher) MergeSignedTx(tx *eos.SignedTransaction, sigs ...*ecc.Signature) (packedTx *eos.PackedTransaction, err error)

根据multisig下的MergeSignedTx代码,移植过来

func (*EOSWatcher) NewPublicKey

func (ew *EOSWatcher) NewPublicKey(uncompresspubkey string) (*ecc.PublicKey, error)

func (*EOSWatcher) PKMSign

func (ew *EOSWatcher) PKMSign(tx *eos.SignedTransaction) (sig *ecc.Signature, err error)

根据multisig下的PKMSign代码,移植过来

func (*EOSWatcher) SendTx

func (ew *EOSWatcher) SendTx(tx *eos.PackedTransaction) (out *eos.PushTransactionFullResp, err error)

根据multisig下的SendTx代码,移植过来

func (*EOSWatcher) StartWatch

func (ew *EOSWatcher) StartWatch(scanBlockHeight, scanBlockIndex uint32, eventChan chan<- *EOSPushEvent, channelCount int)

扫块开始

func (*EOSWatcher) UpdateActionAccount

func (ew *EOSWatcher) UpdateActionAccount(actionAccount string)

func (*EOSWatcher) UpdateActionNameCreate

func (ew *EOSWatcher) UpdateActionNameCreate(actionName string)

func (*EOSWatcher) UpdateActionNameDestroy

func (ew *EOSWatcher) UpdateActionNameDestroy(actionName string)

func (*EOSWatcher) UpdateBlock

func (ew *EOSWatcher) UpdateBlock(scanBlockHeight uint32) *eos.BlockResp

更新 要扫描块的信息。 如果rpc请求报错,那么继续请求,阻塞在这里

func (*EOSWatcher) UpdateEOSPushEvent

func (ew *EOSWatcher) UpdateEOSPushEvent(scanBlockResp *eos.BlockResp, scanBlockIndex uint32, eventChan chan<- *EOSPushEvent)

更新 根据获得到的 块收据 信息,生成EOSPush事件,发给网关

func (*EOSWatcher) UpdateInfo

func (ew *EOSWatcher) UpdateInfo()

更新 最后一个不可逆转块块高、最高块块高。 如果rpc请求报错,那么继续请求,阻塞在这里

func (*EOSWatcher) UpdatePubKeyHash

func (ew *EOSWatcher) UpdatePubKeyHash(pubKeyHash string)

func (*EOSWatcher) XinPlayerCreateTokenAction

func (ew *EOSWatcher) XinPlayerCreateTokenAction(account, permissionAccount, user string, amount uint32) (*eos.Action, error)

创建转账action createtoken

func (*EOSWatcher) XinPlayerDestroyTokenAction

func (ew *EOSWatcher) XinPlayerDestroyTokenAction(account, permissionAccount, user, memo string, amount uint32) (*eos.Action, error)

创建转账action destroytoken

func (*EOSWatcher) XinPlayerIssueAction

func (ew *EOSWatcher) XinPlayerIssueAction(account, permissionAccount string, amount uint64) (*eos.Action, error)

创建转账action issue

func (*EOSWatcher) XinPlayerNewaccountAction

func (ew *EOSWatcher) XinPlayerNewaccountAction(account, permissionAccount, user string) (*eos.Action, error)

创建转账action newaccount

type EOSWatcherContract

type EOSWatcherContract struct {
	// 链API url
	EosAPI *eos.API
	// 代币所在合约
	ActionAccount eos.AccountName
	// 网关名
	Gateway eos.AccountName

	ScanBlockHeight uint32

	HeadBlockNum             uint32
	LastIrreversibleBlockNum uint32
	EOSPushEvents            []*EOSPushEvent

	// 签名所用私钥 对应的公钥哈希值
	PubKeyHash string

	// 具体扫哪些操作
	ActionNameDestroy eos.ActionName
	ActionNameCreate  eos.ActionName

	// 货币名称、精度
	Symbol    string
	Precision uint8

	DB *leveldb.DB
}

func NewEosWatcherContract

func NewEosWatcherContract(url, pubKeyHash, actionAccount, gateway, actionNameDestroy, actionNameCreate, symbol string, precision uint8, dirName string) *EOSWatcherContract

func (*EOSWatcherContract) CreateActionsTx

func (ew *EOSWatcherContract) CreateActionsTx(action []*eos.Action, duration time.Duration) (*eos.SignedTransaction, error)

根据多个actions等,创建交易

func (*EOSWatcherContract) CreateCreateAction

func (ew *EOSWatcherContract) CreateCreateAction(issuer string, amount int64) (*eos.Action, error)

创建新建action

func (*EOSWatcherContract) CreateIssueAction

func (ew *EOSWatcherContract) CreateIssueAction(to string, amount int64, memo string) (*eos.Action, error)

创建发行action

func (*EOSWatcherContract) CreateSetCodeAction

func (ew *EOSWatcherContract) CreateSetCodeAction(wasmFile, abiFile string) ([]*eos.Action, error)

创建部署合约action,部署在网关账户上面

func (*EOSWatcherContract) CreateSolventAction

func (ew *EOSWatcherContract) CreateSolventAction(from string, amount int64, memo string) (*eos.Action, error)

创建溶币action

func (*EOSWatcherContract) CreateTransferAction

func (ew *EOSWatcherContract) CreateTransferAction(from, to string, amount int64, memo string) (*eos.Action, error)

创建转账action

func (*EOSWatcherContract) CreateTx

func (ew *EOSWatcherContract) CreateTx(action *eos.Action, duration time.Duration) (*eos.SignedTransaction, error)

根据action等,创建交易

func (*EOSWatcherContract) GetEventByTxid

func (ew *EOSWatcherContract) GetEventByTxid(txid string) (*EOSPushEvent, error)

func (*EOSWatcherContract) GetPublickeyFromTx

func (ew *EOSWatcherContract) GetPublickeyFromTx(tx *eos.SignedTransaction, sig *ecc.Signature) (out ecc.PublicKey, err error)

根据multisig下的GetPublickeyFromTx代码,移植过来

func (*EOSWatcherContract) MergeSignedTx

func (ew *EOSWatcherContract) MergeSignedTx(tx *eos.SignedTransaction, sigs ...*ecc.Signature) (packedTx *eos.PackedTransaction, err error)

根据multisig下的MergeSignedTx代码,移植过来

func (*EOSWatcherContract) NewPublicKey

func (ew *EOSWatcherContract) NewPublicKey(uncompresspubkey string) (*ecc.PublicKey, error)

func (*EOSWatcherContract) PKMSign

func (ew *EOSWatcherContract) PKMSign(tx *eos.SignedTransaction) (sig *ecc.Signature, err error)

根据multisig下的PKMSign代码,移植过来

func (*EOSWatcherContract) SendTx

func (ew *EOSWatcherContract) SendTx(tx *eos.PackedTransaction) (out *eos.PushTransactionFullResp, err error)

根据multisig下的SendTx代码,移植过来

func (*EOSWatcherContract) StartWatch

func (ew *EOSWatcherContract) StartWatch(scanBlockHeight, scanBlockIndex uint32, eventChan chan<- *EOSPushEvent, channelCount int)

扫块开始

func (*EOSWatcherContract) UpdateActionAccount

func (ew *EOSWatcherContract) UpdateActionAccount(actionAccount string)

func (*EOSWatcherContract) UpdateActionNameCreate

func (ew *EOSWatcherContract) UpdateActionNameCreate(actionNameCreate string)

func (*EOSWatcherContract) UpdateActionNameDestroy

func (ew *EOSWatcherContract) UpdateActionNameDestroy(actionNameDestroy string)

func (*EOSWatcherContract) UpdateBlock

func (ew *EOSWatcherContract) UpdateBlock(scanBlockHeight uint32) *eos.BlockResp

更新 要扫描块的信息。 如果rpc请求报错,那么继续请求,阻塞在这里

func (*EOSWatcherContract) UpdateEOSPushEvent

func (ew *EOSWatcherContract) UpdateEOSPushEvent(scanBlockResp *eos.BlockResp, scanBlockIndex uint32, eventChan chan<- *EOSPushEvent)

更新 根据获得到的 块收据 信息,生成EOSPush事件,发给网关

func (*EOSWatcherContract) UpdateGateway

func (ew *EOSWatcherContract) UpdateGateway(gateway string)

func (*EOSWatcherContract) UpdateInfo

func (ew *EOSWatcherContract) UpdateInfo()

更新 最后一个不可逆转块块高、最高块块高。 如果rpc请求报错,那么继续请求,阻塞在这里

func (*EOSWatcherContract) UpdatePubKeyHash

func (ew *EOSWatcherContract) UpdatePubKeyHash(pubKeyHash string)

type EOSWatcherInterface

type EOSWatcherInterface interface {
	UpdatePubKeyHash(pubKeyHash string)

	StartWatch(scanBlockHeight, scanBlockIndex uint32, eventChan chan<- *EOSPushEvent, channelCount int)

	UpdateInfo()
	UpdateBlock(scanBlockHeight uint32) *eos.BlockResp
	UpdateEOSPushEvent(scanBlockResp *eos.BlockResp, scanBlockIndex uint32, eventChan chan<- *EOSPushEvent)

	GetEventByTxid(txid string) (*EOSPushEvent, error)

	PKMSign(tx *eos.SignedTransaction) (sig *ecc.Signature, err error)
	GetPublickeyFromTx(tx *eos.SignedTransaction, sig *ecc.Signature) (out ecc.PublicKey, err error)
	MergeSignedTx(tx *eos.SignedTransaction, sigs ...*ecc.Signature) (packedTx *eos.PackedTransaction, err error)
	SendTx(tx *eos.PackedTransaction) (out *eos.PushTransactionFullResp, err error)

	CreateTx(action *eos.Action, duration time.Duration) (*eos.SignedTransaction, error)
	CreateActionsTx(action []*eos.Action, duration time.Duration) (*eos.SignedTransaction, error)

	NewPublicKey(uncompresspubkey string) (*ecc.PublicKey, error)
}

type EOSWatcherMain

type EOSWatcherMain struct {
	// 链API url
	EosAPI *eos.API
	// 网关名
	Gateway eos.AccountName

	ScanBlockHeight uint32

	HeadBlockNum             uint32
	LastIrreversibleBlockNum uint32

	// 签名所用私钥 对应的公钥哈希值
	PubKeyHash string

	// 合约、方法列表
	TokenContracts []*TokenContract

	DB *leveldb.DB
}

func NewEosWatcherMain

func NewEosWatcherMain(url, pubKeyHash, gateway, dirName string, tokenContracts []*TokenContract) *EOSWatcherMain

func (*EOSWatcherMain) ActionDataIssueParse

func (ew *EOSWatcherMain) ActionDataIssueParse(data interface{}, precision uint8, symbol string) (*token.Issue, error)

func (*EOSWatcherMain) ActionDataParse

func (ew *EOSWatcherMain) ActionDataParse(actionName eos.ActionName, data interface{}, precision uint8, symbol string) (*EOSPushEvent, error)

func (*EOSWatcherMain) ActionDataSolventParse

func (ew *EOSWatcherMain) ActionDataSolventParse(data interface{}, precision uint8, symbol string) (*Solvent, error)

func (*EOSWatcherMain) ActionDataTransferParse

func (ew *EOSWatcherMain) ActionDataTransferParse(data interface{}, precision uint8, symbol string) (*token.Transfer, error)

func (*EOSWatcherMain) CreateActionsTx

func (ew *EOSWatcherMain) CreateActionsTx(action []*eos.Action, duration time.Duration) (*eos.SignedTransaction, error)

根据多个actions等,创建交易

func (*EOSWatcherMain) CreateCreateAction

func (ew *EOSWatcherMain) CreateCreateAction(actionAccount, issuer string, amount int64, precision uint8, symbol string) (*eos.Action, error)

创建新建action

func (*EOSWatcherMain) CreateIssueAction

func (ew *EOSWatcherMain) CreateIssueAction(actionAccount, to string, amount int64, symbol string, memo string) (*eos.Action, error)

func (*EOSWatcherMain) CreateIssueActionDispatcher

func (ew *EOSWatcherMain) CreateIssueActionDispatcher(actionAccount, to string, amount int64, precision uint8, symbol string, memo string) (*eos.Action, error)

创建发行action

func (*EOSWatcherMain) CreateSetCodeAction

func (ew *EOSWatcherMain) CreateSetCodeAction(wasmFile, abiFile string) ([]*eos.Action, error)

创建部署合约action,部署在网关账户上面

func (*EOSWatcherMain) CreateSolventAction

func (ew *EOSWatcherMain) CreateSolventAction(actionAccount, from string, amount int64, precision uint8, symbol string, memo string) (*eos.Action, error)

创建溶币action

func (*EOSWatcherMain) CreateTransferAction

func (ew *EOSWatcherMain) CreateTransferAction(from, to string, amount int64, memo string) (*eos.Action, error)

func (*EOSWatcherMain) CreateTransferActionDispatcher

func (ew *EOSWatcherMain) CreateTransferActionDispatcher(actionAccount, from, to string, amount int64, precision uint8, symbol string, memo string) (*eos.Action, error)

创建转账action

func (*EOSWatcherMain) CreateTx

func (ew *EOSWatcherMain) CreateTx(action *eos.Action, duration time.Duration) (*eos.SignedTransaction, error)

根据action等,创建交易

func (*EOSWatcherMain) GetEventByTxid

func (ew *EOSWatcherMain) GetEventByTxid(txid string) (*EOSPushEvent, error)

func (*EOSWatcherMain) GetPublickeyFromTx

func (ew *EOSWatcherMain) GetPublickeyFromTx(tx *eos.SignedTransaction, sig *ecc.Signature) (out ecc.PublicKey, err error)

根据multisig下的GetPublickeyFromTx代码,移植过来

func (*EOSWatcherMain) MergeSignedTx

func (ew *EOSWatcherMain) MergeSignedTx(tx *eos.SignedTransaction, sigs ...*ecc.Signature) (packedTx *eos.PackedTransaction, err error)

根据multisig下的MergeSignedTx代码,移植过来

func (*EOSWatcherMain) NewPublicKey

func (ew *EOSWatcherMain) NewPublicKey(uncompresspubkey string) (*ecc.PublicKey, error)

func (*EOSWatcherMain) PKMSign

func (ew *EOSWatcherMain) PKMSign(tx *eos.SignedTransaction) (sig *ecc.Signature, err error)

根据multisig下的PKMSign代码,移植过来

func (*EOSWatcherMain) SendTx

func (ew *EOSWatcherMain) SendTx(tx *eos.PackedTransaction) (out *eos.PushTransactionFullResp, err error)

根据multisig下的SendTx代码,移植过来

func (*EOSWatcherMain) ShowRegist

func (ew *EOSWatcherMain) ShowRegist()

func (*EOSWatcherMain) StartWatch

func (ew *EOSWatcherMain) StartWatch(scanBlockHeight, scanBlockIndex uint32, eventChan chan<- *EOSPushEvent, channelCount int)

扫块开始

func (*EOSWatcherMain) UpdateBlock

func (ew *EOSWatcherMain) UpdateBlock(scanBlockHeight uint32) *eos.BlockResp

更新 要扫描块的信息。 如果rpc请求报错,那么继续请求,阻塞在这里

func (*EOSWatcherMain) UpdateEOSPushEvent

func (ew *EOSWatcherMain) UpdateEOSPushEvent(scanBlockResp *eos.BlockResp, scanBlockIndex uint32, eventChan chan<- *EOSPushEvent)

更新 根据获得到的 块收据 信息,生成EOSPush事件,发给网关

func (*EOSWatcherMain) UpdateGateway

func (ew *EOSWatcherMain) UpdateGateway(gateway string)

func (*EOSWatcherMain) UpdateInfo

func (ew *EOSWatcherMain) UpdateInfo()

更新 最后一个不可逆转块块高、最高块块高。 如果rpc请求报错,那么继续请求,阻塞在这里

func (*EOSWatcherMain) UpdatePubKeyHash

func (ew *EOSWatcherMain) UpdatePubKeyHash(pubKeyHash string)

type Issue

type Issue struct {
	Amount uint64 `json:"amount"`
}

type JsonMemo

type JsonMemo struct {
	Address string
	Chain   string
}

type NewAccount

type NewAccount struct {
	User eos.AccountName `json:"user"`
}

type PushEvent

type PushEvent interface {
	GetBusiness() string
	GetEventType() uint32
	GetProposal() string
	GetTxID() string
	GetHeight() int64
	GetTranxIx() int
	GetAmount() uint64
	GetFee() uint64
	GetFrom() byte
	GetTo() byte
	GetData() []byte
}

type Solvent

type Solvent struct {
	From     eos.AccountName `json:"from"`
	Quantity eos.Asset       `json:"quantity"`
	Memo     string          `json:"memo"`
}

type TokenContract

type TokenContract struct {
	// 合约名
	ActionAccount eos.AccountName
	// 溶币方法名
	ActionNameDestroy eos.ActionName
	// 铸币方法名
	ActionNameCreate eos.ActionName

	// 货币名称、精度
	Symbol    string
	Precision uint8
}

Jump to

Keyboard shortcuts

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