Fix linting issues

This commit is contained in:
Martin Boehm 2021-11-28 21:26:55 +01:00
parent ae4cb2fb64
commit e143215288
64 changed files with 87 additions and 94 deletions

View File

@ -1,11 +1,11 @@
# Blockbook Contributor Guide
Blockbook is back-end service for Trezor wallet. Although it is open source, the design and development of the core packages
is done by Trezor developers in order to keep Blockbook compatible with Trezor.
Blockbook is a back-end service for the Trezor wallet. Although it is open source, the design and development of the core packages
is done by the Trezor developers to keep Blockbook compatible with Trezor.
Bug fixes and support for new coins are welcome. **Please take note that non-fixing pull requests that change base
packages or another coin code will not be accepted.** If you have a need to change some of the existing code, please file
an issue and discuss your request with Blockbook maintainers.
Bug fixes and support for new coins are welcome. **Please take note that pull requests that are not fixes and that change base
packages or another coin code will not be accepted.** If you need a change in the existing core code, please file
an issue and discuss your request with the Blockbook maintainers.
## Development environment
@ -16,8 +16,8 @@ Instructions to set up your development environment and build Blockbook are desc
### Reporting bugs
A great way to contribute to the project is to send a detailed report when you encounter an issue. We always appreciate
a well-written, thorough bug report, and will thank you for it!
A great way to contribute to the project is to send a detailed report when you encounter a problem. We always appreciate
a well-written and thorough bug report, and we'll be grateful for it!
Check that [our issue database](https://github.com/trezor/blockbook/issues) doesn't already include that problem or
suggestion before submitting an issue. If you find a match, you can use the "subscribe" button to get notified on

View File

@ -5,10 +5,10 @@
**Blockbook** is back-end service for Trezor wallet. Main features of **Blockbook** are:
- index of addresses and address balances of the connected block chain
- fast searches in the indexes
- fast index search
- simple blockchain explorer
- websocket, API and legacy Bitcore Insight compatible socket.io interfaces
- support of multiple coins (Bitcoin and Ethereum type), with easy extensibility for other coins
- support of multiple coins (Bitcoin and Ethereum type) with easy extensibility to other coins
- scripts for easy creation of debian packages for backend and blockbook
## Build and installation instructions
@ -51,7 +51,8 @@ Please add your experience to this [issue](https://github.com/trezor/blockbook/i
#### Error `internalState: database is in inconsistent state and cannot be used`
Blockbook was killed during the initial import, most commonly by OOM killer. By default, Blockbook performs the initial import in bulk import mode, which for performance reasons does not store all the data immediately to the database. If Blockbook is killed during this phase, the database is left in an inconsistent state.
Blockbook was killed during the initial import, most commonly by OOM killer.
By default, Blockbook performs the initial import in bulk import mode, which for performance reasons does not store all data immediately to the database. If Blockbook is killed during this phase, the database is left in an inconsistent state.
See above how to reduce the memory footprint, delete the database files and run the import again.
@ -67,9 +68,9 @@ Your coin's block/transaction data may not be compatible with `BitcoinParser` `P
#### Cannot build Blockbook using `go build` command
When building Blockbook, I get error `not enough arguments in call to _Cfunc_rocksdb_approximate_sizes`.
When building Blockbook I get error `not enough arguments in call to _Cfunc_rocksdb_approximate_sizes`.
RocksDB version 6.16.0 changed the API in backward incompatible way. It is necessary to build Blockbook with the tag `rocksdb_6_16`, which fixes the compatibility issue. The correct way to build Blockbook is:
RocksDB version 6.16.0 changed the API in a backwards incompatible way. It is necessary to build Blockbook with the `rocksdb_6_16` tag to fix the compatibility problem. The correct way to build Blockbook is:
```
go build -tags rocksdb_6_16

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package api

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package bchain

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package bch

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package bellcoin

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package bitcore

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package bitzeny

View File

@ -1,5 +1,4 @@
//go:build unittest
// +build unittest
package btc

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package btg

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package dash

View File

@ -1,5 +1,4 @@
//go:build unittest
// +build unittest
package dcr

View File

@ -54,7 +54,7 @@ func NewDecredRPC(config json.RawMessage, pushHandler func(bchain.NotificationTy
Dial: (&net.Dialer{KeepAlive: 600 * time.Second}).Dial,
MaxIdleConns: 100,
MaxIdleConnsPerHost: 100, // necessary to not to deplete ports
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
d := &DecredRPC{

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package deeponion

View File

@ -6,14 +6,14 @@ import (
"github.com/trezor/blockbook/bchain/coins/btc"
)
// network constants
const (
// MainnetMagic is mainnet network constant
MainnetMagic wire.BitcoinNet = 0xdab6c3fa
TestnetMagic wire.BitcoinNet = 0xddbdc8fd
)
// parser parameters
var (
// MainNetParams are parser parameters for mainnet
MainNetParams chaincfg.Params
TestNetParams chaincfg.Params
)

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package digibyte

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package divi

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package dogecoin

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package eth

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package eth

View File

@ -26,11 +26,11 @@ const (
TestnetMagic wire.BitcoinNet = 0xcffcbeea
RegtestMagic wire.BitcoinNet = 0xfabfb5da
GenesisBlockTime = 1414776286
SwitchToMTPBlockHeader = 1544443200
GenesisBlockTime = 1414776286
SwitchToMTPBlockHeader = 1544443200
SwitchToProgPowBlockHeaderTestnet = 1630069200
SwitchToProgPowBlockHeaderMainnet = 1635228000
MTPL = 64
MTPL = 64
SpendTxID = "0000000000000000000000000000000000000000000000000000000000000000"
@ -159,7 +159,7 @@ func (p *FiroParser) ParseBlock(b []byte) (*bchain.Block, error) {
}
// then ProgPow or MTP header
if(isProgPow(header, p.Params.Net == TestnetMagic)){
if isProgPow(header, p.Params.Net == TestnetMagic) {
progPowHeader := ProgPowBlockHeader{}
// header

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package firo

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package flo

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package fujicoin

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package gamecredits

View File

@ -50,7 +50,7 @@ type GroestlcoinParser struct {
func NewGroestlcoinParser(params *chaincfg.Params, c *btc.Configuration) *GroestlcoinParser {
return &GroestlcoinParser{
BitcoinParser: btc.NewBitcoinParser(params, c),
baseparser: &bchain.BaseParser{},
baseparser: &bchain.BaseParser{},
}
}

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package grs

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package koto

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package liquid

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package litecoin

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package monacoin

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package monetaryunit

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package myriad

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package namecoin

View File

@ -1,5 +1,4 @@
//go:build unittest
// +build unittest
package nuls

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package omotenashicoin

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package pivx

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package polis

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package qtum

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package ravencoin

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package ritocoin

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package snowgem

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package trezarcoin

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package unobtanium

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package vertcoin

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package viacoin

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package vipstarcoin

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package zec

View File

@ -15,6 +15,7 @@ type ZCashRPC struct {
*btc.BitcoinRPC
}
// ResGetBlockChainInfo is a response to GetChainInfo request
type ResGetBlockChainInfo struct {
Error *bchain.RPCError `json:"error"`
Result struct {
@ -72,6 +73,7 @@ func (z *ZCashRPC) Initialize() error {
return nil
}
// GetChainInfo return info about the blockchain
func (z *ZCashRPC) GetChainInfo() (*bchain.ChainInfo, error) {
chainInfo := ResGetBlockChainInfo{}
err := z.Call(&btc.CmdGetBlockChainInfo{Method: "getblockchaininfo"}, &chainInfo)

View File

@ -12,6 +12,7 @@ import (
"time"
)
// Config contains the structure of the config
type Config struct {
Coin struct {
Name string `json:"name"`
@ -108,6 +109,7 @@ func generateRPCAuth(user, pass string) (string, error) {
return out.String(), nil
}
// ParseTemplate parses the template
func (c *Config) ParseTemplate() *template.Template {
templates := map[string]string{
"IPC.RPCURLTemplate": c.IPC.RPCURLTemplate,
@ -134,6 +136,7 @@ func (c *Config) ParseTemplate() *template.Template {
return t
}
// LoadConfig loads the config files
func LoadConfig(configsDir, coin string) (*Config, error) {
config := new(Config)
@ -191,6 +194,7 @@ func isEmpty(config *Config, target string) bool {
}
}
// GeneratePackageDefinitions generate the package definitions from the config
func GeneratePackageDefinitions(config *Config, templateDir, outputDir string) error {
templ := config.ParseTemplate()
@ -276,12 +280,7 @@ func writeTemplate(path string, info os.FileInfo, templ *template.Template, conf
}
defer f.Close()
err = templ.ExecuteTemplate(f, "main", config)
if err != nil {
return err
}
return nil
return templ.ExecuteTemplate(f, "main", config)
}
func writeBackendServerConfigFile(config *Config, outputDir string) error {
@ -318,18 +317,13 @@ func writeBackendClientConfigFile(config *Config, outputDir string) error {
if config.Backend.ClientConfigFile == "" {
return nil
} else {
in, err := os.Open(filepath.Join(outputDir, "backend/config", config.Backend.ClientConfigFile))
if err != nil {
return err
}
defer in.Close()
_, err = io.Copy(out, in)
if err != nil {
return err
}
}
in, err := os.Open(filepath.Join(outputDir, "backend/config", config.Backend.ClientConfigFile))
if err != nil {
return err
}
defer in.Close()
return nil
_, err = io.Copy(out, in)
return err
}

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package common

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package db

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package db

View File

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package db

View File

@ -1,4 +1,4 @@
// +build unittest
//go:build unittest
package fiat

View File

@ -1,5 +1,4 @@
//go:build unittest
// +build unittest
package server

View File

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package server

View File

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package tests

View File

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package tests

View File

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package rpc

View File

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package sync

View File

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package sync

View File

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package sync

View File

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package sync