Fix coding style and formatting issues
parent
e83511469b
commit
499d65460f
|
@ -36,6 +36,7 @@ import (
|
|||
|
||||
type blockChainFactory func(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error)
|
||||
|
||||
// BlockChainFactories is a map of constructors of coin RPC interfaces
|
||||
var BlockChainFactories = make(map[string]blockChainFactory)
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -857,6 +857,7 @@ func safeDecodeResponse(body io.ReadCloser, res interface{}) (err error) {
|
|||
return json.Unmarshal(data, &res)
|
||||
}
|
||||
|
||||
// Call calls Backend RPC interface, using RPCMarshaler interface to marshall the request
|
||||
func (b *BitcoinRPC) Call(req interface{}, res interface{}) error {
|
||||
httpData, err := b.RPCMarshaler.Marshal(req)
|
||||
if err != nil {
|
||||
|
|
|
@ -6,12 +6,15 @@ import (
|
|||
"reflect"
|
||||
)
|
||||
|
||||
// RPCMarshaler is used for marshalling requests to Bitcoin Type RPC interfaces
|
||||
type RPCMarshaler interface {
|
||||
Marshal(v interface{}) ([]byte, error)
|
||||
}
|
||||
|
||||
// JSONMarshalerV2 is used for marshalling requests to newer Bitcoin Type RPC interfaces
|
||||
type JSONMarshalerV2 struct{}
|
||||
|
||||
// Marshal converts struct passed by parameter to JSON
|
||||
func (JSONMarshalerV2) Marshal(v interface{}) ([]byte, error) {
|
||||
d, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
|
@ -20,10 +23,13 @@ func (JSONMarshalerV2) Marshal(v interface{}) ([]byte, error) {
|
|||
return d, nil
|
||||
}
|
||||
|
||||
var InvalidValue = errors.New("Invalid value to marshal")
|
||||
// ErrInvalidValue is error returned by JSONMarshalerV1.Marshal if the passed structure contains invalid value
|
||||
var ErrInvalidValue = errors.New("Invalid value to marshal")
|
||||
|
||||
// JSONMarshalerV1 is used for marshalling requests to legacy Bitcoin Type RPC interfaces
|
||||
type JSONMarshalerV1 struct{}
|
||||
|
||||
// Marshal converts struct passed by parameter to JSON
|
||||
func (JSONMarshalerV1) Marshal(v interface{}) ([]byte, error) {
|
||||
u := cmdUntypedParams{}
|
||||
|
||||
|
@ -50,7 +56,7 @@ func (JSONMarshalerV1) Marshal(v interface{}) ([]byte, error) {
|
|||
|
||||
f := v.FieldByName("Method")
|
||||
if !f.IsValid() || f.Kind() != reflect.String {
|
||||
return nil, InvalidValue
|
||||
return nil, ErrInvalidValue
|
||||
}
|
||||
u.Method = f.String()
|
||||
|
||||
|
@ -69,7 +75,7 @@ func (JSONMarshalerV1) Marshal(v interface{}) ([]byte, error) {
|
|||
arr[i] = f.Field(i).Interface()
|
||||
}
|
||||
default:
|
||||
return nil, InvalidValue
|
||||
return nil, ErrInvalidValue
|
||||
}
|
||||
u.Params = arr
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ type testBlock struct {
|
|||
}
|
||||
|
||||
var testParseBlockTxs = map[int]testBlock{
|
||||
104000: testBlock{
|
||||
104000: {
|
||||
size: 15776,
|
||||
time: 1295705889,
|
||||
txs: []string{
|
||||
|
@ -81,7 +81,7 @@ var testParseBlockTxs = map[int]testBlock{
|
|||
"33ad36d79d63b575c7532c516f16b19541f5c637caf7073beb7ddf604c3f39cc",
|
||||
},
|
||||
},
|
||||
532144: testBlock{
|
||||
532144: {
|
||||
size: 12198,
|
||||
time: 1528372417,
|
||||
txs: []string{
|
||||
|
|
|
@ -276,7 +276,7 @@ type testBlock struct {
|
|||
|
||||
var testParseBlockTxs = map[int]testBlock{
|
||||
// block without auxpow
|
||||
12345: testBlock{
|
||||
12345: {
|
||||
size: 8582,
|
||||
time: 1387104223,
|
||||
txs: []string{
|
||||
|
@ -314,7 +314,7 @@ var testParseBlockTxs = map[int]testBlock{
|
|||
},
|
||||
},
|
||||
// 1st block with auxpow
|
||||
371337: testBlock{
|
||||
371337: {
|
||||
size: 1704,
|
||||
time: 1410464577,
|
||||
txs: []string{
|
||||
|
@ -327,7 +327,7 @@ var testParseBlockTxs = map[int]testBlock{
|
|||
},
|
||||
},
|
||||
// block with auxpow
|
||||
567890: testBlock{
|
||||
567890: {
|
||||
size: 3833,
|
||||
time: 1422855443,
|
||||
txs: []string{
|
||||
|
@ -343,7 +343,7 @@ var testParseBlockTxs = map[int]testBlock{
|
|||
},
|
||||
},
|
||||
// recent block
|
||||
2264125: testBlock{
|
||||
2264125: {
|
||||
size: 8531,
|
||||
time: 1529099968,
|
||||
txs: []string{
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestErc20_erc20GetTransfersFromLog(t *testing.T) {
|
|||
{
|
||||
name: "1",
|
||||
args: []*rpcLog{
|
||||
&rpcLog{
|
||||
{
|
||||
Address: "0x76a45e8976499ab9ae223cc584019341d5a84e96",
|
||||
Topics: []string{
|
||||
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
|
||||
|
@ -43,7 +43,7 @@ func TestErc20_erc20GetTransfersFromLog(t *testing.T) {
|
|||
{
|
||||
name: "2",
|
||||
args: []*rpcLog{
|
||||
&rpcLog{ // Transfer
|
||||
{ // Transfer
|
||||
Address: "0x0d0f936ee4c93e25944694d6c121de94d9760f11",
|
||||
Topics: []string{
|
||||
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
|
||||
|
@ -52,7 +52,7 @@ func TestErc20_erc20GetTransfersFromLog(t *testing.T) {
|
|||
},
|
||||
Data: "0x0000000000000000000000000000000000000000000000006a8313d60b1f606b",
|
||||
},
|
||||
&rpcLog{ // Transfer
|
||||
{ // Transfer
|
||||
Address: "0xc778417e063141139fce010982780140aa0cd5ab",
|
||||
Topics: []string{
|
||||
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
|
||||
|
@ -61,7 +61,7 @@ func TestErc20_erc20GetTransfersFromLog(t *testing.T) {
|
|||
},
|
||||
Data: "0x000000000000000000000000000000000000000000000000000308fd0e798ac0",
|
||||
},
|
||||
&rpcLog{ // not Transfer
|
||||
{ // not Transfer
|
||||
Address: "0x479cc461fecd078f766ecc58533d6f69580cf3ac",
|
||||
Topics: []string{
|
||||
"0x0d0b9391970d9a25552f37d436d2aae2925e2bfe1b2a923754bada030c498cb3",
|
||||
|
@ -71,7 +71,7 @@ func TestErc20_erc20GetTransfersFromLog(t *testing.T) {
|
|||
},
|
||||
Data: "0x0000000000000000000000004bda106325c335df99eab7fe363cac8a0ba2a24d0000000000000",
|
||||
},
|
||||
&rpcLog{ // not Transfer
|
||||
{ // not Transfer
|
||||
Address: "0x0d0f936ee4c93e25944694d6c121de94d9760f11",
|
||||
Topics: []string{
|
||||
"0x0d0b9391970d9a25552f37d436d2aae2925e2bfe1b2a923754bada030c498cb3",
|
||||
|
|
|
@ -142,7 +142,7 @@ func init() {
|
|||
GasUsed: "0xcb39",
|
||||
Status: "0x1",
|
||||
Logs: []*rpcLog{
|
||||
&rpcLog{
|
||||
{
|
||||
Address: "0x4af4114f73d1c1c903ac9e0361b379d1291808a2",
|
||||
Data: "0x00000000000000000000000000000000000000000000021e19e0c9bab2400000",
|
||||
Topics: []string{
|
||||
|
|
|
@ -507,6 +507,9 @@ func (b *EthereumRPC) GetBlockInfo(hash string) (*bchain.BlockInfo, error) {
|
|||
return nil, err
|
||||
}
|
||||
bch, err := b.ethHeaderToBlockHeader(&head)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &bchain.BlockInfo{
|
||||
BlockHeader: *bch,
|
||||
Difficulty: json.Number(head.Difficulty),
|
||||
|
|
|
@ -29,8 +29,7 @@ func init() {
|
|||
Time: 1525189571,
|
||||
Txid: "97f944e3558cc784f4013b3753ce9570fe4707893eda724b12eb4c69686113a6",
|
||||
LockTime: 0,
|
||||
Vin: []bchain.Vin{
|
||||
},
|
||||
Vin: []bchain.Vin{},
|
||||
Vout: []bchain.Vout{
|
||||
{
|
||||
ValueSat: *big.NewInt(9800018691),
|
||||
|
|
|
@ -69,7 +69,7 @@ type testBlock struct {
|
|||
}
|
||||
|
||||
var testParseBlockTxs = map[int]testBlock{
|
||||
40000: testBlock{
|
||||
40000: {
|
||||
size: 1385,
|
||||
time: 1327728573,
|
||||
txs: []string{
|
||||
|
|
|
@ -11,11 +11,12 @@ import (
|
|||
"encoding/json"
|
||||
|
||||
"math/big"
|
||||
|
||||
"github.com/martinboehm/btcd/blockchain"
|
||||
|
||||
"github.com/juju/errors"
|
||||
"github.com/martinboehm/btcd/wire"
|
||||
"github.com/martinboehm/btcutil/chaincfg"
|
||||
"github.com/juju/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -37,7 +38,7 @@ func init() {
|
|||
// PivXParser handle
|
||||
type PivXParser struct {
|
||||
*btc.BitcoinParser
|
||||
baseparser *bchain.BaseParser
|
||||
baseparser *bchain.BaseParser
|
||||
BitcoinOutputScriptToAddressesFunc btc.OutputScriptToAddressesFunc
|
||||
}
|
||||
|
||||
|
@ -73,9 +74,9 @@ func (p *PivXParser) ParseBlock(b []byte) (*bchain.Block, error) {
|
|||
return nil, errors.Annotatef(err, "Deserialize")
|
||||
}
|
||||
|
||||
if (h.Version > 3) {
|
||||
if h.Version > 3 {
|
||||
// Skip past AccumulatorCheckpoint which was added in pivx block version 4
|
||||
_, err = r.Seek(32, io.SeekCurrent)
|
||||
r.Seek(32, io.SeekCurrent)
|
||||
}
|
||||
|
||||
err = utils.DecodeTransactions(r, 0, wire.WitnessEncoding, &w)
|
||||
|
@ -125,7 +126,7 @@ func (p *PivXParser) TxFromMsgTx(t *wire.MsgTx, parseAddresses bool) bchain.Tx {
|
|||
for i, in := range t.TxIn {
|
||||
|
||||
// extra check to not confuse Tx with single OP_ZEROCOINSPEND input as a coinbase Tx
|
||||
if (!isZeroCoinSpendScript(in.SignatureScript) && blockchain.IsCoinBaseTx(t)) {
|
||||
if !isZeroCoinSpendScript(in.SignatureScript) && blockchain.IsCoinBaseTx(t) {
|
||||
vin[i] = bchain.Vin{
|
||||
Coinbase: hex.EncodeToString(in.SignatureScript),
|
||||
Sequence: in.Sequence,
|
||||
|
@ -198,7 +199,7 @@ func (p *PivXParser) ParseTxFromJson(msg json.RawMessage) (*bchain.Tx, error) {
|
|||
}
|
||||
vout.JsonValue = ""
|
||||
|
||||
if(vout.ScriptPubKey.Addresses == nil) {
|
||||
if vout.ScriptPubKey.Addresses == nil {
|
||||
vout.ScriptPubKey.Addresses = []string{}
|
||||
}
|
||||
}
|
||||
|
@ -206,16 +207,15 @@ func (p *PivXParser) ParseTxFromJson(msg json.RawMessage) (*bchain.Tx, error) {
|
|||
return &tx, nil
|
||||
}
|
||||
|
||||
|
||||
// outputScriptToAddresses converts ScriptPubKey to bitcoin addresses
|
||||
func (p *PivXParser) outputScriptToAddresses(script []byte) ([]string, bool, error) {
|
||||
if (isZeroCoinSpendScript(script) || isZeroCoinMintScript(script)) {
|
||||
if isZeroCoinSpendScript(script) || isZeroCoinMintScript(script) {
|
||||
hexScript := hex.EncodeToString(script)
|
||||
anonAddr := "Anonymous " + hexScript
|
||||
return []string{anonAddr}, false, nil
|
||||
}
|
||||
|
||||
rv, s, _ := p.BitcoinOutputScriptToAddressesFunc(script)
|
||||
rv, s, _ := p.BitcoinOutputScriptToAddressesFunc(script)
|
||||
return rv, s, nil
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ func (p *PivXParser) GetAddrDescForUnknownInput(tx *bchain.Tx, input int) bchain
|
|||
if len(tx.Vin) > input {
|
||||
scriptHex := tx.Vin[input].ScriptSig.Hex
|
||||
|
||||
if(scriptHex != "") {
|
||||
if scriptHex != "" {
|
||||
script, _ := hex.DecodeString(scriptHex)
|
||||
return script
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ func (p *PivXParser) GetAddrDescForUnknownInput(tx *bchain.Tx, input int) bchain
|
|||
func isZeroCoinMintScript(signatureScript []byte) bool {
|
||||
OP_ZEROCOINMINT := byte(0xc1)
|
||||
|
||||
if (len(signatureScript) > 1 && signatureScript[0] == OP_ZEROCOINMINT) {
|
||||
if len(signatureScript) > 1 && signatureScript[0] == OP_ZEROCOINMINT {
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ func isZeroCoinMintScript(signatureScript []byte) bool {
|
|||
func isZeroCoinSpendScript(signatureScript []byte) bool {
|
||||
OP_ZEROCOINSPEND := byte(0xc2)
|
||||
|
||||
if (len(signatureScript) >= 100 && signatureScript[0] == OP_ZEROCOINSPEND) {
|
||||
if len(signatureScript) >= 100 && signatureScript[0] == OP_ZEROCOINSPEND {
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
// Metrics holds prometheus collectors for various metrics collected by Blockbook
|
||||
type Metrics struct {
|
||||
SocketIORequests *prometheus.CounterVec
|
||||
SocketIOSubscribes *prometheus.CounterVec
|
||||
|
@ -28,8 +29,10 @@ type Metrics struct {
|
|||
BlockbookAppInfo *prometheus.GaugeVec
|
||||
}
|
||||
|
||||
// Labels represents a collection of label name -> value mappings.
|
||||
type Labels = prometheus.Labels
|
||||
|
||||
// GetMetrics returns struct holding prometheus collectors for various metrics collected by Blockbook
|
||||
func GetMetrics(coin string) (*Metrics, error) {
|
||||
metrics := Metrics{}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ var (
|
|||
buildtime = "unknown"
|
||||
)
|
||||
|
||||
// VersionInfo holds information about the running Blockbook instance
|
||||
type VersionInfo struct {
|
||||
Version string `json:"version"`
|
||||
GitCommit string `json:"gitcommit"`
|
||||
|
@ -16,6 +17,7 @@ type VersionInfo struct {
|
|||
OSArch string `json:"os/arch"`
|
||||
}
|
||||
|
||||
// GetVersionInfo returns VersionInfo of the running Blockbook instance
|
||||
func GetVersionInfo() VersionInfo {
|
||||
return VersionInfo{
|
||||
Version: version,
|
||||
|
|
|
@ -22,7 +22,7 @@ func ethereumTestnetParser() *eth.EthereumParser {
|
|||
|
||||
func verifyAfterEthereumTypeBlock1(t *testing.T, d *RocksDB, afterDisconnect bool) {
|
||||
if err := checkColumn(d, cfHeight, []keyPair{
|
||||
keyPair{
|
||||
{
|
||||
"0041eee8",
|
||||
"c7b98df95acfd11c51ba25611a39e004fe56c8fdfc1582af99354fcd09c17b11" + uintToHex(1534858022) + varuintToHex(2) + varuintToHex(31839),
|
||||
nil,
|
||||
|
@ -33,10 +33,10 @@ func verifyAfterEthereumTypeBlock1(t *testing.T, d *RocksDB, afterDisconnect boo
|
|||
}
|
||||
}
|
||||
if err := checkColumn(d, cfAddresses, []keyPair{
|
||||
keyPair{addressKeyHex(dbtestdata.EthAddr3e, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T1, []int32{^0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.EthAddr55, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T2, []int32{1}) + txIndexesHex(dbtestdata.EthTxidB1T1, []int32{0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.EthAddr20, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T2, []int32{^0, ^1}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.EthAddrContract4a, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T2, []int32{0}), nil},
|
||||
{addressKeyHex(dbtestdata.EthAddr3e, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T1, []int32{^0}), nil},
|
||||
{addressKeyHex(dbtestdata.EthAddr55, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T2, []int32{1}) + txIndexesHex(dbtestdata.EthTxidB1T1, []int32{0}), nil},
|
||||
{addressKeyHex(dbtestdata.EthAddr20, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T2, []int32{^0, ^1}), nil},
|
||||
{addressKeyHex(dbtestdata.EthAddrContract4a, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T2, []int32{0}), nil},
|
||||
}); err != nil {
|
||||
{
|
||||
t.Fatal(err)
|
||||
|
@ -44,10 +44,10 @@ func verifyAfterEthereumTypeBlock1(t *testing.T, d *RocksDB, afterDisconnect boo
|
|||
}
|
||||
|
||||
if err := checkColumn(d, cfAddressContracts, []keyPair{
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr3e, d.chainParser), "0101", nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr55, d.chainParser), "0201" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser) + "01", nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr20, d.chainParser), "0101" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser) + "01", nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser), "0101", nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr3e, d.chainParser), "0101", nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr55, d.chainParser), "0201" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser) + "01", nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr20, d.chainParser), "0101" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser) + "01", nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser), "0101", nil},
|
||||
}); err != nil {
|
||||
{
|
||||
t.Fatal(err)
|
||||
|
@ -59,7 +59,7 @@ func verifyAfterEthereumTypeBlock1(t *testing.T, d *RocksDB, afterDisconnect boo
|
|||
blockTxsKp = []keyPair{}
|
||||
} else {
|
||||
blockTxsKp = []keyPair{
|
||||
keyPair{
|
||||
{
|
||||
"0041eee8",
|
||||
dbtestdata.EthTxidB1T1 +
|
||||
dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr3e, d.chainParser) + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr55, d.chainParser) + "00" +
|
||||
|
@ -81,12 +81,12 @@ func verifyAfterEthereumTypeBlock1(t *testing.T, d *RocksDB, afterDisconnect boo
|
|||
|
||||
func verifyAfterEthereumTypeBlock2(t *testing.T, d *RocksDB) {
|
||||
if err := checkColumn(d, cfHeight, []keyPair{
|
||||
keyPair{
|
||||
{
|
||||
"0041eee8",
|
||||
"c7b98df95acfd11c51ba25611a39e004fe56c8fdfc1582af99354fcd09c17b11" + uintToHex(1534858022) + varuintToHex(2) + varuintToHex(31839),
|
||||
nil,
|
||||
},
|
||||
keyPair{
|
||||
{
|
||||
"0041eee9",
|
||||
"2b57e15e93a0ed197417a34c2498b7187df79099572c04a6b6e6ff418f74e6ee" + uintToHex(1534859988) + varuintToHex(2) + varuintToHex(2345678),
|
||||
nil,
|
||||
|
@ -97,15 +97,15 @@ func verifyAfterEthereumTypeBlock2(t *testing.T, d *RocksDB) {
|
|||
}
|
||||
}
|
||||
if err := checkColumn(d, cfAddresses, []keyPair{
|
||||
keyPair{addressKeyHex(dbtestdata.EthAddr3e, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T1, []int32{^0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.EthAddr55, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T2, []int32{1}) + txIndexesHex(dbtestdata.EthTxidB1T1, []int32{0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.EthAddr20, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T2, []int32{^0, ^1}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.EthAddrContract4a, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T2, []int32{0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.EthAddr55, 4321001, d), txIndexesHex(dbtestdata.EthTxidB2T2, []int32{^2, 1}) + txIndexesHex(dbtestdata.EthTxidB2T1, []int32{^0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.EthAddr9f, 4321001, d), txIndexesHex(dbtestdata.EthTxidB2T1, []int32{0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.EthAddr4b, 4321001, d), txIndexesHex(dbtestdata.EthTxidB2T2, []int32{^0, 1, ^2, 2, ^1}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.EthAddr7b, 4321001, d), txIndexesHex(dbtestdata.EthTxidB2T2, []int32{^1, 2}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.EthAddrContract47, 4321001, d), txIndexesHex(dbtestdata.EthTxidB2T2, []int32{0}), nil},
|
||||
{addressKeyHex(dbtestdata.EthAddr3e, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T1, []int32{^0}), nil},
|
||||
{addressKeyHex(dbtestdata.EthAddr55, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T2, []int32{1}) + txIndexesHex(dbtestdata.EthTxidB1T1, []int32{0}), nil},
|
||||
{addressKeyHex(dbtestdata.EthAddr20, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T2, []int32{^0, ^1}), nil},
|
||||
{addressKeyHex(dbtestdata.EthAddrContract4a, 4321000, d), txIndexesHex(dbtestdata.EthTxidB1T2, []int32{0}), nil},
|
||||
{addressKeyHex(dbtestdata.EthAddr55, 4321001, d), txIndexesHex(dbtestdata.EthTxidB2T2, []int32{^2, 1}) + txIndexesHex(dbtestdata.EthTxidB2T1, []int32{^0}), nil},
|
||||
{addressKeyHex(dbtestdata.EthAddr9f, 4321001, d), txIndexesHex(dbtestdata.EthTxidB2T1, []int32{0}), nil},
|
||||
{addressKeyHex(dbtestdata.EthAddr4b, 4321001, d), txIndexesHex(dbtestdata.EthTxidB2T2, []int32{^0, 1, ^2, 2, ^1}), nil},
|
||||
{addressKeyHex(dbtestdata.EthAddr7b, 4321001, d), txIndexesHex(dbtestdata.EthTxidB2T2, []int32{^1, 2}), nil},
|
||||
{addressKeyHex(dbtestdata.EthAddrContract47, 4321001, d), txIndexesHex(dbtestdata.EthTxidB2T2, []int32{0}), nil},
|
||||
}); err != nil {
|
||||
{
|
||||
t.Fatal(err)
|
||||
|
@ -113,14 +113,14 @@ func verifyAfterEthereumTypeBlock2(t *testing.T, d *RocksDB) {
|
|||
}
|
||||
|
||||
if err := checkColumn(d, cfAddressContracts, []keyPair{
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr3e, d.chainParser), "0101", nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr55, d.chainParser), "0402" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser) + "02" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract0d, d.chainParser) + "01", nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr20, d.chainParser), "0101" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser) + "01", nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser), "0101", nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr9f, d.chainParser), "0101", nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr4b, d.chainParser), "0101" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract0d, d.chainParser) + "02" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser) + "02", nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr7b, d.chainParser), "0100" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser) + "01" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract0d, d.chainParser) + "01", nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract47, d.chainParser), "0101", nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr3e, d.chainParser), "0101", nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr55, d.chainParser), "0402" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser) + "02" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract0d, d.chainParser) + "01", nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr20, d.chainParser), "0101" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser) + "01", nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser), "0101", nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr9f, d.chainParser), "0101", nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr4b, d.chainParser), "0101" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract0d, d.chainParser) + "02" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser) + "02", nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr7b, d.chainParser), "0100" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract4a, d.chainParser) + "01" + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract0d, d.chainParser) + "01", nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddrContract47, d.chainParser), "0101", nil},
|
||||
}); err != nil {
|
||||
{
|
||||
t.Fatal(err)
|
||||
|
@ -128,7 +128,7 @@ func verifyAfterEthereumTypeBlock2(t *testing.T, d *RocksDB) {
|
|||
}
|
||||
|
||||
if err := checkColumn(d, cfBlockTxs, []keyPair{
|
||||
keyPair{
|
||||
{
|
||||
"0041eee9",
|
||||
dbtestdata.EthTxidB2T1 +
|
||||
dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr55, d.chainParser) + dbtestdata.AddressToPubKeyHex(dbtestdata.EthAddr9f, d.chainParser) + "00" +
|
||||
|
@ -249,7 +249,7 @@ func TestRocksDB_Index_EthereumType(t *testing.T) {
|
|||
// check that there is only the last tx in the cache
|
||||
packedTx, err := d.chainParser.PackTx(&block2.Txs[1], block2.Height, block2.Txs[1].Blocktime)
|
||||
if err := checkColumn(d, cfTransactions, []keyPair{
|
||||
keyPair{dbtestdata.EthTxidB2T2, hex.EncodeToString(packedTx), nil},
|
||||
{dbtestdata.EthTxidB2T2, hex.EncodeToString(packedTx), nil},
|
||||
}); err != nil {
|
||||
{
|
||||
t.Fatal(err)
|
||||
|
|
|
@ -173,7 +173,7 @@ func checkColumn(d *RocksDB, col int, kp []keyPair) error {
|
|||
|
||||
func verifyAfterBitcoinTypeBlock1(t *testing.T, d *RocksDB, afterDisconnect bool) {
|
||||
if err := checkColumn(d, cfHeight, []keyPair{
|
||||
keyPair{
|
||||
{
|
||||
"000370d5",
|
||||
"0000000076fbbed90fd75b0e18856aa35baa984e9c9d444cf746ad85e94e2997" + uintToHex(1534858021) + varuintToHex(2) + varuintToHex(1234567),
|
||||
nil,
|
||||
|
@ -185,18 +185,18 @@ func verifyAfterBitcoinTypeBlock1(t *testing.T, d *RocksDB, afterDisconnect bool
|
|||
}
|
||||
// the vout is encoded as signed varint, i.e. value * 2 for non negative values
|
||||
if err := checkColumn(d, cfAddresses, []keyPair{
|
||||
keyPair{addressKeyHex(dbtestdata.Addr1, 225493, d), txIndexesHex(dbtestdata.TxidB1T1, []int32{0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr2, 225493, d), txIndexesHex(dbtestdata.TxidB1T1, []int32{1}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr3, 225493, d), txIndexesHex(dbtestdata.TxidB1T2, []int32{0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr4, 225493, d), txIndexesHex(dbtestdata.TxidB1T2, []int32{1}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr5, 225493, d), txIndexesHex(dbtestdata.TxidB1T2, []int32{2}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr1, 225493, d), txIndexesHex(dbtestdata.TxidB1T1, []int32{0}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr2, 225493, d), txIndexesHex(dbtestdata.TxidB1T1, []int32{1}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr3, 225493, d), txIndexesHex(dbtestdata.TxidB1T2, []int32{0}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr4, 225493, d), txIndexesHex(dbtestdata.TxidB1T2, []int32{1}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr5, 225493, d), txIndexesHex(dbtestdata.TxidB1T2, []int32{2}), nil},
|
||||
}); err != nil {
|
||||
{
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := checkColumn(d, cfTxAddresses, []keyPair{
|
||||
keyPair{
|
||||
{
|
||||
dbtestdata.TxidB1T1,
|
||||
varuintToHex(225493) +
|
||||
"00" +
|
||||
|
@ -205,7 +205,7 @@ func verifyAfterBitcoinTypeBlock1(t *testing.T, d *RocksDB, afterDisconnect bool
|
|||
addressToPubKeyHexWithLength(dbtestdata.Addr2, t, d) + bigintToHex(dbtestdata.SatB1T1A2),
|
||||
nil,
|
||||
},
|
||||
keyPair{
|
||||
{
|
||||
dbtestdata.TxidB1T2,
|
||||
varuintToHex(225493) +
|
||||
"00" +
|
||||
|
@ -221,11 +221,11 @@ func verifyAfterBitcoinTypeBlock1(t *testing.T, d *RocksDB, afterDisconnect bool
|
|||
}
|
||||
}
|
||||
if err := checkColumn(d, cfAddressBalance, []keyPair{
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr1, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB1T1A1), nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr2, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB1T1A2), nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr3, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB1T2A3), nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr4, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB1T2A4), nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr5, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB1T2A5), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr1, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB1T1A1), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr2, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB1T1A2), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr3, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB1T2A3), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr4, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB1T2A4), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr5, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB1T2A5), nil},
|
||||
}); err != nil {
|
||||
{
|
||||
t.Fatal(err)
|
||||
|
@ -237,7 +237,7 @@ func verifyAfterBitcoinTypeBlock1(t *testing.T, d *RocksDB, afterDisconnect bool
|
|||
blockTxsKp = []keyPair{}
|
||||
} else {
|
||||
blockTxsKp = []keyPair{
|
||||
keyPair{
|
||||
{
|
||||
"000370d5",
|
||||
dbtestdata.TxidB1T1 + "00" + dbtestdata.TxidB1T2 + "00",
|
||||
nil,
|
||||
|
@ -254,12 +254,12 @@ func verifyAfterBitcoinTypeBlock1(t *testing.T, d *RocksDB, afterDisconnect bool
|
|||
|
||||
func verifyAfterBitcoinTypeBlock2(t *testing.T, d *RocksDB) {
|
||||
if err := checkColumn(d, cfHeight, []keyPair{
|
||||
keyPair{
|
||||
{
|
||||
"000370d5",
|
||||
"0000000076fbbed90fd75b0e18856aa35baa984e9c9d444cf746ad85e94e2997" + uintToHex(1534858021) + varuintToHex(2) + varuintToHex(1234567),
|
||||
nil,
|
||||
},
|
||||
keyPair{
|
||||
{
|
||||
"000370d6",
|
||||
"00000000eb0443fd7dc4a1ed5c686a8e995057805f9a161d9a5a77a95e72b7b6" + uintToHex(1534859123) + varuintToHex(4) + varuintToHex(2345678),
|
||||
nil,
|
||||
|
@ -270,27 +270,27 @@ func verifyAfterBitcoinTypeBlock2(t *testing.T, d *RocksDB) {
|
|||
}
|
||||
}
|
||||
if err := checkColumn(d, cfAddresses, []keyPair{
|
||||
keyPair{addressKeyHex(dbtestdata.Addr1, 225493, d), txIndexesHex(dbtestdata.TxidB1T1, []int32{0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr2, 225493, d), txIndexesHex(dbtestdata.TxidB1T1, []int32{1}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr3, 225493, d), txIndexesHex(dbtestdata.TxidB1T2, []int32{0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr4, 225493, d), txIndexesHex(dbtestdata.TxidB1T2, []int32{1}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr5, 225493, d), txIndexesHex(dbtestdata.TxidB1T2, []int32{2}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr6, 225494, d), txIndexesHex(dbtestdata.TxidB2T2, []int32{^0}) + txIndexesHex(dbtestdata.TxidB2T1, []int32{0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr7, 225494, d), txIndexesHex(dbtestdata.TxidB2T1, []int32{1}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr8, 225494, d), txIndexesHex(dbtestdata.TxidB2T2, []int32{0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr9, 225494, d), txIndexesHex(dbtestdata.TxidB2T2, []int32{1}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr3, 225494, d), txIndexesHex(dbtestdata.TxidB2T1, []int32{^0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr2, 225494, d), txIndexesHex(dbtestdata.TxidB2T1, []int32{^1}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr5, 225494, d), txIndexesHex(dbtestdata.TxidB2T3, []int32{0, ^0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.AddrA, 225494, d), txIndexesHex(dbtestdata.TxidB2T4, []int32{0}), nil},
|
||||
keyPair{addressKeyHex(dbtestdata.Addr4, 225494, d), txIndexesHex(dbtestdata.TxidB2T2, []int32{^1}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr1, 225493, d), txIndexesHex(dbtestdata.TxidB1T1, []int32{0}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr2, 225493, d), txIndexesHex(dbtestdata.TxidB1T1, []int32{1}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr3, 225493, d), txIndexesHex(dbtestdata.TxidB1T2, []int32{0}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr4, 225493, d), txIndexesHex(dbtestdata.TxidB1T2, []int32{1}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr5, 225493, d), txIndexesHex(dbtestdata.TxidB1T2, []int32{2}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr6, 225494, d), txIndexesHex(dbtestdata.TxidB2T2, []int32{^0}) + txIndexesHex(dbtestdata.TxidB2T1, []int32{0}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr7, 225494, d), txIndexesHex(dbtestdata.TxidB2T1, []int32{1}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr8, 225494, d), txIndexesHex(dbtestdata.TxidB2T2, []int32{0}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr9, 225494, d), txIndexesHex(dbtestdata.TxidB2T2, []int32{1}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr3, 225494, d), txIndexesHex(dbtestdata.TxidB2T1, []int32{^0}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr2, 225494, d), txIndexesHex(dbtestdata.TxidB2T1, []int32{^1}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr5, 225494, d), txIndexesHex(dbtestdata.TxidB2T3, []int32{0, ^0}), nil},
|
||||
{addressKeyHex(dbtestdata.AddrA, 225494, d), txIndexesHex(dbtestdata.TxidB2T4, []int32{0}), nil},
|
||||
{addressKeyHex(dbtestdata.Addr4, 225494, d), txIndexesHex(dbtestdata.TxidB2T2, []int32{^1}), nil},
|
||||
}); err != nil {
|
||||
{
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := checkColumn(d, cfTxAddresses, []keyPair{
|
||||
keyPair{
|
||||
{
|
||||
dbtestdata.TxidB1T1,
|
||||
varuintToHex(225493) +
|
||||
"00" +
|
||||
|
@ -299,7 +299,7 @@ func verifyAfterBitcoinTypeBlock2(t *testing.T, d *RocksDB) {
|
|||
spentAddressToPubKeyHexWithLength(dbtestdata.Addr2, t, d) + bigintToHex(dbtestdata.SatB1T1A2),
|
||||
nil,
|
||||
},
|
||||
keyPair{
|
||||
{
|
||||
dbtestdata.TxidB1T2,
|
||||
varuintToHex(225493) +
|
||||
"00" +
|
||||
|
@ -309,7 +309,7 @@ func verifyAfterBitcoinTypeBlock2(t *testing.T, d *RocksDB) {
|
|||
spentAddressToPubKeyHexWithLength(dbtestdata.Addr5, t, d) + bigintToHex(dbtestdata.SatB1T2A5),
|
||||
nil,
|
||||
},
|
||||
keyPair{
|
||||
{
|
||||
dbtestdata.TxidB2T1,
|
||||
varuintToHex(225494) +
|
||||
"02" +
|
||||
|
@ -320,7 +320,7 @@ func verifyAfterBitcoinTypeBlock2(t *testing.T, d *RocksDB) {
|
|||
addressToPubKeyHexWithLength(dbtestdata.Addr7, t, d) + bigintToHex(dbtestdata.SatB2T1A7),
|
||||
nil,
|
||||
},
|
||||
keyPair{
|
||||
{
|
||||
dbtestdata.TxidB2T2,
|
||||
varuintToHex(225494) +
|
||||
"02" +
|
||||
|
@ -331,7 +331,7 @@ func verifyAfterBitcoinTypeBlock2(t *testing.T, d *RocksDB) {
|
|||
addressToPubKeyHexWithLength(dbtestdata.Addr9, t, d) + bigintToHex(dbtestdata.SatB2T2A9),
|
||||
nil,
|
||||
},
|
||||
keyPair{
|
||||
{
|
||||
dbtestdata.TxidB2T3,
|
||||
varuintToHex(225494) +
|
||||
"01" +
|
||||
|
@ -340,7 +340,7 @@ func verifyAfterBitcoinTypeBlock2(t *testing.T, d *RocksDB) {
|
|||
addressToPubKeyHexWithLength(dbtestdata.Addr5, t, d) + bigintToHex(dbtestdata.SatB2T3A5),
|
||||
nil,
|
||||
},
|
||||
keyPair{
|
||||
{
|
||||
dbtestdata.TxidB2T4,
|
||||
varuintToHex(225494) +
|
||||
"01" + inputAddressToPubKeyHexWithLength("", t, d) + bigintToHex(dbtestdata.SatZero) +
|
||||
|
@ -355,23 +355,23 @@ func verifyAfterBitcoinTypeBlock2(t *testing.T, d *RocksDB) {
|
|||
}
|
||||
}
|
||||
if err := checkColumn(d, cfAddressBalance, []keyPair{
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr1, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB1T1A1), nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr2, d.chainParser), "02" + bigintToHex(dbtestdata.SatB1T1A2) + bigintToHex(dbtestdata.SatZero), nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr3, d.chainParser), "02" + bigintToHex(dbtestdata.SatB1T2A3) + bigintToHex(dbtestdata.SatZero), nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr4, d.chainParser), "02" + bigintToHex(dbtestdata.SatB1T2A4) + bigintToHex(dbtestdata.SatZero), nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr5, d.chainParser), "02" + bigintToHex(dbtestdata.SatB1T2A5) + bigintToHex(dbtestdata.SatB2T3A5), nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr6, d.chainParser), "02" + bigintToHex(dbtestdata.SatB2T1A6) + bigintToHex(dbtestdata.SatZero), nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr7, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB2T1A7), nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr8, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB2T2A8), nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr9, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB2T2A9), nil},
|
||||
keyPair{dbtestdata.AddressToPubKeyHex(dbtestdata.AddrA, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB2T4AA), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr1, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB1T1A1), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr2, d.chainParser), "02" + bigintToHex(dbtestdata.SatB1T1A2) + bigintToHex(dbtestdata.SatZero), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr3, d.chainParser), "02" + bigintToHex(dbtestdata.SatB1T2A3) + bigintToHex(dbtestdata.SatZero), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr4, d.chainParser), "02" + bigintToHex(dbtestdata.SatB1T2A4) + bigintToHex(dbtestdata.SatZero), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr5, d.chainParser), "02" + bigintToHex(dbtestdata.SatB1T2A5) + bigintToHex(dbtestdata.SatB2T3A5), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr6, d.chainParser), "02" + bigintToHex(dbtestdata.SatB2T1A6) + bigintToHex(dbtestdata.SatZero), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr7, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB2T1A7), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr8, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB2T2A8), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.Addr9, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB2T2A9), nil},
|
||||
{dbtestdata.AddressToPubKeyHex(dbtestdata.AddrA, d.chainParser), "01" + bigintToHex(dbtestdata.SatZero) + bigintToHex(dbtestdata.SatB2T4AA), nil},
|
||||
}); err != nil {
|
||||
{
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := checkColumn(d, cfBlockTxs, []keyPair{
|
||||
keyPair{
|
||||
{
|
||||
"000370d6",
|
||||
dbtestdata.TxidB2T1 + "02" + dbtestdata.TxidB1T2 + "00" + dbtestdata.TxidB1T1 + "02" +
|
||||
dbtestdata.TxidB2T2 + "02" + dbtestdata.TxidB2T1 + "00" + dbtestdata.TxidB1T2 + "02" +
|
||||
|
@ -541,7 +541,7 @@ func TestRocksDB_Index_BitcoinType(t *testing.T) {
|
|||
// check that there is only the last tx in the cache
|
||||
packedTx, err := d.chainParser.PackTx(&block2.Txs[1], block2.Height, block2.Txs[1].Blocktime)
|
||||
if err := checkColumn(d, cfTransactions, []keyPair{
|
||||
keyPair{block2.Txs[1].Txid, hex.EncodeToString(packedTx), nil},
|
||||
{block2.Txs[1].Txid, hex.EncodeToString(packedTx), nil},
|
||||
}); err != nil {
|
||||
{
|
||||
t.Fatal(err)
|
||||
|
|
|
@ -64,18 +64,18 @@ func GetTestBitcoinTypeBlock1(parser bchain.BlockChainParser) *bchain.Block {
|
|||
Confirmations: 2,
|
||||
},
|
||||
Txs: []bchain.Tx{
|
||||
bchain.Tx{
|
||||
{
|
||||
Txid: TxidB1T1,
|
||||
Vin: []bchain.Vin{},
|
||||
Vout: []bchain.Vout{
|
||||
bchain.Vout{
|
||||
{
|
||||
N: 0,
|
||||
ScriptPubKey: bchain.ScriptPubKey{
|
||||
Hex: AddressToPubKeyHex(Addr1, parser),
|
||||
},
|
||||
ValueSat: *SatB1T1A1,
|
||||
},
|
||||
bchain.Vout{
|
||||
{
|
||||
N: 1,
|
||||
ScriptPubKey: bchain.ScriptPubKey{
|
||||
Hex: AddressToPubKeyHex(Addr2, parser),
|
||||
|
@ -87,24 +87,24 @@ func GetTestBitcoinTypeBlock1(parser bchain.BlockChainParser) *bchain.Block {
|
|||
Time: 22549300000,
|
||||
Confirmations: 2,
|
||||
},
|
||||
bchain.Tx{
|
||||
{
|
||||
Txid: TxidB1T2,
|
||||
Vout: []bchain.Vout{
|
||||
bchain.Vout{
|
||||
{
|
||||
N: 0,
|
||||
ScriptPubKey: bchain.ScriptPubKey{
|
||||
Hex: AddressToPubKeyHex(Addr3, parser),
|
||||
},
|
||||
ValueSat: *SatB1T2A3,
|
||||
},
|
||||
bchain.Vout{
|
||||
{
|
||||
N: 1,
|
||||
ScriptPubKey: bchain.ScriptPubKey{
|
||||
Hex: AddressToPubKeyHex(Addr4, parser),
|
||||
},
|
||||
ValueSat: *SatB1T2A4,
|
||||
},
|
||||
bchain.Vout{
|
||||
{
|
||||
N: 2,
|
||||
ScriptPubKey: bchain.ScriptPubKey{
|
||||
Hex: AddressToPubKeyHex(Addr5, parser),
|
||||
|
@ -130,29 +130,29 @@ func GetTestBitcoinTypeBlock2(parser bchain.BlockChainParser) *bchain.Block {
|
|||
Confirmations: 1,
|
||||
},
|
||||
Txs: []bchain.Tx{
|
||||
bchain.Tx{
|
||||
{
|
||||
Txid: TxidB2T1,
|
||||
Vin: []bchain.Vin{
|
||||
// addr3
|
||||
bchain.Vin{
|
||||
{
|
||||
Txid: TxidB1T2,
|
||||
Vout: 0,
|
||||
},
|
||||
// addr2
|
||||
bchain.Vin{
|
||||
{
|
||||
Txid: TxidB1T1,
|
||||
Vout: 1,
|
||||
},
|
||||
},
|
||||
Vout: []bchain.Vout{
|
||||
bchain.Vout{
|
||||
{
|
||||
N: 0,
|
||||
ScriptPubKey: bchain.ScriptPubKey{
|
||||
Hex: AddressToPubKeyHex(Addr6, parser),
|
||||
},
|
||||
ValueSat: *SatB2T1A6,
|
||||
},
|
||||
bchain.Vout{
|
||||
{
|
||||
N: 1,
|
||||
ScriptPubKey: bchain.ScriptPubKey{
|
||||
Hex: AddressToPubKeyHex(Addr7, parser),
|
||||
|
@ -164,29 +164,29 @@ func GetTestBitcoinTypeBlock2(parser bchain.BlockChainParser) *bchain.Block {
|
|||
Time: 22549400000,
|
||||
Confirmations: 1,
|
||||
},
|
||||
bchain.Tx{
|
||||
{
|
||||
Txid: TxidB2T2,
|
||||
Vin: []bchain.Vin{
|
||||
// spending an output in the same block - addr6
|
||||
bchain.Vin{
|
||||
{
|
||||
Txid: TxidB2T1,
|
||||
Vout: 0,
|
||||
},
|
||||
// spending an output in the previous block - addr4
|
||||
bchain.Vin{
|
||||
{
|
||||
Txid: TxidB1T2,
|
||||
Vout: 1,
|
||||
},
|
||||
},
|
||||
Vout: []bchain.Vout{
|
||||
bchain.Vout{
|
||||
{
|
||||
N: 0,
|
||||
ScriptPubKey: bchain.ScriptPubKey{
|
||||
Hex: AddressToPubKeyHex(Addr8, parser),
|
||||
},
|
||||
ValueSat: *SatB2T2A8,
|
||||
},
|
||||
bchain.Vout{
|
||||
{
|
||||
N: 1,
|
||||
ScriptPubKey: bchain.ScriptPubKey{
|
||||
Hex: AddressToPubKeyHex(Addr9, parser),
|
||||
|
@ -199,17 +199,17 @@ func GetTestBitcoinTypeBlock2(parser bchain.BlockChainParser) *bchain.Block {
|
|||
Confirmations: 1,
|
||||
},
|
||||
// transaction from the same address in the previous block
|
||||
bchain.Tx{
|
||||
{
|
||||
Txid: TxidB2T3,
|
||||
Vin: []bchain.Vin{
|
||||
// addr5
|
||||
bchain.Vin{
|
||||
{
|
||||
Txid: TxidB1T2,
|
||||
Vout: 2,
|
||||
},
|
||||
},
|
||||
Vout: []bchain.Vout{
|
||||
bchain.Vout{
|
||||
{
|
||||
N: 0,
|
||||
ScriptPubKey: bchain.ScriptPubKey{
|
||||
Hex: AddressToPubKeyHex(Addr5, parser),
|
||||
|
@ -222,22 +222,22 @@ func GetTestBitcoinTypeBlock2(parser bchain.BlockChainParser) *bchain.Block {
|
|||
Confirmations: 1,
|
||||
},
|
||||
// mining transaction
|
||||
bchain.Tx{
|
||||
{
|
||||
Txid: TxidB2T4,
|
||||
Vin: []bchain.Vin{
|
||||
bchain.Vin{
|
||||
{
|
||||
Coinbase: "03bf1e1504aede765b726567696f6e312f50726f6a65637420425443506f6f6c2f01000001bf7e000000000000",
|
||||
},
|
||||
},
|
||||
Vout: []bchain.Vout{
|
||||
bchain.Vout{
|
||||
{
|
||||
N: 0,
|
||||
ScriptPubKey: bchain.ScriptPubKey{
|
||||
Hex: AddressToPubKeyHex(AddrA, parser),
|
||||
},
|
||||
ValueSat: *SatB2T4AA,
|
||||
},
|
||||
bchain.Vout{
|
||||
{
|
||||
N: 1,
|
||||
ScriptPubKey: bchain.ScriptPubKey{},
|
||||
ValueSat: *SatZero,
|
||||
|
|
|
@ -12,7 +12,8 @@ type fakeBlockChain struct {
|
|||
*bchain.BaseChain
|
||||
}
|
||||
|
||||
func NewFakeBlockChain(parser bchain.BlockChainParser) (*fakeBlockChain, error) {
|
||||
// NewFakeBlockChain returns mocked blockchain RPC interface used for tests
|
||||
func NewFakeBlockChain(parser bchain.BlockChainParser) (bchain.BlockChain, error) {
|
||||
return &fakeBlockChain{&bchain.BaseChain{Parser: parser}}, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue