From 27faa31c7a78192bc36ea0df0a17323187db77e3 Mon Sep 17 00:00:00 2001 From: Patrick O'Grady Date: Fri, 13 Nov 2020 11:29:02 -0800 Subject: [PATCH] Fix statuses --- bitcoin/client.go | 12 ++++-------- indexer/indexer.go | 2 +- indexer/indexer_test.go | 3 +-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/bitcoin/client.go b/bitcoin/client.go index a3b768f..203c60b 100644 --- a/bitcoin/client.go +++ b/bitcoin/client.go @@ -516,9 +516,8 @@ func (b *Client) parseTransactions( "block hash", block.Hash, "transaction hash", transaction.Hash, ) - status := SuccessStatus for _, op := range txOps { - op.Status = &status + op.Status = types.String(SkippedStatus) } } @@ -675,14 +674,13 @@ func (b *Client) parseOutputTransactionOperation( coinChange = nil } - status := SuccessStatus return &types.Operation{ OperationIdentifier: &types.OperationIdentifier{ Index: index, NetworkIndex: &networkIndex, }, Type: OutputOpType, - Status: &status, + Status: types.String(SuccessStatus), Account: account, Amount: &types.Amount{ Value: strconv.FormatInt(int64(amount), 10), @@ -733,14 +731,13 @@ func (b *Client) parseInputTransactionOperation( return nil, fmt.Errorf("%w: unable to negate previous output", err) } - status := SuccessStatus return &types.Operation{ OperationIdentifier: &types.OperationIdentifier{ Index: index, NetworkIndex: &networkIndex, }, Type: InputOpType, - Status: &status, + Status: types.String(SuccessStatus), Account: accountCoin.Account, Amount: &types.Amount{ Value: newValue, @@ -796,14 +793,13 @@ func (b *Client) coinbaseTxOperation( return nil, fmt.Errorf("%w: unable to get input metadata", err) } - status := SuccessStatus return &types.Operation{ OperationIdentifier: &types.OperationIdentifier{ Index: index, NetworkIndex: &networkIndex, }, Type: CoinbaseOpType, - Status: &status, + Status: types.String(SuccessStatus), Metadata: metadata, }, nil } diff --git a/indexer/indexer.go b/indexer/indexer.go index 1f50002..794789f 100644 --- a/indexer/indexer.go +++ b/indexer/indexer.go @@ -255,7 +255,7 @@ func (i *Indexer) Sync(ctx context.Context) error { // If previously processed blocks exist in storage, they are fetched. // Otherwise, none are provided to the cache (the syncer will not attempt // a reorg if the cache is empty). - pastBlocks := i.blockStorage.CreateBlockCache(ctx, int(head.Index)) + pastBlocks := i.blockStorage.CreateBlockCache(ctx, syncer.DefaultPastBlockLimit) syncer := syncer.New( i.network, diff --git a/indexer/indexer_test.go b/indexer/indexer_test.go index 5ea8b4a..79e3244 100644 --- a/indexer/indexer_test.go +++ b/indexer/indexer_test.go @@ -487,7 +487,6 @@ func TestIndexer_Reorg(t *testing.T) { } transactions := []*types.Transaction{} - status := bitcoin.SuccessStatus for j := 0; j < 5; j++ { rawHash := fmt.Sprintf("block %d transaction %d", i, j) hash := fmt.Sprintf("%x", sha256.Sum256([]byte(rawHash))) @@ -507,7 +506,7 @@ func TestIndexer_Reorg(t *testing.T) { Index: 0, NetworkIndex: &index0, }, - Status: &status, + Status: types.String(bitcoin.SuccessStatus), Type: bitcoin.OutputOpType, Account: &types.AccountIdentifier{ Address: rawHash,