Skip to content

Commit

Permalink
end block
Browse files Browse the repository at this point in the history
  • Loading branch information
boojamya committed Mar 4, 2024
1 parent d469119 commit c4c9370
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ethereum/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Ethereum struct {
wsURL string
messageTransmitterAddress string
startBlock uint64
endBlock uint64
lookbackPeriod uint64
privateKey *ecdsa.PrivateKey
minterAddress string
Expand All @@ -42,6 +43,7 @@ func NewChain(
wsURL string,
messageTransmitterAddress string,
startBlock uint64,
endBlock uint64,
lookbackPeriod uint64,
privateKey string,
maxRetries int,
Expand All @@ -60,6 +62,7 @@ func NewChain(
wsURL: wsURL,
messageTransmitterAddress: messageTransmitterAddress,
startBlock: startBlock,
endBlock: endBlock,
lookbackPeriod: lookbackPeriod,
privateKey: privEcdsaKey,
minterAddress: ethereumAddress,
Expand Down
2 changes: 2 additions & 0 deletions ethereum/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type ChainConfig struct {
MessageTransmitter string `yaml:"message-transmitter"`

StartBlock uint64 `yaml:"start-block"`
EndBlock uint64 `yaml:"end-block"`
LookbackPeriod uint64 `yaml:"lookback-period"`

BroadcastRetries int `yaml:"broadcast-retries"`
Expand All @@ -34,6 +35,7 @@ func (c *ChainConfig) Chain(name string) (types.Chain, error) {
c.WS,
c.MessageTransmitter,
c.StartBlock,
c.EndBlock,
c.LookbackPeriod,
c.MinterPrivateKey,
c.BroadcastRetries,
Expand Down
8 changes: 8 additions & 0 deletions ethereum/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ func (e *Ethereum) StartListener(
Addresses: []common.Address{messageTransmitterAddress},
Topics: [][]common.Hash{{messageSent.ID}},
FromBlock: big.NewInt(int64(e.startBlock - e.lookbackPeriod)),
ToBlock: big.NewInt(int64(e.endBlock)),
}
if e.endBlock == 0 {
query = ethereum.FilterQuery{
Addresses: []common.Address{messageTransmitterAddress},
Topics: [][]common.Hash{{messageSent.ID}},
FromBlock: big.NewInt(int64(e.startBlock - e.lookbackPeriod)),
}
}

logger.Info(fmt.Sprintf(
Expand Down

0 comments on commit c4c9370

Please sign in to comment.