mirror of
https://github.com/eosswedenorg/thalos
synced 2026-07-04 12:03:41 +02:00
app/ship_processor.go: keep track of current block.
This commit is contained in:
parent
e1dc5f85a0
commit
6ef3daeecf
1 changed files with 16 additions and 6 deletions
|
|
@ -34,6 +34,9 @@ type ShipProcessor struct {
|
||||||
shipStream *shipclient.Stream
|
shipStream *shipclient.Stream
|
||||||
encode message.Encoder
|
encode message.Encoder
|
||||||
|
|
||||||
|
// Keep track of the current block we have processed.
|
||||||
|
current_block uint32
|
||||||
|
|
||||||
// System contract ("eosio" per default)
|
// System contract ("eosio" per default)
|
||||||
syscontract eos.AccountName
|
syscontract eos.AccountName
|
||||||
}
|
}
|
||||||
|
|
@ -45,6 +48,7 @@ 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,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach handlers
|
// Attach handlers
|
||||||
|
|
@ -107,9 +111,15 @@ func (processor *ShipProcessor) updateAbiFromAction(act *ship.Action) error {
|
||||||
return processor.abi.SetAbi(set_abi.Account, &contract_abi)
|
return processor.abi.SetAbi(set_abi.Account, &contract_abi)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (processor *ShipProcessor) GetCurrentBlock() uint32 {
|
||||||
|
return processor.current_block
|
||||||
|
}
|
||||||
|
|
||||||
func (processor *ShipProcessor) processBlock(block *ship.GetBlocksResultV0) {
|
func (processor *ShipProcessor) processBlock(block *ship.GetBlocksResultV0) {
|
||||||
|
processor.current_block = block.ThisBlock.BlockNum
|
||||||
|
|
||||||
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", processor.current_block, block.Head.BlockNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
if block.ThisBlock.BlockNum%10 == 0 {
|
if block.ThisBlock.BlockNum%10 == 0 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue