mirror of
https://github.com/trezor/blockbook.git
synced 2026-03-06 15:48:01 +01:00
3.8 KiB
3.8 KiB
Blockbook Introduction
- backend for
Suite - essential for
Suiteto work - supports multiple coins - around 80 officially, and much more unofficially
- github repository is quite popular - 700 forks, 700 stars - https://github.com/trezor/blockbook
- public UI - https://btc1.trezor.io/
Building blocks of Blockbook
Go language
- developed by Google
- statically typed, compiled language
- can do concurrent programming (goroutines)
- good bindings for RocksDB
- error handling is explicit - no exceptions, no try-catch
ZeroMQ
- messaging library
- listens for
hashblockandhashtxevents/notifications/messages frombitcoindand runs a callback function (sends notifications to subscribers) - used in bchain/mq.go
RocksDB
- used in db/rocksdb.go
Bitcoin RPC (bitcoind)
- used in bchain/coins/btc/bitcoinrpc.go
Backend software components/parts
- programming language
- Go
- good for concurrent programming - goroutines, channels
- support for RocksDB
- explicit error handling - no exceptions
- capital letters for public functions, variables, etc.
- main entrypoint/loop
- according to CLI args, does some things
blockbook.go
- configurations
- one config per coin -
configs/coins/bitcoin.json- RPC details, ports build/blockchaincfg.json- coin + server configurationsblockbook.gotaking CLI args
- one config per coin -
- modularization
- the core is blockchain agnostic, bitcoin specified an RPC client interface, all coins implement this interface - with the possibility of default implementations
- db
- RocksDB -
db/rocksdb.go - column families, no tables
- key-value store of bytes, very fast and efficient
- RocksDB -
- data source
- bitcoind RPC for blockchain data, ZeroMQ for notifications
- coingecko API for fiat rates
- data synchronization
- initial sync
- incremental sync
- reorg handling
- application states
- synchronizing, ready for requests, DB inconsistent
- dev environment
- dev server, local development
- logging
- glog ... INFO, WARNING, ERROR
- monitoring
- external, via internal API
- reporting / metrics
- Prometheus - metrics, Grafana - dashboards
common/metrics.go
- REST API
/server/public.go-ConnectFullPublicInterface
- websocket API
server/websocket.go-requestHandlers
- admin interface / internal dashboard
- very small now
server/internal.go
- frontend / UI
/,/test-websocket.html
- cron jobs / scheduled / periodic tasks
- fetching fiat rates
- authentication/authorization
- not used, only for the admin interface
- caching
- saving used transactions in RocksDB
- testing
- unit tests, integration tests
go test -tags=unittest ./db
- deployment
- Debian packages, Debian servers, bare-metal, no cloud
- CI/CD
- Github Actions, previously Gitlab CI
- security
- backups
- scaling
- performance
- error handling
- rate limiting
- load balancing
- cloudflare
- messaging systems
- localization
- documentation
docsfolder
- support
- server resources
- reliability
- developers
- contributors
- repository
- users
- clients
Schedule
-
- Diagram introduction - 5 minutes
-
- Backend terms brainstorming - 10 minutes
-
- Backend terms discussing + code + diagrams - 45 minutes Break - 5 minutes
-
- Installing dependencies - 15 minutes
-
- Installing and running local regtest bitcoind - 15 minutes
-
- Running local Blockbook connected to local regtest - 15 minutes Break - 5 minutes
-
- Playing with code, implementing some API and UI changes - 60 minutes