storage

package
v0.0.0-...-8369a04 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("not found")
	ErrBlockSequence = errors.New("block sequence")
)
View Source
var (
	ErrNotExist   = fs.ErrNotExist
	ErrExist      = fs.ErrExist
	ErrPermission = fs.ErrPermission
	ErrIsDir      = errors.New("not a file")
	ErrNotDir     = errors.New("not a directory")
	ErrSize       = errors.New("file has wrong size")
)
View Source
var ErrMempool = errors.New("mempool")

Functions

func CheckOrCreateDir

func CheckOrCreateDir(fsx iFS, path string) error

func GenesisBlock

func GenesisBlock(network string) (block umi.Block)

Types

type Blockchain

type Blockchain struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewBlockchain

func NewBlockchain(conf *config.Config) *Blockchain

func (*Blockchain) AppendBlock

func (bc *Blockchain) AppendBlock(block umi.Block) error

func (*Blockchain) Block

func (bc *Blockchain) Block(height uint32) (umi.Block, error)

func (*Blockchain) Close

func (bc *Blockchain) Close()

func (*Blockchain) Height

func (bc *Blockchain) Height() int

func (*Blockchain) OpenOrCreate

func (bc *Blockchain) OpenOrCreate() (err error)

func (*Blockchain) Scan

func (bc *Blockchain) Scan(confirmer iConfirmer) error

func (*Blockchain) StreamBlocks

func (bc *Blockchain) StreamBlocks(writer io.Writer, height, limit uint32)

func (*Blockchain) Subscribe

func (bc *Blockchain) Subscribe(ch chan umi.Block)

func (*Blockchain) Transaction

func (bc *Blockchain) Transaction(blockHeight uint32, txIndex uint16) (umi.Transaction, bool)

type BlockchainMemory

type BlockchainMemory struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewBlockchainMemory

func NewBlockchainMemory(conf *config.Config) *BlockchainMemory

func (*BlockchainMemory) AppendBlock

func (bc *BlockchainMemory) AppendBlock(block umi.Block) error

func (*BlockchainMemory) Block

func (bc *BlockchainMemory) Block(height uint32) (umi.Block, error)

func (*BlockchainMemory) Close

func (*BlockchainMemory) Close()

func (*BlockchainMemory) Height

func (bc *BlockchainMemory) Height() int

func (*BlockchainMemory) OpenOrCreate

func (bc *BlockchainMemory) OpenOrCreate() error

func (*BlockchainMemory) Scan

func (*BlockchainMemory) Scan(iConfirmer) error

func (*BlockchainMemory) StreamBlocks

func (bc *BlockchainMemory) StreamBlocks(writer io.Writer, height, limit uint32)

func (*BlockchainMemory) Subscribe

func (bc *BlockchainMemory) Subscribe(ch chan umi.Block)

func (*BlockchainMemory) Transaction

func (bc *BlockchainMemory) Transaction(blockHeight uint32, txIndex uint16) (umi.Transaction, bool)

type BlockchainMmap

type BlockchainMmap struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewBlockchainMmap

func NewBlockchainMmap(config1 *config.Config) *BlockchainMmap

func (*BlockchainMmap) AppendBlock

func (bc *BlockchainMmap) AppendBlock(blk umi.Block) error

func (*BlockchainMmap) Block

func (bc *BlockchainMmap) Block(height uint32) (umi.Block, error)

func (*BlockchainMmap) Close

func (bc *BlockchainMmap) Close()

func (*BlockchainMmap) FastScan

func (bc *BlockchainMmap) FastScan()

func (*BlockchainMmap) Height

func (bc *BlockchainMmap) Height() int

func (*BlockchainMmap) OpenOrCreate

func (bc *BlockchainMmap) OpenOrCreate() error

func (*BlockchainMmap) StreamBlocks

func (bc *BlockchainMmap) StreamBlocks(writer io.Writer, height, limit uint32)

func (*BlockchainMmap) Subscribe

func (bc *BlockchainMmap) Subscribe(ch chan umi.Block)

func (*BlockchainMmap) Transaction

func (bc *BlockchainMmap) Transaction(blockHeight uint32, txIndex uint16) (umi.Transaction, bool)

type FSx

type FSx struct{}

func NewFSx

func NewFSx() *FSx

func (FSx) Create

func (FSx) Create(name string) (file IFile, err error)

func (FSx) MkdirAll

func (FSx) MkdirAll(path string, perm fs.FileMode) error

func (FSx) OpenFile

func (FSx) OpenFile(name string) (IFile, error)

func (FSx) Stat

func (FSx) Stat(name string) (fi fs.FileInfo, err error)

type IBlockchain

type IBlockchain interface {
	OpenOrCreate() error
	Close()
	Subscribe(chan umi.Block)
	Scan(confirmer iConfirmer) error
	AppendBlock(umi.Block) error
	Block(uint32) (umi.Block, error)
	Transaction(uint32, uint16) (umi.Transaction, bool)
	StreamBlocks(io.Writer, uint32, uint32)
	Height() int
}

type IFile

type IFile interface {
	io.WriteCloser
	io.WriterAt
	io.ReaderAt
	Stat() (fs.FileInfo, error)
}

func CreateAndFillFile

func CreateAndFillFile(fsx iFS, name string, size int) (file IFile, err error)

func OpenOrCreateFile

func OpenOrCreateFile(fsx iFS, name string, size int) (file IFile, err error)

type Index

type Index struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewIndex

func NewIndex() *Index

func (*Index) SubscribeTo

func (index *Index) SubscribeTo(subscriber iSubscriber)

func (*Index) TransactionsByAddress

func (index *Index) TransactionsByAddress(address umi.Address) (txs *[]uint64, ok bool)

func (*Index) Worker

func (index *Index) Worker(ctx context.Context)

type Mempool

type Mempool struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMempool

func NewMempool() *Mempool

func (*Mempool) Mempool

func (mempool *Mempool) Mempool() (transactions []*umi.Transaction)

func (*Mempool) ParseBlock

func (mempool *Mempool) ParseBlock(block umi.Block)

func (*Mempool) Push

func (mempool *Mempool) Push(transaction umi.Transaction) error

func (*Mempool) SetLedger

func (mempool *Mempool) SetLedger(ledger1 iLedger)

func (*Mempool) Subscribe

func (mempool *Mempool) Subscribe(ch chan *umi.Transaction)

func (*Mempool) SubscribeTo

func (mempool *Mempool) SubscribeTo(subscriber iSubscriber)

func (*Mempool) Transactions

func (mempool *Mempool) Transactions(address umi.Address) (transactions []*umi.Transaction)

func (*Mempool) UnconfirmedBalance

func (mempool *Mempool) UnconfirmedBalance(address umi.Address) int64

func (*Mempool) Worker

func (mempool *Mempool) Worker(ctx context.Context)

Jump to

Keyboard shortcuts

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