rawdb

package
v0.0.0-...-dd5a67f Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2019 License: MIT Imports: 16 Imported by: 0

README

go-ethereum의 LevelDB 스키마를 대부분 따름

일부 스키마 및 인코딩 방식 등을 커스터마이징

  1. database.go

    • DB 생성 인터페이스 함수 구현
    • in-memory (NewMemoryDatabase) 및 persistent (=disk) (NewLevelDBDatabase) DB 구현
  2. io_chain.go

    • 블록 데이터 I/O 함수 (read, write, delete) 구현
    • Hash, Header, Body, Td (=total difficulty), Block 등의 I/O 구현
    • GenesisHeaderHash, LastHeaderHash 접근 가능
  3. io_state.go

    • State 데이터 I/O 함수 (read, write, delete) 구현
    • 추가적으로 테스팅을 위한 ReadStates, CountStates 구현
  4. io_txs.go

    • Tx (=transaction) 데이터 I/O 함수 (read, write, delete) 구현
    • 블록 안에 저장된 tx와 밖에 따로 저장된 tx가 있으므로 두 케이스 모두에 대해 구현

    (1) 블록 안에 저장된 tx: TxLookupEntry, tx가 저장된 블록의 해시 return

    (2) 블록 밖에 저장된 tx: RawTxData, tx 자체를 저장

  5. schema.go

    • var (...)에 로우레벨 DB prefixing 스키마 설명 (실제 LevelDB에 저장되는 key 값)

      e.g. lastHeaderKey = []byte("LastHeader")

    • 각각의 key 값에 대한 인터페이스 함수

Documentation

Overview

Package rawdb contains a collection of low level database accessors. e.g. read, write

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountStates

func CountStates(db xordb.Iteratee) int

Get the number of account

func DeleteBlock

func DeleteBlock(db xordb.Writer, hash common.Hash, number uint64)

DeleteBlock removes all block data associated with a hash.

func DeleteBody

func DeleteBody(db xordb.Writer, hash common.Hash, number uint64)

DeleteBody removes all block body data associated with a hash.

func DeleteHash

func DeleteHash(db xordb.Writer, number uint64)

DeleteHash removes the number to hash mapping.

func DeleteHeader

func DeleteHeader(db xordb.Writer, hash common.Hash, number uint64)

DeleteHeader removes all block header data associated with a hash.

func DeleteRawTxData

func DeleteRawTxData(db xordb.Writer, hash common.Hash)

DeleteRawTxData removes the raw tx data corresponding to the hash

func DeleteState

func DeleteState(db xordb.Writer, publicKey *ecdsa.PublicKey)

DeleteState deletes a tx hash corresponding to the PublicKey's address

func DeleteTd

func DeleteTd(db xordb.Writer, hash common.Hash, number uint64)

DeleteTd removes all block total difficulty data associated with a hash.

func DeleteTxLookupEntry

func DeleteTxLookupEntry(db xordb.Writer, hash common.Hash)

DeleteTxLookupEntry removes all transaction data associated with a hash.

func HasBody

func HasBody(db xordb.Reader, hash common.Hash, number uint64) bool

HasBody verifies the existence of a block body corresponding to the hash.

func HasHeader

func HasHeader(db xordb.Reader, hash common.Hash, number uint64) bool

HasHeader verifies the existence of a block header corresponding to the hash.

func LoadBlock

func LoadBlock(db xordb.Reader, hash common.Hash, number uint64) *types.Block

LoadBlock retrieves an entire block corresponding to the hash & number

func LoadBlockByBN

func LoadBlockByBN(db xordb.Reader, number uint64) *types.Block

LoadBlockByBN retrieves an entire block corresponding to the number

func LoadHeader

func LoadHeader(db xordb.Reader, hash common.Hash, number uint64) *types.Header

LoadHeader retrieves an entire header corresponding to the hash & number

func LoadHeaderByBN

func LoadHeaderByBN(db xordb.Reader, number uint64) *types.Header

LoadHeaderByBN retrieves an entire header corresponding to the number

func NewDatabase

func NewDatabase(db xordb.KeyValueStore) xordb.Database

NewDatabase creates a high level database on top of a given key-value data

func NewLevelDBDatabase

func NewLevelDBDatabase(file string, cache int, handles int, namespace string) (xordb.Database, error)

NewLevelDBDatabase creates a persistent key-value database

func NewMemoryDatabase

func NewMemoryDatabase() xordb.Database

NewMemoryDatabase creates an in-memory key-value database

func NewMemoryDatabaseWithCap

func NewMemoryDatabaseWithCap(size int) xordb.Database

NewMemoryDatabaseWithCap creates an in-memory key-value database with an initial starting capacity

func ReadBody

func ReadBody(db xordb.Reader, hash common.Hash, number uint64) *types.Body

ReadBody retrieves the block body corresponding to the hash.

func ReadBodyData

func ReadBodyData(db xordb.Reader, hash common.Hash, number uint64) []byte

ReadBodyData retrieves the block body in json encoding

func ReadGenesisHeaderHash

func ReadGenesisHeaderHash(db xordb.Reader) common.Hash

ReadGenesisHeaderHash retrieves the hash of the genesis block.

func ReadHash

func ReadHash(db xordb.Reader, number uint64) common.Hash

ReadHash retrieves the hash assigned to a block number.

func ReadHeadBlockHash

func ReadHeadBlockHash(db xordb.Reader) common.Hash

ReadHeadBlockHash retrieves the hash of the last block.

func ReadHeader

func ReadHeader(db xordb.Reader, hash common.Hash, number uint64) *types.Header

ReadHeader retrieves the block header corresponding to the hash.

func ReadHeaderData

func ReadHeaderData(db xordb.Reader, hash common.Hash, number uint64) rlp.RawValue

ReadHeaderData retrieves a block header data in rlp encoding

func ReadHeaderNumber

func ReadHeaderNumber(db xordb.Reader, hash common.Hash) *uint64

ReadHeaderNumber returns the header number assigned to a hash.

func ReadLastHeaderHash

func ReadLastHeaderHash(db xordb.Reader) common.Hash

ReadLastHeaderHash retrieves the hash of the last header.

func ReadRawTxData

func ReadRawTxData(db xordb.Reader, hash common.Hash) []byte

ReadRawTxData retrieves the raw tx data corresponding to the hash

func ReadState

func ReadState(db xordb.Reader, publicKey *ecdsa.PublicKey) common.Hash

ReadState reads a tx hash corresponding to the PublicKey's address

func ReadStates

func ReadStates(db xordb.Database)

ReadStates reads all address - txHash mappings in the db

func ReadTd

func ReadTd(db xordb.Reader, hash common.Hash, number uint64) *big.Int

ReadTd retrieves a block's total difficulty corresponding to the hash.

func ReadTdData

func ReadTdData(db xordb.Reader, hash common.Hash, number uint64) rlp.RawValue

ReadTdData retrieves a block's total difficulty corresponding to the hash.

func ReadTransaction

func ReadTransaction(db xordb.Reader, hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64)

ReadTransaction retrieves a transaction and its metadata. returns (tx, blockHash, *blockNumber, uint64(txIndex))

func ReadTxLookupEntry

func ReadTxLookupEntry(db xordb.Reader, hash common.Hash) *uint64

ReadTxLookupEntry retrieves the blocknumber of the block the tx is in

func StoreBlock

func StoreBlock(db xordb.Writer, block *types.Block)

StoreBlock serializes a block into the database, header and body separately.

func WriteBody

func WriteBody(db xordb.Writer, hash common.Hash, number uint64, body *types.Body)

WriteBody stores a block body into the database.

func WriteBodyData

func WriteBodyData(db xordb.Writer, hash common.Hash, number uint64, data []byte)

WriteBodyData stores block body into the database in json encoding

func WriteGenesisHeaderHash

func WriteGenesisHeaderHash(db xordb.Writer, hash common.Hash)

WriteGenesisHeaderHash stores the hash of the genesis block.

func WriteHash

func WriteHash(db xordb.Writer, hash common.Hash, number uint64)

WriteHash stores the hash assigned to a block number.

func WriteHeadBlockHash

func WriteHeadBlockHash(db xordb.Writer, hash common.Hash)

WriteHeadBlockHash stores the last block's hash.

func WriteHeader

func WriteHeader(db xordb.Writer, header *types.Header)

WriteHeader stores a block header into the database and also stores the hash- to-number mapping.

func WriteLastHeaderHash

func WriteLastHeaderHash(db xordb.Writer, hash common.Hash)

WriteLastHeaderHash stores the hash of the last header.

func WriteRawTxData

func WriteRawTxData(db xordb.Writer, hash common.Hash, data []byte)

WriteRawTxData stores the raw tx data corresponding to the hash

func WriteState

func WriteState(db xordb.Writer, address common.Address, txHash common.Hash)

WriteState writes a tx hash corresponding to the PublicKey's address

func WriteTd

func WriteTd(db xordb.Writer, hash common.Hash, number uint64, td *big.Int)

WriteTd stores the total difficulty of a block into the database.

func WriteTransaction

func WriteTransaction(db xordb.Database, hash common.Hash, tx *types.Transaction)

WriteTransaction stores a transaction into the database.

func WriteTxLookupEntries

func WriteTxLookupEntries(db xordb.Writer, block *types.Block)

WriteTxLookupEntries stores the blocknumber of the block the tx is in

Types

This section is empty.

Jump to

Keyboard shortcuts

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