Skip to content

Commit

Permalink
use check nft user exists before registering peer, use sync.Once for …
Browse files Browse the repository at this point in the history
…registering peer
  • Loading branch information
avendauz committed Aug 12, 2021
1 parent cd2d4b0 commit b66bec0
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions x/nft/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (am AppModule) BeginBlock(_ sdk.Context, req abci.RequestBeginBlock) {
}

var once sync.Once

var registerPeerOnce sync.Once
// 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 {
Expand All @@ -163,15 +163,17 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val
am.keeper.Logger(ctx).Error("nft user does not exist in keyring", "nft", err)
}

//if ctx.BlockHeight() > 10 {
// if !peerRegistered {
// go func() {
// err := am.keeper.BroadcastRegisterBtPeer(ctx)
// if err == nil {
// peerRegistered = true
// }
// }()
// }
//}
if ctx.BlockHeight() > 10 {
if err == nil {
registerPeerOnce.Do(func () {
go func() {
err := am.keeper.BroadcastRegisterBtPeer(ctx)
if err != nil {
am.keeper.Logger(ctx).Error("Broadcast Register Bt Peer failed", "error", err)
}
}()})
}

}
return []abci.ValidatorUpdate{}
}

0 comments on commit b66bec0

Please sign in to comment.