1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-07-04 12:03:41 +02:00

app/ship_processor.go: remove current_block and use state.CurrentBlock instead.

This commit is contained in:
Henrik Hautakoski 2023-11-01 21:47:21 +01:00
parent 98a49538e2
commit 310f96219f

View file

@ -43,8 +43,8 @@ type ShipProcessor struct {
// Encoder used to encode messages // Encoder used to encode messages
encode message.Encoder encode message.Encoder
// Keep track of the current block we have processed. // Internal state
current_block uint32 state State
// System contract ("eosio" per default) // System contract ("eosio" per default)
syscontract eos.AccountName syscontract eos.AccountName
@ -58,7 +58,9 @@ func SpawnProccessor(shipStream *shipclient.Stream, writer api.Writer, abi *abi.
shipStream: shipStream, shipStream: shipStream,
encode: logDecoratedEncoder(codec.Encoder), encode: logDecoratedEncoder(codec.Encoder),
syscontract: eos.AccountName("eosio"), syscontract: eos.AccountName("eosio"),
current_block: shipStream.StartBlock, state: State{
CurrentBlock: shipStream.StartBlock,
},
} }
// Attach handlers // Attach handlers
@ -124,15 +126,15 @@ func (processor *ShipProcessor) updateAbiFromAction(act *ship.Action) error {
// Get the current block. // Get the current block.
func (processor *ShipProcessor) GetCurrentBlock() uint32 { func (processor *ShipProcessor) GetCurrentBlock() uint32 {
return processor.current_block return processor.state.CurrentBlock
} }
// Callback function called by shipclient.Stream when a new block arrives. // Callback function called by shipclient.Stream when a new block arrives.
func (processor *ShipProcessor) processBlock(block *ship.GetBlocksResultV0) { func (processor *ShipProcessor) processBlock(block *ship.GetBlocksResultV0) {
processor.current_block = block.ThisBlock.BlockNum processor.state.CurrentBlock = block.ThisBlock.BlockNum
if block.ThisBlock.BlockNum%100 == 0 { if block.ThisBlock.BlockNum%100 == 0 {
log.Infof("Current: %d, Head: %d", processor.current_block, block.Head.BlockNum) log.Infof("Current: %d, Head: %d", processor.state.CurrentBlock, block.Head.BlockNum)
} }
if block.ThisBlock.BlockNum%10 == 0 { if block.ThisBlock.BlockNum%10 == 0 {