Documentation ¶
Index ¶
- Variables
- func NewPeer(network wire.BitcoinNet, address string) (*peer, error)
- type Config
- type HashHeight
- type Server
- func (s *Server) AddExternalHeaders(ctx context.Context, headers [][80]byte, upstreamStateId *[32]byte) (tbcd.InsertType, *tbcd.BlockHeader, *tbcd.BlockHeader, error)
- func (s *Server) BalanceByAddress(ctx context.Context, encodedAddress string) (uint64, error)
- func (s *Server) BlockHeaderBest(ctx context.Context) (uint64, *wire.BlockHeader, error)
- func (s *Server) BlockHeaderByHash(ctx context.Context, hash *chainhash.Hash) (*wire.BlockHeader, uint64, error)
- func (s *Server) BlockHeadersByHeight(ctx context.Context, height uint64) ([]*wire.BlockHeader, error)
- func (s *Server) DB() tbcd.Database
- func (s *Server) DBClose() error
- func (s *Server) DBOpen(ctx context.Context) error
- func (s *Server) DifficultyAtHash(ctx context.Context, hash *chainhash.Hash) (*big.Int, error)
- func (s *Server) ExternalHeaderSetup(ctx context.Context) error
- func (s *Server) ExternalHeaderTearDown() error
- func (s *Server) FeesAtHeight(ctx context.Context, height, count int64) (uint64, error)
- func (s *Server) FullBlockAvailable(ctx context.Context, hash *chainhash.Hash) (bool, error)
- func (s *Server) IndexIsLinear(ctx context.Context, startHash, endHash *chainhash.Hash) (int, error)
- func (s *Server) RawBlockHeaderBest(ctx context.Context) (uint64, api.ByteSlice, error)
- func (s *Server) RawBlockHeadersByHeight(ctx context.Context, height uint64) ([]api.ByteSlice, error)
- func (s *Server) RemoveExternalHeaders(ctx context.Context, headers [][80]byte, tipAfterRemoval [80]byte, ...) (tbcd.RemoveType, *tbcd.BlockHeader, error)
- func (s *Server) Run(pctx context.Context) error
- func (s *Server) ScriptHashAvailableToSpend(ctx context.Context, txId *chainhash.Hash, index uint32) (bool, error)
- func (s *Server) SetUpstreamStateId(ctx context.Context, upstreamStateId *[32]byte) error
- func (s *Server) SpentOutputsByTxId(ctx context.Context, txId *chainhash.Hash) ([]tbcd.SpentInfo, error)
- func (s *Server) SyncIndexersToHash(ctx context.Context, hash *chainhash.Hash) error
- func (s *Server) Synced(ctx context.Context) SyncInfo
- func (s *Server) TxById(ctx context.Context, txId *chainhash.Hash) (*wire.MsgTx, *chainhash.Hash, error)
- func (s *Server) TxIndexHash(ctx context.Context) (*HashHeight, error)
- func (s *Server) TxIndexIsLinear(ctx context.Context, endHash *chainhash.Hash) (int, error)
- func (s *Server) TxIndexer(ctx context.Context, endHash *chainhash.Hash) error
- func (s *Server) TxIndexerUnwind(ctx context.Context, startBH, endBH *tbcd.BlockHeader) error
- func (s *Server) TxIndexerWind(ctx context.Context, startBH, endBH *tbcd.BlockHeader) error
- func (s *Server) UpstreamStateId(ctx context.Context) (*[32]byte, error)
- func (s *Server) UtxoIndexHash(ctx context.Context) (*HashHeight, error)
- func (s *Server) UtxoIndexIsLinear(ctx context.Context, endHash *chainhash.Hash) (int, error)
- func (s *Server) UtxoIndexer(ctx context.Context, endHash *chainhash.Hash) error
- func (s *Server) UtxoIndexerUnwind(ctx context.Context, startBH, endBH *tbcd.BlockHeader) error
- func (s *Server) UtxoIndexerWind(ctx context.Context, startBH, endBH *tbcd.BlockHeader) error
- func (s *Server) UtxosByAddress(ctx context.Context, encodedAddress string, start uint64, count uint64) ([]tbcd.Utxo, error)
- type SyncInfo
Constants ¶
This section is empty.
Variables ¶
var ( UtxoIndexHashKey = []byte("utxoindexhash") // last indexed utxo hash TxIndexHashKey = []byte("txindexhash") // last indexed tx hash ErrNotLinear = errors.New("not linear") // not a valid chain )
Functions ¶
Types ¶
type Config ¶
type Config struct { AutoIndex bool BlockSanity bool LevelDBHome string ListenAddress string LogLevel string MaxCachedTxs int Network string PeersWanted int PrometheusListenAddress string PprofListenAddress string Seeds []string // In this mode, P2P is disabled and TBC expects to be fed external // headers by the code that manages it. Additionally, a fake genesis // block can optionally be configured which TBC will build on top of, // with pre-set height and cumulative difficulty adjustments so TBC // can return correct height/cdiff values for blocks in its chain. // This mode was originally created for op-geth to be able to maintain // a lightweight header-only view of Bitcoin consensus based on BTC // Attributes Deposited transactions which communicate new Bitcoin // headers to the protocol and determine what blocks are actually // indexed in op-geth's separate full TBC node at each L2 block to // ensure deterministic Bitcoin state availability to hVM precompiles. ExternalHeaderMode bool EffectiveGenesisBlock *wire.BlockHeader GenesisHeightOffset uint64 GenesisDifficultyOffset big.Int }
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
type HashHeight ¶ added in v0.2.0
func (HashHeight) String ¶ added in v0.2.0
func (h HashHeight) String() string
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) AddExternalHeaders ¶
func (s *Server) AddExternalHeaders(ctx context.Context, headers [][80]byte, upstreamStateId *[32]byte) (tbcd.InsertType, *tbcd.BlockHeader, *tbcd.BlockHeader, error)
func (*Server) BalanceByAddress ¶
func (*Server) BlockHeaderBest ¶ added in v0.2.0
BlockHeaderBest returns the headers for the best known blocks.
func (*Server) BlockHeaderByHash ¶
func (*Server) BlockHeadersByHeight ¶
func (*Server) DB ¶
DB exports the underlying database. This should only be used in tests. XXX remove this and deal with the fallout.
func (*Server) DBOpen ¶
DBOpen opens the underlying server database. It has been put in its own function to make it available during tests and hemictl. It would be good if it can be deleted. XXX remove and find a different way to do this.
func (*Server) DifficultyAtHash ¶ added in v0.2.0
func (*Server) ExternalHeaderSetup ¶
func (*Server) ExternalHeaderTearDown ¶
func (*Server) FeesAtHeight ¶
func (*Server) FullBlockAvailable ¶
FullBlockAvailable returns whether TBC has the full block corresponding to the specified hash available in its database. XXX: Optimize this to not actually read the full block from disk
func (*Server) IndexIsLinear ¶ added in v0.2.8
func (*Server) RawBlockHeaderBest ¶ added in v0.2.0
RawBlockHeaderBest returns the raw header for the best known block. XXX should we return cumulative difficulty, hash?
func (*Server) RawBlockHeadersByHeight ¶
func (*Server) RemoveExternalHeaders ¶
func (s *Server) RemoveExternalHeaders(ctx context.Context, headers [][80]byte, tipAfterRemoval [80]byte, upstreamStateId *[32]byte) (tbcd.RemoveType, *tbcd.BlockHeader, error)
RemoveExternalHeaders removes the provided headers from TBC's state knowledge, setting the canonical tip to the provided tip. This method can only be used when TBC is running in external header mode.
The upstream state id is an optional identifier that the caller can use to track some upstream state which represents TBC's own state once this removal is performed. For example, op-geth uses this to track the hash of the EVM block which cumulatively represents TBC's entire header knowledge after the removal is processed, such that re-applying all Bitcoin Attributes Deposited transactions in the EVM from genesis to that hash would result in TBC having this state.
This upstream state id is tracked in TBC rather than upstream in the caller so that updates to the upstreamCursor are always made atomically with the corresponding TBC database state transition. Otherwise, an unexpected termination between updating TBC state and recording the updated upstreamCursor could cause state corruption.
func (*Server) ScriptHashAvailableToSpend ¶
func (s *Server) ScriptHashAvailableToSpend(ctx context.Context, txId *chainhash.Hash, index uint32) (bool, error)
ScriptHashAvailableToSpend returns a boolean which indicates whether a specific output (uniquely identified by TxId output index) is available for spending in the UTXO table. This function can return false for two reasons:
- The outpoint was already spent
- The outpoint never existed
func (*Server) SetUpstreamStateId ¶
func (*Server) SpentOutputsByTxId ¶ added in v0.2.8
func (*Server) SyncIndexersToHash ¶ added in v0.2.0
SyncIndexersToHash tries to move the various indexers to the supplied height (inclusive). Note: on unwind it means that it WILL unwind the the various indexers including the hash that was passed in. E.g. if this unwinds from 1001 to 1000 the indexes for block 1000 WILL be updated as well.
func (*Server) Synced ¶
Synced returns true if all block headers, blocks and all indexes are caught up.
func (*Server) TxIndexHash ¶ added in v0.2.0
func (s *Server) TxIndexHash(ctx context.Context) (*HashHeight, error)
TxIndexHash returns the last hash that has been been Tx indexed.
func (*Server) TxIndexIsLinear ¶ added in v0.2.8
func (*Server) TxIndexerUnwind ¶ added in v0.2.8
func (*Server) TxIndexerWind ¶ added in v0.2.8
func (*Server) UpstreamStateId ¶
UpstreamStateId fetches the last-stored upstream state id. If the last header insertion/removal did not specify an upstream state ID, this will return the default upstream state id.
func (*Server) UtxoIndexHash ¶ added in v0.2.0
func (s *Server) UtxoIndexHash(ctx context.Context) (*HashHeight, error)
UtxoIndexHash returns the last hash that has been been UTxO indexed.
func (*Server) UtxoIndexIsLinear ¶ added in v0.2.8
func (*Server) UtxoIndexer ¶
func (*Server) UtxoIndexerUnwind ¶ added in v0.2.8
func (*Server) UtxoIndexerWind ¶ added in v0.2.8
type SyncInfo ¶
type SyncInfo struct { Synced bool // True when all indexing is caught up BlockHeader HashHeight Utxo HashHeight Tx HashHeight }