node

package
v0.0.0-...-a41f14b Latest Latest
Warning

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

Go to latest
Published: Jan 7, 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(blockStore BlockStorer, txStore TXStorer) *Chain

func (*Chain) AddBlock

func (c *Chain) AddBlock(block *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(block *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 (h *HeaderList) Add(header *proto.Header)

func (*HeaderList) Get

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

func (*HeaderList) Height

func (h *HeaderList) Height() int

func (*HeaderList) Len

func (h *HeaderList) Len() int

type MemoryBlockStore

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

func NewMemoryBlockStore

func NewMemoryBlockStore() *MemoryBlockStore

func (*MemoryBlockStore) Get

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

func (*MemoryBlockStore) Put

func (m *MemoryBlockStore) Put(block *proto.Block) error

type MemoryTXStore

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

func NewMemoryTXStore

func NewMemoryTXStore() *MemoryTXStore

func (*MemoryTXStore) Get

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

func (*MemoryTXStore) Put

func (m *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 (m *MemoryUTXOStore) Get(hash string) (*UTXO, error)

func (*MemoryUTXOStore) Put

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

type Mempool

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

func NewMempool

func NewMempool() *Mempool

func (*Mempool) Add

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

func (*Mempool) Clear

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

func (*Mempool) Has

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

func (*Mempool) Len

func (m *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