Skip to content

Commit

Permalink
[coin] refs fibercrypto#142 Correcting error the linter in coin
Browse files Browse the repository at this point in the history
  • Loading branch information
Maykel Arias Torres committed Oct 15, 2019
1 parent c123e77 commit 241d68b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/coin/skycoin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ func NewSkyFiberPlugin(params params.SkyFiberParams) core.AltcoinPlugin {

func init() {
cf := local.GetConfigManager()
core.GetMultiPool().CreateSection(sky.PoolSection, sky.NewSkycoinConnectionFactory(cf.GetNode()))
err := core.GetMultiPool().CreateSection(sky.PoolSection, sky.NewSkycoinConnectionFactory(cf.GetNode()))
if err != nil {
return
}
util.RegisterAltcoin(NewSkyFiberPlugin(params.SkycoinMainNetParams))
}
5 changes: 4 additions & 1 deletion src/coin/skycoin/models/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ func (addr *SkycoinAddress) ListTransactions() core.TransactionIterator {
}
defer ReturnSkycoinClient(c)
transactions := make([]core.Transaction, 0)
txn, _ := c.TransactionsVerbose([]string{addr.String()})
txn, err := c.TransactionsVerbose([]string{addr.String()})
if err != nil {
return nil
}

for _, tx := range txn {
st := core.TXN_STATUS_PENDING
Expand Down
5 changes: 4 additions & 1 deletion src/coin/skycoin/models/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ func (txn *SkycoinTransaction) GetStatus() core.TransactionStatus {
return 0
}
defer ReturnSkycoinClient(c)
txnU, _ := c.Transaction(txn.skyTxn.Hash)
txnU, err := c.Transaction(txn.skyTxn.Hash)
if err != nil {
return 0
}
if txnU.Status.Confirmed {
txn.status = core.TXN_STATUS_CONFIRMED
return txn.status
Expand Down
2 changes: 1 addition & 1 deletion src/coin/skycoin/models/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type SkycoinApiClient struct {
pool core.MultiPoolSection
}

// nolint megacheck TODO: This functions is not used
func (sc *SkycoinApiClient) returnToPool() {
sc.pool.Put(sc.Client)
}
Expand All @@ -78,7 +79,6 @@ func NewSkycoinApiClient(section string) (SkycoinAPI, error) {

if err != nil {
for _, ok := err.(core.NotAvailableObjectsError); ok; _, ok = err.(core.NotAvailableObjectsError) {
obj = pool.Get()
if err == nil {
break
}
Expand Down
30 changes: 24 additions & 6 deletions src/coin/skycoin/models/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ func (wltSrv *SkycoinRemoteWallet) Encrypt(walletName string, pwd core.PasswordR
return
}
defer ReturnSkycoinClient(c)
password, _ := pwd("Insert password")
password, err := pwd("Insert password")
if err != nil {
return
}
_, err = c.EncryptWallet(walletName, password)
if err != nil {
return
Expand All @@ -153,7 +156,10 @@ func (wltSrv *SkycoinRemoteWallet) Decrypt(walletName string, pwd core.PasswordR
return
}
defer ReturnSkycoinClient(c)
password, _ := pwd("Insert password")
password, err := pwd("Insert password")
if err != nil {
return
}
_, err = c.DecryptWallet(walletName, password)
if err != nil {
return
Expand Down Expand Up @@ -190,7 +196,10 @@ func (wltSrv *SkycoinRemoteWallet) GetWallet(id string) core.Wallet {
func NewWalletNode(nodeAddress string) *WalletNode {

pool := core.GetMultiPool()
sections, _ := pool.ListSections()
sections, err := pool.ListSections()
if err != nil {
return nil
}
cont := 1
var sect string
for {
Expand All @@ -208,7 +217,10 @@ func NewWalletNode(nodeAddress string) *WalletNode {
}
}

pool.CreateSection(sect, NewSkycoinConnectionFactory(nodeAddress))
err = pool.CreateSection(sect, NewSkycoinConnectionFactory(nodeAddress))
if err != nil {
return nil
}
return &WalletNode{
NodeAddress: nodeAddress,
poolSection: sect,
Expand Down Expand Up @@ -345,7 +357,10 @@ func (wlt *RemoteWallet) SetLabel(name string) {
return
}
defer ReturnSkycoinClient(c)
_ = c.UpdateWallet(wlt.Id, name)
err = c.UpdateWallet(wlt.Id, name)
if err != nil {
return
}
}

func (wlt *RemoteWallet) GetId() string {
Expand Down Expand Up @@ -517,7 +532,10 @@ func (wlt *RemoteWallet) GenAddresses(addrType core.AddressType, startIndex, cou
return nil
}
defer ReturnSkycoinClient(c)
password, _ := pwd("Insert password")
password, err := pwd("Insert password")
if err != nil {
return nil
}
wltR, err := c.Wallet(wlt.Id)
if err != nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion src/core/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (ps *PoolSection) Put(obj interface{}) {
func newMultiConnectionPool(capacity int) *MultiConnectionsPool {
return &MultiConnectionsPool{
capacity: capacity,
sections: make(map[string]*PoolSection, 0),
sections: make(map[string]*PoolSection),
}
}
func GetMultiPool() MultiPool {
Expand Down

0 comments on commit 241d68b

Please sign in to comment.