mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-17 04:30:03 +02:00
app/ship_processor.go: Make sure we set act.Data to a go object and not json byte slice.
This commit is contained in:
parent
6e47fc1a3c
commit
57a31996d3
1 changed files with 12 additions and 3 deletions
|
|
@ -1,12 +1,15 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/eosswedenorg/thalos/api"
|
||||
"github.com/eosswedenorg/thalos/api/message"
|
||||
"github.com/eosswedenorg/thalos/app/abi"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/eoscanada/eos-go"
|
||||
"github.com/eoscanada/eos-go/ship"
|
||||
shipclient "github.com/eosswedenorg-go/antelope-ship-client"
|
||||
)
|
||||
|
|
@ -64,6 +67,14 @@ func (processor *ShipProcessor) encodeQueue(channel api.Channel, v interface{})
|
|||
return false
|
||||
}
|
||||
|
||||
func decode(abi *eos.ABI, act *ship.Action, v any) error {
|
||||
jsondata, err := abi.DecodeAction(act.Data, act.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal(jsondata, v)
|
||||
}
|
||||
|
||||
func (processor *ShipProcessor) processBlock(block *ship.GetBlocksResultV0) {
|
||||
if block.ThisBlock.BlockNum%100 == 0 {
|
||||
log.Infof("Current: %d, Head: %d", block.ThisBlock.BlockNum, block.Head.BlockNum)
|
||||
|
|
@ -127,11 +138,9 @@ func (processor *ShipProcessor) processBlock(block *ship.GetBlocksResultV0) {
|
|||
|
||||
ABI, err := processor.abi.GetAbi(act_trace.Act.Account)
|
||||
if err == nil {
|
||||
data, err := ABI.DecodeAction(act_trace.Act.Data, act_trace.Act.Name)
|
||||
if err != nil {
|
||||
if err = decode(ABI, act_trace.Act, &act.Data); err != nil {
|
||||
log.WithError(err).Warn("Failed to decode action")
|
||||
}
|
||||
act.Data = data
|
||||
} else {
|
||||
log.WithError(err).Errorf("Failed to get abi for contract %s", act_trace.Act.Account)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue