Skip to content

Commit

Permalink
Add TzKT types
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Aug 29, 2022
1 parent 74532e7 commit e2990bb
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 6 deletions.
6 changes: 6 additions & 0 deletions cmd/mempool/block_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ func (bq *BlockQueue) ExpirationLevel(hash string) uint64 {
}
return 0
}

// Contains -
func (bq *BlockQueue) Contains(hash string) bool {
_, ok := bq.levels[hash]
return ok
}
5 changes: 2 additions & 3 deletions cmd/mempool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"io/ioutil"
"os"
"os/signal"
"strings"
Expand Down Expand Up @@ -159,7 +158,7 @@ func main() {
}

func createViews(ctx context.Context, database libCfg.Database) ([]string, error) {
files, err := ioutil.ReadDir("views")
files, err := os.ReadDir("views")
if err != nil {
return nil, err
}
Expand All @@ -177,7 +176,7 @@ func createViews(ctx context.Context, database libCfg.Database) ([]string, error
}

path := fmt.Sprintf("views/%s", files[i].Name())
raw, err := ioutil.ReadFile(path)
raw, err := os.ReadFile(path)
if err != nil {
return nil, err
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/mempool/tzkt/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ var toNodeKinds = map[string]string{
data.KindTxRollupRejection: node.KindTxRollupRejection,
data.KindTxRollupRemoveCommitment: node.KindTxRollupRemoveCommitment,
data.KindSetDepositsLimit: node.KindSetDepositsLimit,
data.KindIncreasePaidStorage: node.KindIncreasePaidStorage,
data.KindVdfRevelation: node.KindVdfRevelation,
}

var toTzKTKinds = map[string]string{
Expand All @@ -57,6 +59,8 @@ var toTzKTKinds = map[string]string{
node.KindTxRollupRejection: data.KindTxRollupRejection,
node.KindTxRollupRemoveCommitment: data.KindTxRollupRemoveCommitment,
node.KindSetDepositsLimit: data.KindSetDepositsLimit,
node.KindIncreasePaidStorage: data.KindIncreasePaidStorage,
node.KindVdfRevelation: data.KindVdfRevelation,
}

// OperationMessage -
Expand Down
22 changes: 22 additions & 0 deletions cmd/mempool/tzkt/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,25 @@ func operationFromTransferTicket(model data.TransferTicket) data.Operation {
Block: model.Block,
}
}

func operationFromIncreasePaidStorage(model data.IncreasePaidStorage) data.Operation {
return data.Operation{
Type: node.KindIncreasePaidStorage,
Level: model.Level,
ID: model.ID,
Hash: model.Hash,
Block: model.Block,
GasUsed: &model.GasUsed,
BakerFee: &model.BakerFee,
}
}

func operationFromVdfRevelation(model data.VdfRevelation) data.Operation {
return data.Operation{
Type: node.KindVdfRevelation,
Level: model.Level,
ID: model.ID,
Hash: model.Hash,
Block: model.Block,
}
}
10 changes: 10 additions & 0 deletions cmd/mempool/tzkt/tzkt.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ func (tzkt *TzKT) getAPIOperation(model interface{}) (data.Operation, error) {
case *data.TxRollupSubmitBatch:
return operationFromTxRollupSubmitBatch(*operation), nil

case *data.VdfRevelation:
return operationFromVdfRevelation(*operation), nil

case *data.IncreasePaidStorage:
return operationFromIncreasePaidStorage(*operation), nil

default:
return data.Operation{}, errors.Wrapf(ErrInvalidOperationType, "%T", model)
}
Expand Down Expand Up @@ -549,6 +555,10 @@ func (tzkt *TzKT) getTableData(ctx context.Context, table *tableState, indexerSt
return getOperations(ctx, table, filters, tzkt.api.GetTxRollupRejection, operationFromTxRollupRejection)
case data.KindTxRollupRemoveCommitment:
return getOperations(ctx, table, filters, tzkt.api.GetTxRollupRemoveCommitment, operationFromTxRollupRemoveCommitment)
case data.KindVdfRevelation:
return getOperations(ctx, table, filters, tzkt.api.GetVdfRevelations, operationFromVdfRevelation)
case data.KindIncreasePaidStorage:
return getOperations(ctx, table, filters, tzkt.api.GetIncreasePaidStorage, operationFromIncreasePaidStorage)
default:
return errors.Wrap(ErrUnknownOperationKind, table.Table)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/btcsuite/btcutil v1.0.2
github.com/dipdup-net/go-lib v0.2.20
github.com/dipdup-net/go-lib v0.2.22
github.com/go-pg/pg/v10 v10.10.6
github.com/json-iterator/go v1.1.12
github.com/karlseguin/ccache v2.0.3+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dipdup-net/go-lib v0.2.20 h1:CJnv3GRQZf/8G9FjHdStoWeEN1MbIwtmlxPyHJSjUCU=
github.com/dipdup-net/go-lib v0.2.20/go.mod h1:RCYx6FV8+7qQkC1dCP8zn8WTlsFRXXx/D4N+2mw1GJg=
github.com/dipdup-net/go-lib v0.2.22 h1:VDo6Atzl7OkXHI6H15NpZB8sIv/+mzK1JGRYEVs+gH8=
github.com/dipdup-net/go-lib v0.2.22/go.mod h1:RCYx6FV8+7qQkC1dCP8zn8WTlsFRXXx/D4N+2mw1GJg=
github.com/ebellocchia/go-base58 v0.1.0 h1:0w/ODEfZnOPW5KW0QY/Xpb1fxba/BxQJMUa5iYzpljk=
github.com/ebellocchia/go-base58 v0.1.0/go.mod h1:RHE/6C6Ru6YAH9Tc+A9eHQ6ZKEooLC0jw+YLnpt3CAU=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down

0 comments on commit e2990bb

Please sign in to comment.