Skip to content

Commit

Permalink
make btPeer global to nft package
Browse files Browse the repository at this point in the history
  • Loading branch information
Aven Dauz authored and Aven Dauz committed Aug 12, 2021
1 parent cc1a1bb commit ca4d3f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion x/nft/keeper/createNft.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (


func (k Keeper) SeedFile(metainfo *metainfo.MetaInfo) error {
err := k.btClient.SeedFile(metainfo)
err := k.GetBtClient().SeedFile(metainfo)
if err != nil {
return err
}
Expand Down
9 changes: 5 additions & 4 deletions x/nft/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/tendermint/tendermint/libs/log"
"os"
)
var btClient *torrentClient.TorrentClient

type (
Keeper struct {
Expand All @@ -27,7 +28,7 @@ type (
MsgBroadcaster curium.MsgBroadcaster
curiumKeeper *curium.Keeper
KeyringReader *keeper.KeyringReader
btClient *torrentClient.TorrentClient
BtClient *torrentClient.TorrentClient
}
)

Expand Down Expand Up @@ -58,11 +59,11 @@ func NewKeeper (
}

func (k Keeper) GetBtClient() (*torrentClient.TorrentClient) {
return k.btClient
return btClient
}

func (k Keeper) SetBtClient(btClient *torrentClient.TorrentClient) {
k.btClient = btClient
func (k Keeper) SetBtClient(newBtClient *torrentClient.TorrentClient) {
btClient = newBtClient
}

func (k Keeper) GetCdc() *codec.Codec {
Expand Down
6 changes: 3 additions & 3 deletions x/nft/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage {
func (am AppModule) BeginBlock(_ sdk.Context, req abci.RequestBeginBlock) {
}

var registerPeerOnce sync.Once
var once 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 @@ -155,7 +155,7 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val
if err != nil {
am.keeper.Logger(ctx).Error("nft user does not exist in keyring", "nft", err)
} else {
registerPeerOnce.Do(func () {
once.Do(func () {

btClient, err := torrentClient.NewTorrentClient(am.btDirectory, am.btPort)
fmt.Println("Torrent client created", *btClient)
Expand All @@ -167,7 +167,7 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val

am.keeper.SetBtClient(btClient)

fmt.Println("Bt client after setting", am.keeper.GetBtClient())
fmt.Println("Bt client after setting", am.keeper.BtClient, am.keeper.GetBtClient())


fmt.Println("Doing broadcast register peer")
Expand Down

0 comments on commit ca4d3f8

Please sign in to comment.