Skip to content

Commit

Permalink
[src] refs fibercrypto#142 FInalized src/coin , src/core, `src/ut…
Browse files Browse the repository at this point in the history
…il` and `src/main`.
  • Loading branch information
Maykel Arias Torres committed Oct 15, 2019
1 parent b452fb4 commit 9f80473
Show file tree
Hide file tree
Showing 15 changed files with 165 additions and 99 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ run:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs:
- /usr/local/go/src
- src/models

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ install-linters: ## Install linters
cat ./.travis/install-golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.10.2

lint: ## Run linters. Use make install-linters first.
# vendorcheck ./...
# src needs separate linting rules
# golangci-lint run -c .golangci.yml ./src/...
golangci-lint run -c .golangci.yml ./src/...

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
22 changes: 11 additions & 11 deletions src/coin/skycoin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@ type SkyFiberPlugin struct {
func (p *SkyFiberPlugin) ListSupportedAltcoins() []core.AltcoinMetadata {
return []core.AltcoinMetadata{
core.AltcoinMetadata{
Name: SkycoinName,
Ticker: SkycoinTicker,
Family: SkycoinFamily,
Name: params.SkycoinName,
Ticker: params.SkycoinTicker,
Family: params.SkycoinFamily,
HasBip44: false,
Accuracy: 6,
},
core.AltcoinMetadata{
Name: CoinHoursName,
Ticker: CoinHoursTicker,
Family: CoinHoursFamily,
Name: params.CoinHoursName,
Ticker: params.CoinHoursTicker,
Family: params.CoinHoursFamily,
HasBip44: false,
Accuracy: 0,
},
core.AltcoinMetadata{
Name: CalculatedHoursName,
Ticker: CalculatedHoursTicker,
Family: CalculatedHoursFamily,
Name: params.CalculatedHoursName,
Ticker: params.CalculatedHoursTicker,
Family: params.CalculatedHoursFamily,
HasBip44: false,
Accuracy: 0,
},
}
}

func (p *SkyFiberPlugin) ListSupportedFamilies() []string {
return []string{SkycoinFamily}
return []string{params.SkycoinFamily}
}

func (p *SkyFiberPlugin) RegisterTo(manager core.AltcoinManager) {
Expand Down Expand Up @@ -99,5 +99,5 @@ func NewSkyFiberPlugin(params params.SkyFiberParams) core.AltcoinPlugin {
func init() {
cf := local.GetConfigManager()
core.GetMultiPool().CreateSection(sky.PoolSection, sky.NewSkycoinConnectionFactory(cf.GetNode()))
util.RegisterAltcoin(NewSkyFiberPlugin(SkycoinMainNetParams))
util.RegisterAltcoin(NewSkyFiberPlugin(params.SkycoinMainNetParams))
}
7 changes: 5 additions & 2 deletions src/coin/skycoin/models/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"strconv"

"github.com/fibercrypto/FiberCryptoWallet/src/core"
"github.com/fibercrypto/FiberCryptoWallet/src/util"
"github.com/skycoin/skycoin/src/cli"
"github.com/skycoin/skycoin/src/readable"
"github.com/skycoin/skycoin/src/util/droplet"
"github.com/skycoin/skycoin/src/wallet"
"github.com/fibercrypto/FiberCryptoWallet/src/util"
)

func (addr *SkycoinAddress) GetBalance(ticker string) (uint64, error) {
Expand Down Expand Up @@ -95,7 +95,7 @@ func (addr *SkycoinAddress) ListTransactions() core.TransactionIterator {

}
func (addr *SkycoinAddress) ListPendingTransactions() (core.TransactionIterator, error) { //------TODO
return nil,nil
return nil, nil
}

func (wlt *RemoteWallet) GetBalance(ticker string) (uint64, error) {
Expand Down Expand Up @@ -196,6 +196,9 @@ func (wlt *LocalWallet) GetBalance(ticker string) (uint64, error) {
}

bl, err := getBalanceOfAddresses(outs, addrs)
if err != nil {
return 0, err
}

if ticker == Sky {
flSky, err := strconv.ParseFloat(bl.Confirmed.Coins, 64)
Expand Down
2 changes: 1 addition & 1 deletion src/coin/skycoin/models/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type SkycoinBlockchainInfo struct {
}

type SkycoinBlockchainStatus struct { //Implements BlockchainStatus interface
lastTimeStatusRequested uint64
lastTimeStatusRequested uint64 //nolint structcheck TODO: Not used
lastTimeSupplyRequested uint64
CacheTime uint64
cachedStatus *SkycoinBlockchainInfo
Expand Down
16 changes: 11 additions & 5 deletions src/coin/skycoin/models/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"strconv"
"time"

"github.com/skycoin/skycoin/src/cipher"
"github.com/skycoin/skycoin/src/visor"
"github.com/skycoin/skycoin/src/coin"
"github.com/fibercrypto/FiberCryptoWallet/src/core"
"github.com/fibercrypto/FiberCryptoWallet/src/util"
"github.com/skycoin/skycoin/src/cipher"
"github.com/skycoin/skycoin/src/coin"
"github.com/skycoin/skycoin/src/readable"
"github.com/skycoin/skycoin/src/visor"
)

/*
Expand Down Expand Up @@ -279,7 +279,10 @@ func (txn *SkycoinTransaction) GetStatus() core.TransactionStatus {
return 0
}
defer core.GetMultiPool().Return(PoolSection, 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 Expand Up @@ -417,7 +420,10 @@ func (in *SkycoinTransactionInput) GetSpentOutput() core.TransactionOutput {
if err != nil {
return nil
}
skyAccuracy, _ := util.AltcoinQuotient("SKY")
skyAccuracy, err := util.AltcoinQuotient("SKY")
if err != nil {
return nil
}

skyOut := &SkycoinTransactionOutput{
skyOut: readable.TransactionOutput{
Expand Down
4 changes: 2 additions & 2 deletions src/coin/skycoin/models/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewSkycoinApiClient(section string) (*api.Client, error) {

if err != nil {
for _, ok := err.(core.NotAvailableObjectsError); ok; _, ok = err.(core.NotAvailableObjectsError) {
obj, err = pool.Get(section)
_, err = pool.Get(section)
if err == nil {
break
}
Expand All @@ -44,7 +44,7 @@ func NewSkycoinApiClient(section string) (*api.Client, error) {

skyApi, ok := obj.(*api.Client)
if !ok {
return nil, errors.New(fmt.Sprintf("There is not propers client in %s pool", section))
return nil, fmt.Errorf("There is not propers client in %s pool", section)
}
return skyApi, nil
}
Expand Down
5 changes: 1 addition & 4 deletions src/coin/skycoin/models/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ func (it *SkycoinPexNodeIterator) Next() bool {
}

func (it *SkycoinPexNodeIterator) HasNext() bool {
if (it.current + 1) >= len(it.networks) {
return false
}
return true
return !((it.current + 1) >= len(it.networks))
}

func NewSkycoinPexNodeIterator(network []core.PexNode) *SkycoinPexNodeIterator {
Expand Down
Loading

0 comments on commit 9f80473

Please sign in to comment.