Commit 1c593baf authored by suyanlong's avatar suyanlong

add symbol config

parent 612de9e8
......@@ -48,6 +48,7 @@ type Chain33 struct {
EventFilter string `mapstructure:"event_filter" toml:"event_filter" json:"event_filter"`
TimeoutHeight int64 `mapstructure:"timeout_height" json:"timeout_height"`
IsTest bool `mapstructure:"is_test" json:"is_test"`
Symbol string `mapstructure:"symbol" json:"symbol"`
}
type Service struct {
......
......@@ -6,6 +6,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"time"
"github.com/33cn/chain33/common/address"
......@@ -60,6 +61,7 @@ type Evmxgo struct {
heightDiff int64 // 高度差
logger hclog.InterceptLogger
config *config.Config
}
func (e *Evmxgo) incHeight() int64 {
......@@ -104,6 +106,7 @@ func (e *Evmxgo) Initialize(configPath string, _ string, _ []byte) error {
if err != nil {
return fmt.Errorf("unmarshal config for plugin :%w", err)
}
e.config = chain33Config
out, err := log.Initialize(
log.WithReportCaller(chain33Config.Log.ReportCaller == true),
log.WithPersist(true),
......@@ -328,35 +331,38 @@ func (e *Evmxgo) pollAppChain() chan *types.Event {
}
burnEvent := action.BurnMap
e.logger.Info("printf burnEvent", "burnEvent", util.FormatJSON(action))
// extra, _ := util.FromHex(burnEvent.Extra)
// 已销毁
burnAddress := burnEvent.Recipient
if burnAddress == "" {
burnAddress = tx.From // 用户地址
}
event := &types.Event{
TxID: tx.Hash,
BlockNumber: uint64(item.Block.Height),
Contract: &types.Contract{
ChainID: cast.ToString(e.chainID),
ExecName: ID,
Address: address.ExecAddress(ID), // 合约地址
CallMethod: evmxgotypes.NameBurnMapAction,
},
Payload: &types.MapAssetInfo{
EventType: types.EventType_Burn,
BurnAddress: burnAddress,
BurnAmount: cast.ToInt64(burnEvent.Amount),
Symbol: types.Symbol(burnEvent.Symbol),
Height: height1,
Nonce: tx.Nonce,
// Extra: extra, //TODO
},
if strings.ToLower(burnEvent.Symbol) == strings.ToLower(e.config.Chain33.Symbol) {
// extra, _ := util.FromHex(burnEvent.Extra)
// 已销毁
burnAddress := burnEvent.Recipient
if burnAddress == "" {
burnAddress = tx.From // 用户地址
}
event := &types.Event{
TxID: tx.Hash,
BlockNumber: uint64(item.Block.Height),
Contract: &types.Contract{
ChainID: cast.ToString(e.chainID),
ExecName: ID,
Address: address.ExecAddress(ID), // 合约地址
CallMethod: evmxgotypes.NameBurnMapAction,
},
Payload: &types.MapAssetInfo{
EventType: types.EventType_Burn,
BurnAddress: burnAddress,
BurnAmount: cast.ToInt64(burnEvent.Amount),
Symbol: types.Symbol(burnEvent.Symbol),
Height: height1,
Nonce: tx.Nonce,
// Extra: extra, //TODO
},
}
e.saveBurn(event)
e.saveUndoneEvent(event)
ch <- event
break
}
e.saveBurn(event)
e.saveUndoneEvent(event)
ch <- event
break
}
}
......
......@@ -12,6 +12,7 @@ fee = 100000
#被监听链ID
chain_id = 0
step = 10
symbol = "bty"
[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