inventory

package
v0.0.0-...-79d14b3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2015 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fingerprint

func Fingerprint(hash []byte, i uint32) []byte

Types

type BitStack

type BitStack struct {
	Bytes []byte
	Next  int
}

func (*BitStack) Pop

func (s *BitStack) Pop() bool

func (*BitStack) Size

func (s *BitStack) Size() int

type Block

type Block struct {
	Hash      []byte    // 32 bytes
	Timestamp time.Time // 4 bytes
	Height    int32     // 4 bytes
}

type Config

type Config struct {
	Wallet   *wallet.Wallet
	Database Database
	Network  Network
}

type Database

type Database interface {
	LoadAllTransactions() []*TxVersion
	StoreNewTransaction(*TxVersion)
	Set([]byte, interface{})
	Get([]byte, interface{}) error
	Close()
}

type Filter

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

TODO make threadsafe

func NewFilter

func NewFilter() *Filter

func (*Filter) Filter

func (f *Filter) Filter() *messages.FilterLoad

func (*Filter) Match

func (f *Filter) Match(data []byte) bool

func (*Filter) RemoteData

func (f *Filter) RemoteData() []byte

func (*Filter) RemoteUpdateNeeded

func (f *Filter) RemoteUpdateNeeded() bool

func (Filter) String

func (f Filter) String() string

func (*Filter) Watch

func (f *Filter) Watch(data []byte, mayNeedUpdate bool)

type HashStack

type HashStack struct {
	Hashes [][]byte
	Next   int
}

func (*HashStack) Pop

func (s *HashStack) Pop() []byte

func (*HashStack) Size

func (s *HashStack) Size() int

type HeaderGetter

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

func GetHeaders

func GetHeaders(inv *Inventory, db Database) *HeaderGetter

func (*HeaderGetter) Close

func (getter *HeaderGetter) Close()

Close shuts down the header getter. It is guaranteed to not read or write to any channels after Close returns.

func (*HeaderGetter) Input

func (getter *HeaderGetter) Input() chan<- network.Message

func (*HeaderGetter) Run

func (getter *HeaderGetter) Run()

type Inventory

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

func New

func New(config *Config) *Inventory

func (*Inventory) Close

func (inv *Inventory) Close()

func (*Inventory) Connected

func (inv *Inventory) Connected() chan struct{}

Connected returns a channel that closes once an initial connection has been established.

func (*Inventory) GetRecentMerkleBlocks

func (inv *Inventory) GetRecentMerkleBlocks(count int) error

TODO Add headergetter function getting N most recent headers.

func (*Inventory) Run

func (inv *Inventory) Run()

func (*Inventory) Send

func (inv *Inventory) Send(m network.Message) string

func (*Inventory) SendGetData

func (inv *Inventory) SendGetData(vector messages.InventoryVector, addrHint string) error

func (*Inventory) ServeHTTP

func (inv *Inventory) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Inventory) Subscribe

func (inv *Inventory) Subscribe(d dispatcher)

func (*Inventory) UnspentTxOutputs

func (inv *Inventory) UnspentTxOutputs() []*messages.TxOutput

UnspentTransactions returns a list of the current unspent transactions in the set Inventory is watching.

func (*Inventory) Unsubscribe

func (inv *Inventory) Unsubscribe(d dispatcher)

func (*Inventory) UpdateTxOutputs

func (inv *Inventory) UpdateTxOutputs(version *TxVersion) error

UpdateTxOutputs updates the list of unspent transaction outputs Inventory is watching. It also alerts attached wallets about new transaction to aid their discovery process.

func (*Inventory) VerifyTransaction

func (inv *Inventory) VerifyTransaction(tx *messages.Transaction) (bool, error)

type MerkleNode

type MerkleNode struct {
	Left, Right *MerkleNode
	Hash        []byte
	// contains filtered or unexported fields
}

func NewMerkleTree

func NewMerkleTree(count uint32, hashArray [][]byte, flags []byte) (*MerkleNode, error)

EmptyMerkleTree construct an empty merkle tree with count transactions in it. It returns the root of the tree.

func (*MerkleNode) MatchedTransactions

func (n *MerkleNode) MatchedTransactions() [][]byte

func (*MerkleNode) Process

func (n *MerkleNode) Process(hashes *HashStack, bits *BitStack, levels int) error

type Network

type Network interface {
	SendChannel() chan<- network.Message
	EndpointMisbehaving(string, int, string)
	EndpointsByQuality() []string
	Connected() chan struct{}
}

type Transaction

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

type TxLoader

type TxLoader interface {
	LoadAllTransactions() []*TxVersion
}

type TxOutput

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

func (*TxOutput) Fingerprint

func (out *TxOutput) Fingerprint() []byte

Fingerprint returns a unique identifier of the output.

func (*TxOutput) TxHash

func (out *TxOutput) TxHash() []byte

TxHash returns the hash of the transaction the output belongs to.

type TxVersion

type TxVersion struct {
	Hash  []byte `json:"hash,omitempty"`
	Block *Block `json:"block,omitempty"`

	// Another duplicate of this version has been confirmed.
	InvalidatedBy []byte `json:"invalidated_by,omitempty"`

	// Only used for storing and loading tx.
	Data []byte `json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*TxVersion) DeserializeTransaction

func (t *TxVersion) DeserializeTransaction() error

func (*TxVersion) Id

func (t *TxVersion) Id() []byte

func (*TxVersion) SerializeTransaction

func (t *TxVersion) SerializeTransaction()

func (TxVersion) String

func (t TxVersion) String() string

Jump to

Keyboard shortcuts

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