tbc

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UtxoIndexHashKey = []byte("utxoindexhash") // last indexed utxo hash
	TxIndexHashKey   = []byte("txindexhash")   // last indexed tx hash

	ErrNotLinear       = errors.New("not linear") // not a valid chain
	ErrAlreadyIndexing = errors.New("already indexing")
)
View Source
var (
	ErrReset            = errors.New("reset")
	ErrNoAddresses      = errors.New("no addresses")
	ErrDNSSeed          = errors.New("could not dns seed")
	ErrNoConnectedPeers = errors.New("no connected peers")
)
View Source
var (
	ErrTxAlreadyBroadcast = errors.New("tx already broadcast")
	ErrTxBroadcastNoPeers = errors.New("can't broadcast tx, no peers")
)

Functions

func NewPeer

func NewPeer(network wire.BitcoinNet, id int, address string) (*peer, error)

Types

type Config

type Config struct {
	AutoIndex               bool
	BlockCache              int
	BlockheaderCache        int
	BlockSanity             bool
	LevelDBHome             string
	ListenAddress           string
	LogLevel                string
	MaxCachedTxs            int
	MempoolEnabled          bool
	Network                 string
	PeersWanted             int
	PrometheusListenAddress string
	PprofListenAddress      string
	Seeds                   []string
}

func NewDefaultConfig

func NewDefaultConfig() *Config

type HashHeight added in v0.2.0

type HashHeight struct {
	Hash   chainhash.Hash
	Height uint64
}

func (HashHeight) String added in v0.2.0

func (h HashHeight) String() string

type PeerManager added in v0.3.0

type PeerManager struct {
	// contains filtered or unexported fields
}

PeerManager keeps track of the available peers and their quality.

func NewPeerManager added in v0.5.0

func NewPeerManager(net wire.BitcoinNet, seeds []string, want int) (*PeerManager, error)

NewPeerManager returns a new peer manager.

func (*PeerManager) All added in v0.5.0

func (pm *PeerManager) All(ctx context.Context, f func(ctx context.Context, p *peer))

All runs a call back on all connected peers.

func (*PeerManager) AllBlock added in v0.5.0

func (pm *PeerManager) AllBlock(ctx context.Context, f func(ctx context.Context, p *peer))

func (*PeerManager) Bad added in v0.5.0

func (pm *PeerManager) Bad(ctx context.Context, address string) error

Bad marks the peer as bad.

func (*PeerManager) Good added in v0.5.0

func (pm *PeerManager) Good(address string) error

Good adds peer to good list if it does not exist in connected and good list already.

func (*PeerManager) HandleAddr added in v0.5.0

func (pm *PeerManager) HandleAddr(peers []string)

HandleAddr adds peers to good list.

func (*PeerManager) Random added in v0.5.0

func (pm *PeerManager) Random() (*peer, error)

Random returns a random connected peer.

func (*PeerManager) RandomConnect added in v0.5.0

func (pm *PeerManager) RandomConnect(ctx context.Context) (*peer, error)

RandomConnect blocks until there is a peer ready to use.

func (*PeerManager) Run added in v0.5.0

func (pm *PeerManager) Run(ctx context.Context) error

func (*PeerManager) Stats added in v0.3.0

func (pm *PeerManager) Stats() (int, int, int)

Stats returns peer statistics.

func (*PeerManager) String added in v0.5.0

func (pm *PeerManager) String() string

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg *Config) (*Server, error)

func (*Server) BalanceByAddress

func (s *Server) BalanceByAddress(ctx context.Context, encodedAddress string) (uint64, error)

func (*Server) BalanceByScriptHash added in v0.4.4

func (s *Server) BalanceByScriptHash(ctx context.Context, hash tbcd.ScriptHash) (uint64, error)

func (*Server) BlockByHash added in v0.3.8

func (s *Server) BlockByHash(ctx context.Context, hash *chainhash.Hash) (*btcutil.Block, error)

BlockByHash returns a block with the given hash.

func (*Server) BlockHashByTxId added in v0.4.4

func (s *Server) BlockHashByTxId(ctx context.Context, txId *chainhash.Hash) (*chainhash.Hash, error)

func (*Server) BlockHeaderBest added in v0.2.0

func (s *Server) BlockHeaderBest(ctx context.Context) (uint64, *wire.BlockHeader, error)

BlockHeaderBest returns the headers for the best known blocks.

func (*Server) BlockHeaderByHash

func (s *Server) BlockHeaderByHash(ctx context.Context, hash *chainhash.Hash) (*wire.BlockHeader, uint64, error)

XXX should we return a form of tbcd.BlockHeader which contains all info? and note that the return parameters here are reversed from BlockHeaderBest call.

func (*Server) BlockHeadersByHeight

func (s *Server) BlockHeadersByHeight(ctx context.Context, height uint64) ([]*wire.BlockHeader, error)

func (*Server) BlockInTxIndex added in v0.4.4

func (s *Server) BlockInTxIndex(ctx context.Context, blkid *chainhash.Hash) (bool, error)

func (*Server) BlocksMissing added in v0.4.4

func (s *Server) BlocksMissing(ctx context.Context, count int) ([]tbcd.BlockIdentifier, error)

func (*Server) DBClose

func (s *Server) DBClose() error

XXX remove and find a different way to do this.

func (*Server) DBOpen

func (s *Server) DBOpen(ctx context.Context) error

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 (s *Server) DifficultyAtHash(ctx context.Context, hash *chainhash.Hash) (*big.Int, error)

func (*Server) FeesAtHeight

func (s *Server) FeesAtHeight(ctx context.Context, height, count int64) (uint64, error)

func (*Server) IndexIsLinear added in v0.2.8

func (s *Server) IndexIsLinear(ctx context.Context, startHash, endHash *chainhash.Hash) (int, error)

func (*Server) RawBlockHeaderBest added in v0.2.0

func (s *Server) RawBlockHeaderBest(ctx context.Context) (uint64, api.ByteSlice, error)

RawBlockHeaderBest returns the raw header for the best known block. XXX should we return cumulative difficulty, hash?

func (*Server) RawBlockHeadersByHeight

func (s *Server) RawBlockHeadersByHeight(ctx context.Context, height uint64) ([]api.ByteSlice, error)

func (*Server) Run

func (s *Server) Run(pctx context.Context) error

func (*Server) SpentOutputsByTxId added in v0.2.8

func (s *Server) SpentOutputsByTxId(ctx context.Context, txId *chainhash.Hash) ([]tbcd.SpentInfo, error)

func (*Server) SyncIndexersToBest added in v0.4.4

func (s *Server) SyncIndexersToBest(ctx context.Context) error

func (*Server) SyncIndexersToHash added in v0.2.0

func (s *Server) SyncIndexersToHash(ctx context.Context, hash *chainhash.Hash) error

SyncIndexersToHash tries to move the various indexers to the supplied hash (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

func (s *Server) Synced(ctx context.Context) SyncInfo

Synced returns true if all block headers, blocks and all indexes are caught up.

func (*Server) TxBroadcast added in v0.5.0

func (s *Server) TxBroadcast(ctx context.Context, tx *wire.MsgTx, force bool) (*chainhash.Hash, error)

func (*Server) TxBroadcastAllToPeer added in v0.5.0

func (s *Server) TxBroadcastAllToPeer(ctx context.Context, p *peer) error

func (*Server) TxById

func (s *Server) TxById(ctx context.Context, txId *chainhash.Hash) (*wire.MsgTx, error)

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 (s *Server) TxIndexIsLinear(ctx context.Context, endHash *chainhash.Hash) (int, error)

func (*Server) TxIndexer

func (s *Server) TxIndexer(ctx context.Context, endHash *chainhash.Hash) error

func (*Server) TxIndexerUnwind added in v0.2.8

func (s *Server) TxIndexerUnwind(ctx context.Context, startBH, endBH *tbcd.BlockHeader) error

func (*Server) TxIndexerWind added in v0.2.8

func (s *Server) TxIndexerWind(ctx context.Context, startBH, endBH *tbcd.BlockHeader) error

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 (s *Server) UtxoIndexIsLinear(ctx context.Context, endHash *chainhash.Hash) (int, error)

func (*Server) UtxoIndexer

func (s *Server) UtxoIndexer(ctx context.Context, endHash *chainhash.Hash) error

func (*Server) UtxoIndexerUnwind added in v0.2.8

func (s *Server) UtxoIndexerUnwind(ctx context.Context, startBH, endBH *tbcd.BlockHeader) error

func (*Server) UtxoIndexerWind added in v0.2.8

func (s *Server) UtxoIndexerWind(ctx context.Context, startBH, endBH *tbcd.BlockHeader) error

func (*Server) UtxosByAddress

func (s *Server) UtxosByAddress(ctx context.Context, encodedAddress string, start uint64, count uint64) ([]tbcd.Utxo, error)

func (*Server) UtxosByScriptHash added in v0.4.4

func (s *Server) UtxosByScriptHash(ctx context.Context, hash tbcd.ScriptHash, start uint64, count uint64) ([]tbcd.Utxo, error)

type SyncInfo

type SyncInfo struct {
	Synced      bool // True when all indexing is caught up
	BlockHeader HashHeight
	Utxo        HashHeight
	Tx          HashHeight
}

Jump to

Keyboard shortcuts

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