mirror of
https://github.com/eosswedenorg/thalos
synced 2026-07-04 12:03:41 +02:00
app/ship_processor.go: Adding updateAbiFromAction()
This commit is contained in:
parent
637ec74a2a
commit
d552a924e9
1 changed files with 28 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/eosswedenorg/thalos/api"
|
"github.com/eosswedenorg/thalos/api"
|
||||||
|
|
@ -79,6 +80,33 @@ func decode(abi *eos.ABI, act *ship.Action, v any) error {
|
||||||
return json.Unmarshal(jsondata, v)
|
return json.Unmarshal(jsondata, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (processor *ShipProcessor) updateAbiFromAction(act *ship.Action) error {
|
||||||
|
ABI, err := processor.abi.GetAbi(processor.syscontract)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
set_abi := struct {
|
||||||
|
Abi string
|
||||||
|
Account eos.AccountName
|
||||||
|
}{}
|
||||||
|
if err := decode(ABI, act, &set_abi); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
binary_abi, err := hex.DecodeString(set_abi.Abi)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
contract_abi := eos.ABI{}
|
||||||
|
if err = eos.UnmarshalBinary(binary_abi, &contract_abi); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return processor.abi.SetAbi(set_abi.Account, &contract_abi)
|
||||||
|
}
|
||||||
|
|
||||||
func (processor *ShipProcessor) processBlock(block *ship.GetBlocksResultV0) {
|
func (processor *ShipProcessor) processBlock(block *ship.GetBlocksResultV0) {
|
||||||
if block.ThisBlock.BlockNum%100 == 0 {
|
if block.ThisBlock.BlockNum%100 == 0 {
|
||||||
log.Infof("Current: %d, Head: %d", block.ThisBlock.BlockNum, block.Head.BlockNum)
|
log.Infof("Current: %d, Head: %d", block.ThisBlock.BlockNum, block.Head.BlockNum)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue