Commit 7546549f authored by suyanlong's avatar suyanlong

Add execType and symbols pair

parent e22100b0
...@@ -36,19 +36,21 @@ type DB struct { ...@@ -36,19 +36,21 @@ type DB struct {
} }
type Chain33 struct { type Chain33 struct {
Title string `toml:"title" json:"title"` Title string `toml:"title" json:"title"`
Addr string `toml:"addr" json:"addr"` Addr string `toml:"addr" json:"addr"`
Name string `toml:"name" json:"name"` Name string `toml:"name" json:"name"`
PrivateKey string `mapstructure:"private_key" toml:"private_key" json:"private_key"` PrivateKey string `mapstructure:"private_key" toml:"private_key" json:"private_key"`
ChainID int32 `mapstructure:"chain_id" json:"chain_id"` ChainID int32 `mapstructure:"chain_id" json:"chain_id"`
StartHeight int64 `mapstructure:"start_height" json:"start_height"` // 起始高度 StartHeight int64 `mapstructure:"start_height" json:"start_height"` // 起始高度
HeightDiff int64 `mapstructure:"height_diff" json:"height_diff"` // 高度差 HeightDiff int64 `mapstructure:"height_diff" json:"height_diff"` // 高度差
Fee int64 `mapstructure:"Fee" json:"Fee"` // 单笔交易的手续费 Fee int64 `mapstructure:"Fee" json:"Fee"` // 单笔交易的手续费
Step int64 `mapstructure:"step" json:"step"` // 步长 Step int64 `mapstructure:"step" json:"step"` // 步长
EventFilter string `mapstructure:"event_filter" toml:"event_filter" json:"event_filter"` ExecType int64 `mapstructure:"exec_type" json:"exec_type"` // 执行器类型:0、1
TimeoutHeight int64 `mapstructure:"timeout_height" json:"timeout_height"` EventFilter string `mapstructure:"event_filter" toml:"event_filter" json:"event_filter"`
IsTest bool `mapstructure:"is_test" json:"is_test"` TimeoutHeight int64 `mapstructure:"timeout_height" json:"timeout_height"`
Symbol string `mapstructure:"symbol" json:"symbol"` IsTest bool `mapstructure:"is_test" json:"is_test"`
Symbol string `mapstructure:"symbol" json:"symbol"`
Symbols map[string]string `mapstructure:"symbols" json:"symbols"`
} }
type Service struct { type Service struct {
......
...@@ -334,8 +334,17 @@ func (e *Evmxgo) pollAppChain() chan *types.Event { ...@@ -334,8 +334,17 @@ func (e *Evmxgo) pollAppChain() chan *types.Event {
burnEvent := action.BurnMap burnEvent := action.BurnMap
e.logger.Info("printf burnEvent", "burnEvent", util.FormatJSON(action)) e.logger.Info("printf burnEvent", "burnEvent", util.FormatJSON(action))
amount := burnEvent.Amount
symbol := burnEvent.Symbol
isRun := false
if len(e.config.Chain33.Symbols) != 0 {
symbol, isRun = e.config.Chain33.Symbols[symbol]
} else {
isRun = strings.ToLower(burnEvent.Symbol) == strings.ToLower(e.config.Chain33.Symbol)
}
// 销毁指定的token // 销毁指定的token
if strings.ToLower(burnEvent.Symbol) == strings.ToLower(e.config.Chain33.Symbol) { if isRun {
// extra, _ := util.FromHex(burnEvent.Extra) // extra, _ := util.FromHex(burnEvent.Extra)
// 已销毁 // 已销毁
burnAddress := burnEvent.Recipient burnAddress := burnEvent.Recipient
...@@ -354,8 +363,8 @@ func (e *Evmxgo) pollAppChain() chan *types.Event { ...@@ -354,8 +363,8 @@ func (e *Evmxgo) pollAppChain() chan *types.Event {
Payload: &types.MapAssetInfo{ Payload: &types.MapAssetInfo{
EventType: types.EventType_Burn, EventType: types.EventType_Burn,
BurnAddress: burnAddress, BurnAddress: burnAddress,
BurnAmount: cast.ToInt64(burnEvent.Amount), BurnAmount: cast.ToInt64(amount),
Symbol: types.Symbol(burnEvent.Symbol), Symbol: types.Symbol(symbol),
Height: height1, Height: height1,
Nonce: tx.Nonce, Nonce: tx.Nonce,
// Extra: extra, //TODO // Extra: extra, //TODO
......
...@@ -14,6 +14,11 @@ chain_id = 0 ...@@ -14,6 +14,11 @@ chain_id = 0
step = 10 step = 10
symbol = "BTY" symbol = "BTY"
[chain33.symbols]
#BTY = "BTY"
#YCC = "YCC"
[log] [log]
#日志级别 #日志级别
level = "trace" level = "trace"
......
...@@ -164,7 +164,7 @@ func (p *Paracross) Initialize(configPath string, ID string, extra []byte) error ...@@ -164,7 +164,7 @@ func (p *Paracross) Initialize(configPath string, ID string, extra []byte) error
p.isTest = chain33Config.Chain33.IsTest p.isTest = chain33Config.Chain33.IsTest
p.paraHeight = atomic.NewInt64(-2) // TODO p.paraHeight = atomic.NewInt64(-2) // TODO
// 判断执行器地址类型 // 判断执行器地址类型
if strings.ToUpper(chain33Config.Chain33.Symbol) == "YCC" { if chain33Config.Chain33.ExecType == 2 {
// 执行器地址类型,YCC是以太坊地址类型。 // 执行器地址类型,YCC是以太坊地址类型。
execAddress, err := address.GetExecAddress(p.title+execer, 2) execAddress, err := address.GetExecAddress(p.title+execer, 2)
if err != nil { if err != nil {
...@@ -734,6 +734,14 @@ func (p *Paracross) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) { ...@@ -734,6 +734,14 @@ func (p *Paracross) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) {
// 第一次提交。 // 第一次提交。
tokenSymbol := p.chain33Config.Chain33.Symbol tokenSymbol := p.chain33Config.Chain33.Symbol
symbol := strings.ToLower(p.chain33Config.Chain33.Symbol) symbol := strings.ToLower(p.chain33Config.Chain33.Symbol)
isRun := false
if len(p.chain33Config.Chain33.Symbols) != 0 {
symbol, isRun = p.chain33Config.Chain33.Symbols[event.Payload.Symbol]
if !isRun {
symbol = ""
}
}
if symbol == "ycc" || symbol == "bty" { if symbol == "ycc" || symbol == "bty" {
// 主链的token映射到平行链: coins.xxx // 主链的token映射到平行链: coins.xxx
tokenSymbol = fmt.Sprintf("coins.%s", symbol) tokenSymbol = fmt.Sprintf("coins.%s", symbol)
......
...@@ -14,7 +14,11 @@ fee = 100000 ...@@ -14,7 +14,11 @@ fee = 100000
#被监听链ID #被监听链ID
chain_id = 0 chain_id = 0
step = 10 step = 10
exec_type = 0
symbol = "BTY" symbol = "BTY"
[chain33.symbols]
#BTY = "BTY"
#YCC = "YCC"
[log] [log]
#日志级别 #日志级别
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment