node

package
v0.0.0-...-6bb3ed1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockStorer

type BlockStorer interface {
	Put(*proto.Block) error
	Get(string) (*proto.Block, error)
}

type Chain

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

func NewChain

func NewChain(bs BlockStorer, txStore TXStorer) *Chain

func (*Chain) AddBlock

func (c *Chain) AddBlock(b *proto.Block) error

func (*Chain) GetBlockByHash

func (c *Chain) GetBlockByHash(hash []byte) (*proto.Block, error)

func (*Chain) GetBlockByHeight

func (c *Chain) GetBlockByHeight(height int) (*proto.Block, error)

func (*Chain) Height

func (c *Chain) Height() int

func (*Chain) ValidateBlock

func (c *Chain) ValidateBlock(b *proto.Block) error

func (*Chain) ValidateTransaction

func (c *Chain) ValidateTransaction(tx *proto.Transaction) error

type HeaderList

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

func NewHeaderList

func NewHeaderList() *HeaderList

func (*HeaderList) Add

func (list *HeaderList) Add(h *proto.Header)

func (*HeaderList) Get

func (list *HeaderList) Get(index int) *proto.Header

func (*HeaderList) Height

func (list *HeaderList) Height() int

func (*HeaderList) Len

func (list *HeaderList) Len() int

type MemoryBlockStore

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

func NewMemoryBlockStore

func NewMemoryBlockStore() *MemoryBlockStore

func (*MemoryBlockStore) Get

func (s *MemoryBlockStore) Get(hash string) (*proto.Block, error)

func (*MemoryBlockStore) Put

func (s *MemoryBlockStore) Put(b *proto.Block) error

type MemoryTXStore

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

func NewMemoryTXStore

func NewMemoryTXStore() *MemoryTXStore

func (*MemoryTXStore) Get

func (s *MemoryTXStore) Get(hash string) (*proto.Transaction, error)

func (*MemoryTXStore) Put

func (s *MemoryTXStore) Put(tx *proto.Transaction) error

type MemoryUTXOStore

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

func NewMemoryUTXOStore

func NewMemoryUTXOStore() *MemoryUTXOStore

func (*MemoryUTXOStore) Get

func (s *MemoryUTXOStore) Get(hash string) (*UTXO, error)

func (*MemoryUTXOStore) Put

func (s *MemoryUTXOStore) Put(utxo *UTXO) error

type Mempool

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

func NewMempool

func NewMempool() *Mempool

func (*Mempool) Add

func (pool *Mempool) Add(tx *proto.Transaction) bool

func (*Mempool) Clear

func (pool *Mempool) Clear() []*proto.Transaction

func (*Mempool) Has

func (pool *Mempool) Has(tx *proto.Transaction) bool

func (*Mempool) Len

func (pool *Mempool) Len() int

type Node

type Node struct {
	ServerConfig

	proto.UnimplementedNodeServer
	// contains filtered or unexported fields
}

func NewNode

func NewNode(cfg ServerConfig) *Node

func (*Node) HandleTransaction

func (n *Node) HandleTransaction(ctx context.Context, tx *proto.Transaction) (*proto.Ack, error)

func (*Node) Handshake

func (n *Node) Handshake(ctx context.Context, v *proto.Version) (*proto.Version, error)

func (*Node) Start

func (n *Node) Start(listenAddr string, bootstrapNodes []string) error

type ServerConfig

type ServerConfig struct {
	Version    string
	ListenAddr string
	PrivateKey *crypto.PrivateKey
}

type TXStorer

type TXStorer interface {
	Put(*proto.Transaction) error
	Get(string) (*proto.Transaction, error)
}

type UTXO

type UTXO struct {
	Hash     string
	OutIndex int
	Amount   int64
	Spent    bool
}

type UTXOStorer

type UTXOStorer interface {
	Put(*UTXO) error
	Get(string) (*UTXO, error)
}

Jump to

Keyboard shortcuts

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