Fix formatting/linting errors

pull/187/head^2
Martin Boehm 2019-04-16 15:18:54 +02:00
parent b348a53664
commit 0312db4d9d
16 changed files with 44 additions and 13 deletions

View File

@ -1101,7 +1101,7 @@ func (w *Worker) GetMempool(page int, itemsOnPage int) (*MempoolTxids, error) {
page = 0
}
entries := w.mempool.GetAllEntries()
pg, from, to, page := computePaging(len(entries), page, itemsOnPage)
pg, from, to, _ := computePaging(len(entries), page, itemsOnPage)
r := &MempoolTxids{
Paging: pg,
MempoolSize: len(entries),

View File

@ -7,11 +7,13 @@ import (
"github.com/martinboehm/btcutil/chaincfg"
)
// magic numbers
const (
MainnetMagic wire.BitcoinNet = 0xbebacefa
TestnetMagic wire.BitcoinNet = 0x0709110b
)
// chain parameters
var (
MainNetParams chaincfg.Params
TestNetParams chaincfg.Params

View File

@ -10,10 +10,12 @@ import (
"github.com/martinboehm/btcutil/chaincfg"
)
// magic numbers
const (
MainnetMagic wire.BitcoinNet = 0xc0c0c0c0
)
// chain parameters
var (
MainNetParams chaincfg.Params
)

View File

@ -7,12 +7,14 @@ import (
"github.com/martinboehm/btcutil/chaincfg"
)
// magic numbers
const (
MainnetMagic wire.BitcoinNet = 0xdbb6c0fb
TestnetMagic wire.BitcoinNet = 0x0709110b
RegtestMagic wire.BitcoinNet = 0xdab5bffa
)
// chain parameters
var (
MainNetParams chaincfg.Params
TestNetParams chaincfg.Params

View File

@ -9,11 +9,13 @@ import (
"github.com/martinboehm/btcutil/chaincfg"
)
// magic numbers
const (
MainnetMagic wire.BitcoinNet = 0xd4b4bef9
TestnetMagic wire.BitcoinNet = 0x0709110b
)
// chain parameters
var (
MainNetParams chaincfg.Params
TestNetParams chaincfg.Params

View File

@ -9,10 +9,12 @@ import (
"github.com/juju/errors"
)
// GroestlcoinRPC is an interface to JSON-RPC service
type GroestlcoinRPC struct {
*btc.BitcoinRPC
}
// NewGroestlcoinRPC returns new GroestlcoinRPC instance
func NewGroestlcoinRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) {
b, err := btc.NewBitcoinRPC(config, pushHandler)
if err != nil {

View File

@ -7,12 +7,14 @@ import (
"github.com/martinboehm/btcutil/chaincfg"
)
// magic numbers
const (
MainnetMagic wire.BitcoinNet = 0xdbb6c0fb
TestnetMagic wire.BitcoinNet = 0xf1c8d2fd
RegtestMagic wire.BitcoinNet = 0xdab5bffa
)
// chain parameters
var (
MainNetParams chaincfg.Params
TestNetParams chaincfg.Params

View File

@ -6,19 +6,22 @@ import (
"bytes"
"encoding/binary"
"encoding/json"
"github.com/bsm/go-vlq"
vlq "github.com/bsm/go-vlq"
"github.com/martinboehm/btcutil/base58"
"github.com/martinboehm/btcd/wire"
"github.com/martinboehm/btcutil/chaincfg"
)
// magic numbers
const (
MainnetMagic wire.BitcoinNet = 0xbd6b0cbf
TestnetMagic wire.BitcoinNet = 0xffcae2ce
RegtestMagic wire.BitcoinNet = 0xdcb7c1fc
)
// chain parameters
var (
MainNetParams chaincfg.Params
TestNetParams chaincfg.Params
@ -140,6 +143,7 @@ func (p *NulsParser) UnpackTx(buf []byte) (*bchain.Tx, uint32, error) {
return tx, height, nil
}
// ParseTx parses tx from blob
func (p *NulsParser) ParseTx(b []byte) (*bchain.Tx, error) {
tx := bchain.Tx{}
err := json.Unmarshal(b, &tx)

View File

@ -21,7 +21,7 @@ import (
"github.com/golang/glog"
)
// NulsRPC is an interface to JSON-RPC bitcoind service.
// NulsRPC is an interface to JSON-RPC bitcoind service
type NulsRPC struct {
*btc.BitcoinRPC
client http.Client
@ -30,7 +30,7 @@ type NulsRPC struct {
password string
}
// NewNulsRPC returns new NulsRPC instance.
// NewNulsRPC returns new NulsRPC instance
func NewNulsRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) {
b, err := btc.NewBitcoinRPC(config, pushHandler)
if err != nil {
@ -101,7 +101,7 @@ type CmdGetVersionInfo struct {
MyVersion string `json:"myVersion"`
NewestVersion string `json:"newestVersion"`
NetworkVersion int `json:"networkVersion"`
Infromation string `json:"infromation"`
Information string `json:"information"`
} `json:"data"`
}
@ -227,7 +227,7 @@ func (n *NulsRPC) GetChainInfo() (*bchain.ChainInfo, error) {
Subversion: versionInfo.Data.NewestVersion,
ProtocolVersion: strconv.Itoa(versionInfo.Data.NetworkVersion),
Timeoffset: 0,
Warnings: versionInfo.Data.Infromation,
Warnings: versionInfo.Data.Information,
}
return chainInfo, nil
}
@ -414,7 +414,8 @@ func (n *NulsRPC) GetTransaction(txid string) (*bchain.Tx, error) {
}
blockHeaderHeight := getTx.Tx.BlockHeight
blockHeader, e := n.GetBlockHeaderByHeight(uint32(blockHeaderHeight))
// shouldn't it check the error here?
blockHeader, _ := n.GetBlockHeaderByHeight(uint32(blockHeaderHeight))
if blockHeader != nil {
tx.Blocktime = blockHeader.Time
}

View File

@ -2,16 +2,19 @@ package polis
import (
"blockbook/bchain/coins/btc"
"github.com/martinboehm/btcd/wire"
"github.com/martinboehm/btcutil/chaincfg"
)
// magic numbers
const (
MainnetMagic wire.BitcoinNet = 0xbd6b0cbf
TestnetMagic wire.BitcoinNet = 0xffcae2ce
RegtestMagic wire.BitcoinNet = 0xdcb7c1fc
)
// chain parameters
var (
MainNetParams chaincfg.Params
TestNetParams chaincfg.Params

View File

@ -3,21 +3,20 @@
package polis
import (
"bytes"
"fmt"
"blockbook/bchain"
"blockbook/bchain/coins/btc"
"bytes"
"encoding/hex"
"fmt"
"github.com/martinboehm/btcutil/chaincfg"
"io/ioutil"
"math/big"
"os"
"path/filepath"
"reflect"
"testing"
"github.com/martinboehm/btcutil/chaincfg"
)
type testBlock struct {
size int
time int64

View File

@ -12,11 +12,13 @@ import (
"github.com/martinboehm/btcutil/chaincfg"
)
// magic numbers
const (
MainnetMagic wire.BitcoinNet = 0xf1cfa6d3
TestnetMagic wire.BitcoinNet = 0x0d221506
)
// chain parameters
var (
MainNetParams chaincfg.Params
TestNetParams chaincfg.Params

View File

@ -7,12 +7,14 @@ import (
"github.com/martinboehm/btcutil/chaincfg"
)
// magic numbers
const (
MainnetMagic wire.BitcoinNet = 0xdab5bffb
TestnetMagic wire.BitcoinNet = 0x74726576 // "vert" word
RegtestMagic wire.BitcoinNet = 0xdab5bffc
)
// chain parameters
var (
MainNetParams chaincfg.Params
TestNetParams chaincfg.Params

View File

@ -8,6 +8,7 @@ import (
"github.com/golang/glog"
)
// Txids, Xpubs and Addresses
const (
TxidB1T1 = "00b2c06055e5e90e9c82bd4181fde310104391a7fa4f289b1704e5d90caa3840"
TxidB1T2 = "effd9ef509383d536b1c8af5bf434c8efbf521a4f2befd4022bbd68694b4ac75"
@ -30,6 +31,7 @@ const (
AddrA = "mzVznVsCHkVHX9UN8WPFASWUUHtxnNn4Jj" // 76a914d03c0d863d189b23b061a95ad32940b65837609f88ac
)
// Amounts in satoshis
var (
SatZero = big.NewInt(0)
SatB1T1A1 = big.NewInt(100000000)
@ -45,6 +47,7 @@ var (
SatB2T4AA = big.NewInt(1360030331)
)
// AddressToPubKeyHex is a utility conversion function
func AddressToPubKeyHex(addr string, parser bchain.BlockChainParser) string {
if addr == "" {
return ""
@ -56,6 +59,7 @@ func AddressToPubKeyHex(addr string, parser bchain.BlockChainParser) string {
return hex.EncodeToString(b)
}
// GetTestBitcoinTypeBlock1 returns block #1
func GetTestBitcoinTypeBlock1(parser bchain.BlockChainParser) *bchain.Block {
return &bchain.Block{
BlockHeader: bchain.BlockHeader{
@ -122,6 +126,7 @@ func GetTestBitcoinTypeBlock1(parser bchain.BlockChainParser) *bchain.Block {
}
}
// GetTestBitcoinTypeBlock2 returns block #2
func GetTestBitcoinTypeBlock2(parser bchain.BlockChainParser) *bchain.Block {
return &bchain.Block{
BlockHeader: bchain.BlockHeader{

View File

@ -5,6 +5,7 @@ import (
"encoding/hex"
)
// Addresses
const (
EthAddr3e = "3e3a3d69dc66ba10737f531ed088954a9ec89d97"
EthAddr55 = "555ee11fbddc0e49a9bab358a8941ad95ffdb48f"
@ -42,6 +43,7 @@ func unpackTxs(packed []string, parser bchain.BlockChainParser) []bchain.Tx {
return r
}
// GetTestEthereumTypeBlock1 returns block #1
func GetTestEthereumTypeBlock1(parser bchain.BlockChainParser) *bchain.Block {
return &bchain.Block{
BlockHeader: bchain.BlockHeader{
@ -55,6 +57,7 @@ func GetTestEthereumTypeBlock1(parser bchain.BlockChainParser) *bchain.Block {
}
}
// GetTestEthereumTypeBlock2 returns block #2
func GetTestEthereumTypeBlock2(parser bchain.BlockChainParser) *bchain.Block {
return &bchain.Block{
BlockHeader: bchain.BlockHeader{

View File

@ -17,7 +17,7 @@ func NewFakeBlockChain(parser bchain.BlockChainParser) (bchain.BlockChain, error
return &fakeBlockChain{&bchain.BaseChain{Parser: parser}}, nil
}
func (b *fakeBlockChain) CreateMempool(chain bchain.BlockChain) (bchain.Mempool, error) {
func (c *fakeBlockChain) CreateMempool(chain bchain.BlockChain) (bchain.Mempool, error) {
return bchain.NewMempoolBitcoinType(chain, 1, 1), nil
}
@ -189,6 +189,6 @@ func (c *fakeBlockChain) GetChainParser() bchain.BlockChainParser {
}
// GetMempoolTransactions returns transactions in mempool
func (b *fakeBlockChain) GetMempoolTransactions() ([]string, error) {
func (c *fakeBlockChain) GetMempoolTransactions() ([]string, error) {
return nil, errors.New("Not implemented")
}