This commit is contained in:
Patrick O'Grady 2020-12-02 11:02:17 -06:00
parent 3c322d3fc8
commit a3c00fe9a7
No known key found for this signature in database
GPG key ID: 8DE11C985C0C8D85
11 changed files with 121 additions and 58 deletions

View file

@ -29,7 +29,6 @@ import (
bitcoinUtils "github.com/coinbase/rosetta-bitcoin/utils" bitcoinUtils "github.com/coinbase/rosetta-bitcoin/utils"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"github.com/coinbase/rosetta-sdk-go/storage"
"github.com/coinbase/rosetta-sdk-go/types" "github.com/coinbase/rosetta-sdk-go/types"
"github.com/coinbase/rosetta-sdk-go/utils" "github.com/coinbase/rosetta-sdk-go/utils"
) )
@ -246,7 +245,7 @@ func (b *Client) GetRawBlock(
func (b *Client) ParseBlock( func (b *Client) ParseBlock(
ctx context.Context, ctx context.Context,
block *Block, block *Block,
coins map[string]*storage.AccountCoin, coins map[string]*types.AccountCoin,
) (*types.Block, error) { ) (*types.Block, error) {
rblock, err := b.parseBlockData(block) rblock, err := b.parseBlockData(block)
if err != nil { if err != nil {
@ -493,7 +492,7 @@ func skipTransactionOperations(blockNumber int64, blockHash string, transactionH
func (b *Client) parseTransactions( func (b *Client) parseTransactions(
ctx context.Context, ctx context.Context,
block *Block, block *Block,
coins map[string]*storage.AccountCoin, coins map[string]*types.AccountCoin,
) ([]*types.Transaction, error) { ) ([]*types.Transaction, error) {
logger := bitcoinUtils.ExtractLogger(ctx, "client") logger := bitcoinUtils.ExtractLogger(ctx, "client")
@ -547,7 +546,7 @@ func (b *Client) parseTransactions(
continue continue
} }
coins[op.CoinChange.CoinIdentifier.Identifier] = &storage.AccountCoin{ coins[op.CoinChange.CoinIdentifier.Identifier] = &types.AccountCoin{
Coin: &types.Coin{ Coin: &types.Coin{
CoinIdentifier: op.CoinChange.CoinIdentifier, CoinIdentifier: op.CoinChange.CoinIdentifier,
Amount: op.Amount, Amount: op.Amount,
@ -565,7 +564,7 @@ func (b *Client) parseTransactions(
func (b *Client) parseTxOperations( func (b *Client) parseTxOperations(
tx *Transaction, tx *Transaction,
txIndex int, txIndex int,
coins map[string]*storage.AccountCoin, coins map[string]*types.AccountCoin,
) ([]*types.Operation, error) { ) ([]*types.Operation, error) {
txOps := []*types.Operation{} txOps := []*types.Operation{}
@ -719,7 +718,7 @@ func (b *Client) parseInputTransactionOperation(
input *Input, input *Input,
index int64, index int64,
networkIndex int64, networkIndex int64,
accountCoin *storage.AccountCoin, accountCoin *types.AccountCoin,
) (*types.Operation, error) { ) (*types.Operation, error) {
metadata, err := input.Metadata() metadata, err := input.Metadata()
if err != nil { if err != nil {

View file

@ -24,7 +24,6 @@ import (
"net/http/httptest" "net/http/httptest"
"testing" "testing"
"github.com/coinbase/rosetta-sdk-go/storage"
"github.com/coinbase/rosetta-sdk-go/types" "github.com/coinbase/rosetta-sdk-go/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
@ -708,14 +707,14 @@ func mustMarshalMap(v interface{}) map[string]interface{} {
func TestParseBlock(t *testing.T) { func TestParseBlock(t *testing.T) {
tests := map[string]struct { tests := map[string]struct {
block *Block block *Block
coins map[string]*storage.AccountCoin coins map[string]*types.AccountCoin
expectedBlock *types.Block expectedBlock *types.Block
expectedError error expectedError error
}{ }{
"no fetched transactions": { "no fetched transactions": {
block: block1000, block: block1000,
coins: map[string]*storage.AccountCoin{}, coins: map[string]*types.AccountCoin{},
expectedBlock: &types.Block{ expectedBlock: &types.Block{
BlockIdentifier: blockIdentifier1000, BlockIdentifier: blockIdentifier1000,
ParentBlockIdentifier: &types.BlockIdentifier{ ParentBlockIdentifier: &types.BlockIdentifier{
@ -865,7 +864,7 @@ func TestParseBlock(t *testing.T) {
}, },
"block 100000": { "block 100000": {
block: block100000, block: block100000,
coins: map[string]*storage.AccountCoin{ coins: map[string]*types.AccountCoin{
"87a157f3fd88ac7907c05fc55e271dc4acdc5605d187d646604ca8c0e9382e03:0": { "87a157f3fd88ac7907c05fc55e271dc4acdc5605d187d646604ca8c0e9382e03:0": {
Account: &types.AccountIdentifier{ Account: &types.AccountIdentifier{
Address: "1BNwxHGaFbeUBitpjy2AsKpJ29Ybxntqvb", Address: "1BNwxHGaFbeUBitpjy2AsKpJ29Ybxntqvb",
@ -1251,7 +1250,7 @@ func TestParseBlock(t *testing.T) {
}, },
"missing transactions": { "missing transactions": {
block: block100000, block: block100000,
coins: map[string]*storage.AccountCoin{}, coins: map[string]*types.AccountCoin{},
expectedError: errors.New("error finding previous tx"), expectedError: errors.New("error finding previous tx"),
}, },
} }

View file

@ -25,7 +25,7 @@ import (
"github.com/coinbase/rosetta-bitcoin/bitcoin" "github.com/coinbase/rosetta-bitcoin/bitcoin"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
"github.com/coinbase/rosetta-sdk-go/storage" "github.com/coinbase/rosetta-sdk-go/storage/encoder"
"github.com/coinbase/rosetta-sdk-go/types" "github.com/coinbase/rosetta-sdk-go/types"
) )
@ -121,7 +121,7 @@ type Configuration struct {
Pruning *PruningConfiguration Pruning *PruningConfiguration
IndexerPath string IndexerPath string
BitcoindPath string BitcoindPath string
Compressors []*storage.CompressorEntry Compressors []*encoder.CompressorEntry
} }
// LoadConfiguration attempts to create a new Configuration // LoadConfiguration attempts to create a new Configuration
@ -167,7 +167,7 @@ func LoadConfiguration(baseDirectory string) (*Configuration, error) {
config.Currency = bitcoin.MainnetCurrency config.Currency = bitcoin.MainnetCurrency
config.ConfigPath = mainnetConfigPath config.ConfigPath = mainnetConfigPath
config.RPCPort = mainnetRPCPort config.RPCPort = mainnetRPCPort
config.Compressors = []*storage.CompressorEntry{ config.Compressors = []*encoder.CompressorEntry{
{ {
Namespace: transactionNamespace, Namespace: transactionNamespace,
DictionaryPath: mainnetTransactionDictionary, DictionaryPath: mainnetTransactionDictionary,
@ -183,7 +183,7 @@ func LoadConfiguration(baseDirectory string) (*Configuration, error) {
config.Currency = bitcoin.TestnetCurrency config.Currency = bitcoin.TestnetCurrency
config.ConfigPath = testnetConfigPath config.ConfigPath = testnetConfigPath
config.RPCPort = testnetRPCPort config.RPCPort = testnetRPCPort
config.Compressors = []*storage.CompressorEntry{ config.Compressors = []*encoder.CompressorEntry{
{ {
Namespace: transactionNamespace, Namespace: transactionNamespace,
DictionaryPath: testnetTransactionDictionary, DictionaryPath: testnetTransactionDictionary,

View file

@ -22,7 +22,7 @@ import (
"github.com/coinbase/rosetta-bitcoin/bitcoin" "github.com/coinbase/rosetta-bitcoin/bitcoin"
"github.com/coinbase/rosetta-sdk-go/storage" "github.com/coinbase/rosetta-sdk-go/storage/encoder"
"github.com/coinbase/rosetta-sdk-go/types" "github.com/coinbase/rosetta-sdk-go/types"
"github.com/coinbase/rosetta-sdk-go/utils" "github.com/coinbase/rosetta-sdk-go/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -70,7 +70,7 @@ func TestLoadConfiguration(t *testing.T) {
Depth: pruneDepth, Depth: pruneDepth,
MinHeight: minPruneHeight, MinHeight: minPruneHeight,
}, },
Compressors: []*storage.CompressorEntry{ Compressors: []*encoder.CompressorEntry{
{ {
Namespace: transactionNamespace, Namespace: transactionNamespace,
DictionaryPath: mainnetTransactionDictionary, DictionaryPath: mainnetTransactionDictionary,
@ -99,7 +99,7 @@ func TestLoadConfiguration(t *testing.T) {
Depth: pruneDepth, Depth: pruneDepth,
MinHeight: minPruneHeight, MinHeight: minPruneHeight,
}, },
Compressors: []*storage.CompressorEntry{ Compressors: []*encoder.CompressorEntry{
{ {
Namespace: transactionNamespace, Namespace: transactionNamespace,
DictionaryPath: testnetTransactionDictionary, DictionaryPath: testnetTransactionDictionary,

3
go.mod
View file

@ -5,8 +5,9 @@ go 1.13
require ( require (
github.com/btcsuite/btcd v0.21.0-beta github.com/btcsuite/btcd v0.21.0-beta
github.com/btcsuite/btcutil v1.0.2 github.com/btcsuite/btcutil v1.0.2
github.com/coinbase/rosetta-sdk-go v0.6.1 github.com/coinbase/rosetta-sdk-go v0.6.3
github.com/dgraph-io/badger/v2 v2.2007.2 github.com/dgraph-io/badger/v2 v2.2007.2
github.com/google/addlicense v0.0.0-20200906110928-a0294312aa76 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 github.com/grpc-ecosystem/go-grpc-middleware v1.2.2
github.com/stretchr/testify v1.6.1 github.com/stretchr/testify v1.6.1
go.uber.org/zap v1.16.0 go.uber.org/zap v1.16.0

21
go.sum
View file

@ -24,6 +24,8 @@ github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8= github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8=
github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6 h1:1d9pzdbkth4D9AX6ndKSl7of3UTV0RYl3z64U2dXMGo=
github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6/go.mod h1:eSYp2T6f0apnuW8TzhV3f6Aff2SE8Dwio++U4ha4yEM=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
@ -33,12 +35,14 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5
github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ=
github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8=
github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw= github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw=
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btcd v0.21.0-beta h1:At9hIZdJW0s9E/fAz28nrz6AmcNlSVucCH796ZteX1M= github.com/btcsuite/btcd v0.21.0-beta h1:At9hIZdJW0s9E/fAz28nrz6AmcNlSVucCH796ZteX1M=
github.com/btcsuite/btcd v0.21.0-beta/go.mod h1:ZSWyehm27aAuS9bvkATT+Xte3hjHZ+MRgMY/8NJ7K94= github.com/btcsuite/btcd v0.21.0-beta/go.mod h1:ZSWyehm27aAuS9bvkATT+Xte3hjHZ+MRgMY/8NJ7K94=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
github.com/btcsuite/btcutil v0.0.0-20190207003914-4c204d697803/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/btcutil v1.0.2 h1:9iZ1Terx9fMIOtq1VrwdqfsATL9MC2l8ZrUY6YZ2uts= github.com/btcsuite/btcutil v1.0.2 h1:9iZ1Terx9fMIOtq1VrwdqfsATL9MC2l8ZrUY6YZ2uts=
github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts=
@ -64,6 +68,8 @@ github.com/cloudflare/cloudflare-go v0.10.2-0.20190916151808-a80f83b9add9/go.mod
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/coinbase/rosetta-sdk-go v0.6.1 h1:aOb5qstlX0uqP9HRC7wCY+YAZDzZbS2C/i3Qy/lR3xM= github.com/coinbase/rosetta-sdk-go v0.6.1 h1:aOb5qstlX0uqP9HRC7wCY+YAZDzZbS2C/i3Qy/lR3xM=
github.com/coinbase/rosetta-sdk-go v0.6.1/go.mod h1:t36UuaD4p2DSXaSH9IwMasZDJ7UPxt9cQi6alS5OPTo= github.com/coinbase/rosetta-sdk-go v0.6.1/go.mod h1:t36UuaD4p2DSXaSH9IwMasZDJ7UPxt9cQi6alS5OPTo=
github.com/coinbase/rosetta-sdk-go v0.6.3 h1:PPj14tPJ7SFc8sY/hlwK8zddT7PKwWU2wicxyerDxlg=
github.com/coinbase/rosetta-sdk-go v0.6.3/go.mod h1:MvQfsL2KlJ5786OdDviRIJE3agui2YcvS1CaQPDl1Yo=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
@ -134,6 +140,8 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.2-0.20200707131729-196ae77b8a26 h1:lMm2hD9Fy0ynom5+85/pbdkiYcBqM1JWmhpAXLmy0fw= github.com/golang/snappy v0.0.2-0.20200707131729-196ae77b8a26 h1:lMm2hD9Fy0ynom5+85/pbdkiYcBqM1JWmhpAXLmy0fw=
github.com/golang/snappy v0.0.2-0.20200707131729-196ae77b8a26/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.2-0.20200707131729-196ae77b8a26/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/addlicense v0.0.0-20200906110928-a0294312aa76 h1:JypWNzPMSgH5yL0NvFoAIsDRlKFgL0AsS3GO5bg4Pto=
github.com/google/addlicense v0.0.0-20200906110928-a0294312aa76/go.mod h1:EMjYTRimagHs1FwlIqKyX3wAM0u3rA+McvlIIWmSamA=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
@ -145,9 +153,11 @@ github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc=
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 h1:FlFbCRLd5Jr4iYXZufAvgWN6Ao0JrI5chLINnUXDDr0= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 h1:FlFbCRLd5Jr4iYXZufAvgWN6Ao0JrI5chLINnUXDDr0=
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI=
@ -201,6 +211,8 @@ github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8
github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0= github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0=
github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E=
github.com/neilotoole/errgroup v0.1.5 h1:DxEGoIfFm5ooGicidR+okiHjoOaGRKFaSxDPVZuuu2I=
github.com/neilotoole/errgroup v0.1.5/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C2S41udRnToE=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
@ -236,6 +248,8 @@ github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9Ac
github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubrpZHtQLnOf6EwhN2hEMusxZOhcW9H3UQ= github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubrpZHtQLnOf6EwhN2hEMusxZOhcW9H3UQ=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/segmentio/fasthash v1.0.3 h1:EI9+KE1EwvMLBWwjpRDc+fEM+prwxDYbslddQGtrmhM=
github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY=
github.com/shirou/gopsutil v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
@ -258,6 +272,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM=
@ -272,14 +287,18 @@ github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhV
github.com/tidwall/sjson v1.1.2 h1:NC5okI+tQ8OG/oyzchvwXXxRxCV/FVdhODbPKkQ25jQ= github.com/tidwall/sjson v1.1.2 h1:NC5okI+tQ8OG/oyzchvwXXxRxCV/FVdhODbPKkQ25jQ=
github.com/tidwall/sjson v1.1.2/go.mod h1:SEzaDwxiPzKzNfUEO4HbYF/m4UCSJDsGgNqsS1LvdoY= github.com/tidwall/sjson v1.1.2/go.mod h1:SEzaDwxiPzKzNfUEO4HbYF/m4UCSJDsGgNqsS1LvdoY=
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs=
github.com/tyler-smith/go-bip39 v1.0.2/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/vmihailenco/msgpack/v5 v5.0.0-beta.9 h1:iBRIniTnWOo0kqkg3k3XR8Vn6OCkVlIuZNo0UoBrKx4= github.com/vmihailenco/msgpack/v5 v5.0.0-beta.9 h1:iBRIniTnWOo0kqkg3k3XR8Vn6OCkVlIuZNo0UoBrKx4=
github.com/vmihailenco/msgpack/v5 v5.0.0-beta.9/go.mod h1:HVxBVPUK/+fZMonk4bi1islLa8V3cfnBug0+4dykPzo= github.com/vmihailenco/msgpack/v5 v5.0.0-beta.9/go.mod h1:HVxBVPUK/+fZMonk4bi1islLa8V3cfnBug0+4dykPzo=
github.com/vmihailenco/msgpack/v5 v5.1.0 h1:+od5YbEXxW95SPlW6beocmt8nOtlh83zqat5Ip9Hwdc=
github.com/vmihailenco/msgpack/v5 v5.1.0/go.mod h1:C5gboKD0TJPqWDTVTtrQNfRbiBwHZGo8UTqP/9/XvLI=
github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc= github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc=
github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees= github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk= go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk=
@ -295,6 +314,7 @@ go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
@ -347,6 +367,7 @@ golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAG
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

View file

@ -18,11 +18,12 @@ import (
"context" "context"
"github.com/coinbase/rosetta-sdk-go/parser" "github.com/coinbase/rosetta-sdk-go/parser"
"github.com/coinbase/rosetta-sdk-go/storage" "github.com/coinbase/rosetta-sdk-go/storage/database"
"github.com/coinbase/rosetta-sdk-go/storage/modules"
"github.com/coinbase/rosetta-sdk-go/types" "github.com/coinbase/rosetta-sdk-go/types"
) )
var _ storage.BalanceStorageHandler = (*BalanceStorageHandler)(nil) var _ modules.BalanceStorageHandler = (*BalanceStorageHandler)(nil)
// BalanceStorageHandler implements storage.BalanceStorageHandler. // BalanceStorageHandler implements storage.BalanceStorageHandler.
type BalanceStorageHandler struct{} type BalanceStorageHandler struct{}
@ -44,3 +45,21 @@ func (h *BalanceStorageHandler) BlockRemoved(
) error { ) error {
return nil return nil
} }
// AccountsReconciled updates the total accounts reconciled by count.
func (h *BalanceStorageHandler) AccountsReconciled(
ctx context.Context,
dbTx database.Transaction,
count int,
) error {
return nil
}
// AccountsSeen updates the total accounts seen by count.
func (h *BalanceStorageHandler) AccountsSeen(
ctx context.Context,
dbTx database.Transaction,
count int,
) error {
return nil
}

View file

@ -16,14 +16,21 @@ package indexer
import ( import (
"context" "context"
"errors"
"math/big"
"github.com/coinbase/rosetta-sdk-go/asserter" "github.com/coinbase/rosetta-sdk-go/asserter"
"github.com/coinbase/rosetta-sdk-go/parser" "github.com/coinbase/rosetta-sdk-go/parser"
"github.com/coinbase/rosetta-sdk-go/storage" "github.com/coinbase/rosetta-sdk-go/storage/database"
"github.com/coinbase/rosetta-sdk-go/storage/modules"
"github.com/coinbase/rosetta-sdk-go/types" "github.com/coinbase/rosetta-sdk-go/types"
) )
var _ storage.BalanceStorageHelper = (*BalanceStorageHelper)(nil) var _ modules.BalanceStorageHelper = (*BalanceStorageHelper)(nil)
var (
errNotImplemented = errors.New("not implemented")
)
// BalanceStorageHelper implements storage.BalanceStorageHelper. // BalanceStorageHelper implements storage.BalanceStorageHelper.
type BalanceStorageHelper struct { type BalanceStorageHelper struct {
@ -60,3 +67,19 @@ func (h *BalanceStorageHelper) ExemptFunc() parser.ExemptOperation {
return false return false
} }
} }
// AccountsReconciled returns the total accounts reconciled by count.
func (h *BalanceStorageHelper) AccountsReconciled(
ctx context.Context,
dbTx database.Transaction,
) (*big.Int, error) {
return nil, errNotImplemented
}
// AccountsSeen returns the total accounts seen by count.
func (h *BalanceStorageHelper) AccountsSeen(
ctx context.Context,
dbTx database.Transaction,
) (*big.Int, error) {
return nil, errNotImplemented
}

View file

@ -17,22 +17,23 @@ package indexer
import ( import (
"context" "context"
"github.com/coinbase/rosetta-sdk-go/storage" "github.com/coinbase/rosetta-sdk-go/storage/database"
"github.com/coinbase/rosetta-sdk-go/storage/modules"
"github.com/coinbase/rosetta-sdk-go/types" "github.com/coinbase/rosetta-sdk-go/types"
) )
var _ storage.CoinStorageHelper = (*CoinStorageHelper)(nil) var _ modules.CoinStorageHelper = (*CoinStorageHelper)(nil)
// CoinStorageHelper implements storage.CoinStorageHelper. // CoinStorageHelper implements storage.CoinStorageHelper.
type CoinStorageHelper struct { type CoinStorageHelper struct {
b *storage.BlockStorage b *modules.BlockStorage
} }
// CurrentBlockIdentifier returns the current head block identifier // CurrentBlockIdentifier returns the current head block identifier
// and is used to comply with the CoinStorageHelper interface. // and is used to comply with the CoinStorageHelper interface.
func (h *CoinStorageHelper) CurrentBlockIdentifier( func (h *CoinStorageHelper) CurrentBlockIdentifier(
ctx context.Context, ctx context.Context,
transaction storage.DatabaseTransaction, transaction database.Transaction,
) (*types.BlockIdentifier, error) { ) (*types.BlockIdentifier, error) {
return h.b.GetHeadBlockIdentifierTransactional(ctx, transaction) return h.b.GetHeadBlockIdentifierTransactional(ctx, transaction)
} }

View file

@ -26,7 +26,9 @@ import (
"github.com/coinbase/rosetta-bitcoin/utils" "github.com/coinbase/rosetta-bitcoin/utils"
"github.com/coinbase/rosetta-sdk-go/asserter" "github.com/coinbase/rosetta-sdk-go/asserter"
"github.com/coinbase/rosetta-sdk-go/storage" "github.com/coinbase/rosetta-sdk-go/storage/database"
storageErrs "github.com/coinbase/rosetta-sdk-go/storage/errors"
"github.com/coinbase/rosetta-sdk-go/storage/modules"
"github.com/coinbase/rosetta-sdk-go/syncer" "github.com/coinbase/rosetta-sdk-go/syncer"
"github.com/coinbase/rosetta-sdk-go/types" "github.com/coinbase/rosetta-sdk-go/types"
sdkUtils "github.com/coinbase/rosetta-sdk-go/utils" sdkUtils "github.com/coinbase/rosetta-sdk-go/utils"
@ -70,7 +72,7 @@ type Client interface {
ParseBlock( ParseBlock(
context.Context, context.Context,
*bitcoin.Block, *bitcoin.Block,
map[string]*storage.AccountCoin, map[string]*types.AccountCoin,
) (*types.Block, error) ) (*types.Block, error)
} }
@ -88,11 +90,11 @@ type Indexer struct {
client Client client Client
asserter *asserter.Asserter asserter *asserter.Asserter
database storage.Database database database.Database
blockStorage *storage.BlockStorage blockStorage *modules.BlockStorage
balanceStorage *storage.BalanceStorage balanceStorage *modules.BalanceStorage
coinStorage *storage.CoinStorage coinStorage *modules.CoinStorage
workers []storage.BlockWorker workers []modules.BlockWorker
waiter *waitTable waiter *waitTable
} }
@ -125,11 +127,11 @@ func defaultBadgerOptions(
opts.ValueLogLoadingMode = options.MemoryMap opts.ValueLogLoadingMode = options.MemoryMap
// Use an extended table size for larger commits. // Use an extended table size for larger commits.
opts.MaxTableSize = storage.DefaultMaxTableSize opts.MaxTableSize = database.DefaultMaxTableSize
// Smaller value log sizes means smaller contiguous memory allocations // Smaller value log sizes means smaller contiguous memory allocations
// and less RAM usage on cleanup. // and less RAM usage on cleanup.
opts.ValueLogFileSize = storage.DefaultLogValueSize opts.ValueLogFileSize = database.DefaultLogValueSize
// To allow writes at a faster speed, we create a new memtable as soon as // To allow writes at a faster speed, we create a new memtable as soon as
// an existing memtable is filled up. This option determines how many // an existing memtable is filled up. This option determines how many
@ -164,11 +166,11 @@ func Initialize(
config *configuration.Configuration, config *configuration.Configuration,
client Client, client Client,
) (*Indexer, error) { ) (*Indexer, error) {
localStore, err := storage.NewBadgerStorage( localStore, err := database.NewBadgerDatabase(
ctx, ctx,
config.IndexerPath, config.IndexerPath,
storage.WithCompressorEntries(config.Compressors), database.WithCompressorEntries(config.Compressors),
storage.WithCustomSettings(defaultBadgerOptions( database.WithCustomSettings(defaultBadgerOptions(
config.IndexerPath, config.IndexerPath,
)), )),
) )
@ -176,7 +178,7 @@ func Initialize(
return nil, fmt.Errorf("%w: unable to initialize storage", err) return nil, fmt.Errorf("%w: unable to initialize storage", err)
} }
blockStorage := storage.NewBlockStorage(localStore) blockStorage := modules.NewBlockStorage(localStore)
asserter, err := asserter.NewClientWithOptions( asserter, err := asserter.NewClientWithOptions(
config.Network, config.Network,
config.GenesisBlockIdentifier, config.GenesisBlockIdentifier,
@ -200,21 +202,21 @@ func Initialize(
asserter: asserter, asserter: asserter,
} }
coinStorage := storage.NewCoinStorage( coinStorage := modules.NewCoinStorage(
localStore, localStore,
&CoinStorageHelper{blockStorage}, &CoinStorageHelper{blockStorage},
asserter, asserter,
) )
i.coinStorage = coinStorage i.coinStorage = coinStorage
balanceStorage := storage.NewBalanceStorage(localStore) balanceStorage := modules.NewBalanceStorage(localStore)
balanceStorage.Initialize( balanceStorage.Initialize(
&BalanceStorageHelper{asserter}, &BalanceStorageHelper{asserter},
&BalanceStorageHandler{}, &BalanceStorageHandler{},
) )
i.balanceStorage = balanceStorage i.balanceStorage = balanceStorage
i.workers = []storage.BlockWorker{coinStorage, balanceStorage} i.workers = []modules.BlockWorker{coinStorage, balanceStorage}
return i, nil return i, nil
} }
@ -422,14 +424,14 @@ func (i *Indexer) findCoin(
coinIdentifier string, coinIdentifier string,
) (*types.Coin, *types.AccountIdentifier, error) { ) (*types.Coin, *types.AccountIdentifier, error) {
for ctx.Err() == nil { for ctx.Err() == nil {
databaseTransaction := i.database.NewDatabaseTransaction(ctx, false) databaseTransaction := i.database.ReadTransaction(ctx)
defer databaseTransaction.Discard(ctx) defer databaseTransaction.Discard(ctx)
coinHeadBlock, err := i.blockStorage.GetHeadBlockIdentifierTransactional( coinHeadBlock, err := i.blockStorage.GetHeadBlockIdentifierTransactional(
ctx, ctx,
databaseTransaction, databaseTransaction,
) )
if errors.Is(err, storage.ErrHeadBlockNotFound) { if errors.Is(err, storageErrs.ErrHeadBlockNotFound) {
if err := sdkUtils.ContextSleep(ctx, missingTransactionDelay); err != nil { if err := sdkUtils.ContextSleep(ctx, missingTransactionDelay); err != nil {
return nil, nil, err return nil, nil, err
} }
@ -455,7 +457,7 @@ func (i *Indexer) findCoin(
return coin, owner, nil return coin, owner, nil
} }
if !errors.Is(err, storage.ErrCoinNotFound) { if !errors.Is(err, storageErrs.ErrCoinNotFound) {
return nil, nil, fmt.Errorf("%w: unable to lookup coin %s", err, coinIdentifier) return nil, nil, fmt.Errorf("%w: unable to lookup coin %s", err, coinIdentifier)
} }
@ -506,7 +508,7 @@ func (i *Indexer) checkHeaderMatch(
btcBlock *bitcoin.Block, btcBlock *bitcoin.Block,
) error { ) error {
headBlock, err := i.blockStorage.GetHeadBlockIdentifier(ctx) headBlock, err := i.blockStorage.GetHeadBlockIdentifier(ctx)
if err != nil && !errors.Is(err, storage.ErrHeadBlockNotFound) { if err != nil && !errors.Is(err, storageErrs.ErrHeadBlockNotFound) {
return fmt.Errorf("%w: unable to lookup head block", err) return fmt.Errorf("%w: unable to lookup head block", err)
} }
@ -525,12 +527,12 @@ func (i *Indexer) findCoins(
ctx context.Context, ctx context.Context,
btcBlock *bitcoin.Block, btcBlock *bitcoin.Block,
coins []string, coins []string,
) (map[string]*storage.AccountCoin, error) { ) (map[string]*types.AccountCoin, error) {
if err := i.checkHeaderMatch(ctx, btcBlock); err != nil { if err := i.checkHeaderMatch(ctx, btcBlock); err != nil {
return nil, fmt.Errorf("%w: check header match failed", err) return nil, fmt.Errorf("%w: check header match failed", err)
} }
coinMap := map[string]*storage.AccountCoin{} coinMap := map[string]*types.AccountCoin{}
remainingCoins := []string{} remainingCoins := []string{}
for _, coinIdentifier := range coins { for _, coinIdentifier := range coins {
coin, owner, err := i.findCoin( coin, owner, err := i.findCoin(
@ -539,7 +541,7 @@ func (i *Indexer) findCoins(
coinIdentifier, coinIdentifier,
) )
if err == nil { if err == nil {
coinMap[coinIdentifier] = &storage.AccountCoin{ coinMap[coinIdentifier] = &types.AccountCoin{
Account: owner, Account: owner,
Coin: coin, Coin: coin,
} }
@ -673,7 +675,7 @@ func (i *Indexer) GetScriptPubKeys(
ctx context.Context, ctx context.Context,
coins []*types.Coin, coins []*types.Coin,
) ([]*bitcoin.ScriptPubKey, error) { ) ([]*bitcoin.ScriptPubKey, error) {
databaseTransaction := i.database.NewDatabaseTransaction(ctx, false) databaseTransaction := i.database.ReadTransaction(ctx)
defer databaseTransaction.Discard(ctx) defer databaseTransaction.Discard(ctx)
scripts := make([]*bitcoin.ScriptPubKey, len(coins)) scripts := make([]*bitcoin.ScriptPubKey, len(coins))
@ -786,7 +788,7 @@ func (i *Indexer) GetBalance(
currency *types.Currency, currency *types.Currency,
blockIdentifier *types.PartialBlockIdentifier, blockIdentifier *types.PartialBlockIdentifier,
) (*types.Amount, *types.BlockIdentifier, error) { ) (*types.Amount, *types.BlockIdentifier, error) {
dbTx := i.database.NewDatabaseTransaction(ctx, false) dbTx := i.database.ReadTransaction(ctx)
defer dbTx.Discard(ctx) defer dbTx.Discard(ctx)
blockResponse, err := i.blockStorage.GetBlockLazyTransactional( blockResponse, err := i.blockStorage.GetBlockLazyTransactional(
@ -805,7 +807,7 @@ func (i *Indexer) GetBalance(
currency, currency,
blockResponse.Block.BlockIdentifier.Index, blockResponse.Block.BlockIdentifier.Index,
) )
if errors.Is(err, storage.ErrAccountMissing) { if errors.Is(err, storageErrs.ErrAccountMissing) {
return &types.Amount{ return &types.Amount{
Value: zeroValue, Value: zeroValue,
Currency: currency, Currency: currency,

View file

@ -9,8 +9,6 @@ import (
mock "github.com/stretchr/testify/mock" mock "github.com/stretchr/testify/mock"
storage "github.com/coinbase/rosetta-sdk-go/storage"
types "github.com/coinbase/rosetta-sdk-go/types" types "github.com/coinbase/rosetta-sdk-go/types"
) )
@ -75,11 +73,11 @@ func (_m *Client) NetworkStatus(_a0 context.Context) (*types.NetworkStatusRespon
} }
// ParseBlock provides a mock function with given fields: _a0, _a1, _a2 // ParseBlock provides a mock function with given fields: _a0, _a1, _a2
func (_m *Client) ParseBlock(_a0 context.Context, _a1 *bitcoin.Block, _a2 map[string]*storage.AccountCoin) (*types.Block, error) { func (_m *Client) ParseBlock(_a0 context.Context, _a1 *bitcoin.Block, _a2 map[string]*types.AccountCoin) (*types.Block, error) {
ret := _m.Called(_a0, _a1, _a2) ret := _m.Called(_a0, _a1, _a2)
var r0 *types.Block var r0 *types.Block
if rf, ok := ret.Get(0).(func(context.Context, *bitcoin.Block, map[string]*storage.AccountCoin) *types.Block); ok { if rf, ok := ret.Get(0).(func(context.Context, *bitcoin.Block, map[string]*types.AccountCoin) *types.Block); ok {
r0 = rf(_a0, _a1, _a2) r0 = rf(_a0, _a1, _a2)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
@ -88,7 +86,7 @@ func (_m *Client) ParseBlock(_a0 context.Context, _a1 *bitcoin.Block, _a2 map[st
} }
var r1 error var r1 error
if rf, ok := ret.Get(1).(func(context.Context, *bitcoin.Block, map[string]*storage.AccountCoin) error); ok { if rf, ok := ret.Get(1).(func(context.Context, *bitcoin.Block, map[string]*types.AccountCoin) error); ok {
r1 = rf(_a0, _a1, _a2) r1 = rf(_a0, _a1, _a2)
} else { } else {
r1 = ret.Error(1) r1 = ret.Error(1)