mirror of
https://github.com/romanz/electrs.git
synced 2024-11-19 01:43:29 +01:00
Add short schema description
This commit is contained in:
parent
aa6f20017a
commit
b421df8c10
@ -1,9 +1,5 @@
|
||||
# Electrum Server in Rust
|
||||
|
||||
<p>
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c3/Gold-121700.jpg" width="40%" />
|
||||
</p>
|
||||
|
||||
[![Build Status](https://travis-ci.com/romanz/electrs.svg?branch=master)](https://travis-ci.com/romanz/electrs)
|
||||
|
||||
An efficient re-implementation of Electrum Server, inspired by [ElectrumX](https://github.com/kyuupichan/electrumx)
|
||||
@ -81,3 +77,7 @@ scrape_configs:
|
||||
$ sudo systemctl restart prometheus
|
||||
$ firefox 'http://localhost:9090/graph?g0.range_input=1h&g0.expr=index_height&g0.tab=0'
|
||||
```
|
||||
|
||||
## Index database
|
||||
|
||||
The database schema is described [here](doc/schema.md).
|
||||
|
31
doc/schema.md
Normal file
31
doc/schema.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Index Schema
|
||||
|
||||
The index is stored at a single RocksDB database using the following schema:
|
||||
|
||||
## Transaction outputs' index
|
||||
|
||||
Allows efficiently finding all funding transactions for a specific address:
|
||||
|
||||
| Code | Script Hash Prefix | Funding TxID Prefix |
|
||||
| ------ | -------------------- | --------------------- |
|
||||
| `b'O'` | `SHA256(script)[:8]` | `txid[:8]` |
|
||||
|
||||
## Transaction inputs' index
|
||||
|
||||
Allows efficiently finding spending transaction of a specific output:
|
||||
|
||||
| Code | Funding TxID Prefix | Funding Output Index | Spending TxID Prefix |
|
||||
| ------ | -------------------- | --------------------- | --------------------- |
|
||||
| `b'I'` | `txid[:8]` | `uint16` | `txid[:8]` |
|
||||
|
||||
|
||||
## Full Transaction IDs
|
||||
|
||||
In order to save storage space, we store the full transaction IDs once, and use their 8-byte prefixes for the indexes above.
|
||||
|
||||
| Code | Transaction ID | Confirmed height |
|
||||
| ------ | ----------------- |------------------|
|
||||
| `b'T'` | `txid` (32 bytes) | `uint32` |
|
||||
|
||||
Note that this mapping allows us to use `getrawtransaction` RPC to retrieve actual transaction data from without `-txindex` enabled
|
||||
(by explicitly specifying the [blockhash](https://github.com/bitcoin/bitcoin/commit/497d0e014cc79d46531d570e74e4aeae72db602d)).
|
Loading…
Reference in New Issue
Block a user