Skip to content

Commit

Permalink
moved peerRegistered flag out of endblocker
Browse files Browse the repository at this point in the history
  • Loading branch information
avendauz committed Aug 5, 2021
1 parent af5f344 commit 3f1f7f0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions x/nft/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
peerRegistered = false
)

// AppModuleBasic defines the basic application module used by the nft module.
Expand Down Expand Up @@ -138,14 +139,15 @@ func (am AppModule) BeginBlock(_ sdk.Context, req abci.RequestBeginBlock) {
// EndBlock returns the end blocker for the nft module. It returns no validator
// updates.
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
if ctx.BlockHeight() == 10 {
go func() {
err := am.keeper.BroadcastRegisterBtPeer(ctx)
if err != nil {
am.keeper.Logger(ctx).Error("Registering bt peers failed", "RegisterBtPeer", err)
}

}()
if ctx.BlockHeight() > 10 {
if !peerRegistered {
go func() {
err := am.keeper.BroadcastRegisterBtPeer(ctx)
if err == nil {
peerRegistered = true
}
}()
}
}
return []abci.ValidatorUpdate{}
}

0 comments on commit 3f1f7f0

Please sign in to comment.