node/pkg/ethereum: remove emitGuardianSet flag

Change-Id: Ic275220080d29b5a834f6487502619df877059c9
This commit is contained in:
Leo 2021-07-28 15:22:06 +02:00 committed by Leopold Schabel
parent f717262282
commit 1686b35587
2 changed files with 17 additions and 18 deletions

View File

@ -374,7 +374,7 @@ func runBridge(cmd *cobra.Command, args []string) {
}
if err := supervisor.Run(ctx, "ethwatch",
ethereum.NewEthBridgeWatcher(*ethRPC, ethContractAddr, "eth", vaa.ChainIDEthereum, true, lockC, setC).Run); err != nil {
ethereum.NewEthBridgeWatcher(*ethRPC, ethContractAddr, "eth", vaa.ChainIDEthereum, lockC, setC).Run); err != nil {
return err
}

View File

@ -69,18 +69,19 @@ type (
networkName string
// VAA ChainID of the network we're connecting to.
chainID vaa.ChainID
// Whether to publish a message to setChan whenever the guardian set changes.
// Channel to send new messages to.
msgChan chan *common.MessagePublication
// Channel to send guardian set changes to.
// setChan can be set to nil if no guardian set changes are needed.
//
// We currently only fetch the guardian set from one primary chain, which should
// have this flag set to true, and false on all others.
//
// The current primary chain is Ethereum (a mostly arbitrary decision because it
// has the best API - we might want to switch the primary chain to Solana once
// the governance mechanism lives there),
emitGuardianSet bool
// Channel to send new messages to.
msgChan chan *common.MessagePublication
// Channel to send guardian set changes to.
setChan chan *common.GuardianSet
pending map[eth_common.Hash]*pendingMessage
@ -98,18 +99,16 @@ func NewEthBridgeWatcher(
bridge eth_common.Address,
networkName string,
chainID vaa.ChainID,
emitGuardianSet bool,
messageEvents chan *common.MessagePublication,
setEvents chan *common.GuardianSet) *EthBridgeWatcher {
return &EthBridgeWatcher{
url: url,
bridge: bridge,
networkName: networkName,
emitGuardianSet: emitGuardianSet,
chainID: chainID,
msgChan: messageEvents,
setChan: setEvents,
pending: map[eth_common.Hash]*pendingMessage{}}
url: url,
bridge: bridge,
networkName: networkName,
chainID: chainID,
msgChan: messageEvents,
setChan: setEvents,
pending: map[eth_common.Hash]*pendingMessage{}}
}
func (e *EthBridgeWatcher) Run(ctx context.Context) error {
@ -170,7 +169,7 @@ func (e *EthBridgeWatcher) Run(ctx context.Context) error {
zap.Any("value", gs), zap.Uint32("index", idx),
zap.String("eth_network", e.networkName))
if e.emitGuardianSet {
if e.setChan != nil {
e.setChan <- &common.GuardianSet{
Keys: gs.Keys,
Index: idx,
@ -249,7 +248,7 @@ func (e *EthBridgeWatcher) Run(ctx context.Context) error {
zap.Any("value", gs), zap.Uint32("index", ev.Index),
zap.String("eth_network", e.networkName))
if e.emitGuardianSet {
if e.setChan != nil {
e.setChan <- &common.GuardianSet{
Keys: gs.Keys,
Index: ev.Index,