tds

package module
v0.0.0-...-4f2d810 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 0 Imported by: 0

README

Tezos Delegation Service

Technical test for Kiln

This service gather new baking delegations made on the Tezos protocol and expose them through an API.

Requirements

This project creates and manage its own local instance of SQLite3 via mattn's driver.

Important:

Because this is a CGO enabled package, you are required to set the environment variable CGO_ENABLED=1 and have a gcc compiler present within your path.

Run

Makefile

Makefile contains a list of default use cases

build:
    build the project to ./bin/tds
run:
    starts the built project with default configuration
dev:
    starts the project in developpment/debug mode
test:
    run all go tests with coverage profiling
empty:
    empty the store
sync:
    fill the store with all historical delegation events
Manual

The main project is cmd/tds and comes with the following options

$ go run ./cmd/tds -h
    -api string
            tzkt api delegation endpoint (default "https://api.tzkt.io/v1/operations/delegations")
    -db string
            path to the database file (default "delegations.db")
    -debug
            enable debug logging
    -nohistory
            disable history sync
    -port int
            http server port (default 8080)
    -sync string
            sync interval, should be a duration string (default "1m")

To manipulate the store directly we use cmd/db (defaule behavior is to fill the store with historical data)

$ go run ./cmd/db -h
    -api string
            tzkt api delegation endpoint (default "https://api.tzkt.io/v1/operations/delegations")
    -db string
            path to the database file (default "delegations.db")
    -debug
            enable debug logging
    -empty
            empty the database

Endpoints

The app exposes 1 endpoint.

GET /xtz/delegations

Returns the delegations of the current year, ordered by descending timestamps

Query parameters:
  • year=YYYY: (Optional) returns the delegations of the given year.
Returns
{
  "data": [
    {
      "timestamp": "2024-10-31T10:14:05Z",
      "delegator": "tz1KhjVyh7yc6197M5iZqnpn7u7aDSoqWB4R",
      "amount": "2327823247",
      "level": "6993511"
    },
    {
      "timestamp": "2024-10-31T10:02:05Z",
      "delegator": "tz1P9h5zJoaho148uXCv1iMsum76Rr9LJbGg",
      "amount": "109795184",
      "level": "6993439"
    }
  ]
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delegation

type Delegation struct {
	Timestamp string `json:"timestamp"`
	Delegator string `json:"delegator"`
	Amount    string `json:"amount"`
	Level     string `json:"level"`
	ID        string `json:"-"`
}

Delegation is a struct that represents a delegation

Directories

Path Synopsis
cmd
db command
tds command
internal
xtz

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL