📘 Trezor address/account balance backend
Go to file
2018-01-25 18:04:35 +01:00
bitcoin ZeroMQ handler in the background with graceful shutdown 2018-01-22 16:46:54 +01:00
db GetBestBlock height and hash from DB 2018-01-24 18:02:46 +01:00
server extended info rest request - returns bestblock of the index 2018-01-25 12:31:31 +01:00
.gitignore .gitignore update - ignore .vscode and go debugger files 2018-01-17 14:55:54 +01:00
blockbook.go connectBlockChunk - handling height over bitcoind best block height 2018-01-25 16:24:27 +01:00
Gopkg.lock folder reorganization 2018-01-18 16:44:31 +01:00
Gopkg.toml add profiling 2017-09-13 02:50:34 +02:00
README.md description of data storage in RocksDB 2018-01-25 18:04:35 +01:00

blockbook

Install

Setup go environment:

sudo apt-get install golang
sudo apt-get install git
go help gopath

Install RocksDB: https://github.com/facebook/rocksdb/blob/master/INSTALL.md

sudo apt-get install libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev
cd /path/to/rocksdb
make static_lib

Install gorocksdb: https://github.com/tecbot/gorocksdb

CGO_CFLAGS="-I/path/to/rocksdb/include" \
CGO_LDFLAGS="-L/path/to/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4 -lzstd" \
  go get github.com/tecbot/gorocksdb

Install ZeroMQ: https://github.com/zeromq/libzmq

Install Go interface to ZeroMQ:

go get github.com/pebbe/zmq4

Install blockbook:

go get github.com/jpochyla/blockbook

Usage

$GOPATH/bin/blockbook --help

Data storage in RocksDB

Blockbook stores data the following column families

  • default

    at the moment not used, will store statistical data etc.

  • height - mapping of block height to block hash

    Block heigh stored as binary array of 4 bytes (big endian uint32)
    Block hash stored as binary array of 32 bytes

    Example - the first four blocks (all data hex encoded)

0x00000000 : 0x000000000933EA01AD0EE984209779BAAEC3CED90FA3F408719526F8D77F4943
0x00000001 : 0x00000000B873E79784647A6C82962C70D228557D24A747EA4D1B8BBE878E1206
0x00000002 : 0x000000006C02C8EA6E4FF69651F7FCDE348FB9D557A06E6957B65552002A7820
0x00000003 : 0x000000008B896E272758DA5297BCD98FDC6D97C9B765ECEC401E286DC1FDBE10
  • outputs - mapping of address+block height to array of outpoints

    Address+block height stored as binary array 25 bytes total - 21 bytes address without checksum + 4 bytes (big endian uint32) block height
    array of outpoints stored as binary array of 32 bytes for address + variable length outpoint number for each outpoint

    Example - (all data hex encoded)

0x6FCB8DBDD6F207F559162EF3BBD4229911DA248C3000000029 : 0xC459D961CC607A12AFDC6A8A200E84F1AD8E2021C2745FE12E0231DD90CA46BE00
0x6FCF12C87234AF9C402246B1A5D5C3F937337E6ECC00000013 : 0x73A4988ADF462B6540CFA59097804174B298CFA439F73C1A072C2C6FBDBE57C700
0x6FD3F80654BDA100BB704FBAF49E759E6084AB10DD0000005D : 0xC12A5ACAE3EFD788F088FCFA6D267ED48681A1AE4D2F477BFA60C0500274B6BE00
0x6FD5D788B43528CF8AF3EFBB050060B1BE26A54B4600000033 : 0x67F41C86F443AC7E00F494DD6B5DB2E999AA64E77A537728096CE4AB32F3170D00
  • inputs

    tbd