jsonblock

package
v0.0.0-...-a4a6c37 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HardCodedJsonBlock

func HardCodedJsonBlock(height int64) string

func HardCodedJsonBlockCount

func HardCodedJsonBlockCount() int64

func TestGenesisHandle_helper

func TestGenesisHandle_helper(blockchain chainreadinterface.IBlockChain, t *testing.T)

func TestInvalidHandle_helper

func TestInvalidHandle_helper(blockchain chainreadinterface.IBlockChain, t *testing.T)

func TestJustFiveCoinbaseBlocks_helper

func TestJustFiveCoinbaseBlocks_helper(blockchain chainreadinterface.IBlockChain, t *testing.T)

Types

type BlockHandle

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

func (*BlockHandle) Hash

func (bh *BlockHandle) Hash() (indexedhashes.Sha256, error)

func (*BlockHandle) HashSpecified

func (bh *BlockHandle) HashSpecified() bool

func (*BlockHandle) Height

func (bh *BlockHandle) Height() int64

func (*BlockHandle) HeightSpecified

func (bh *BlockHandle) HeightSpecified() bool

func (*BlockHandle) IsBlockHandle

func (bh *BlockHandle) IsBlockHandle()

func (*BlockHandle) IsInvalid

func (bh *BlockHandle) IsInvalid() bool

type HardCodedBlockFetcher

type HardCodedBlockFetcher struct {
}

func (*HardCodedBlockFetcher) CountBlocks

func (fbf *HardCodedBlockFetcher) CountBlocks() (int64, error)

func (*HardCodedBlockFetcher) FetchBlockJsonBytes

func (fbf *HardCodedBlockFetcher) FetchBlockJsonBytes(height int64) ([]byte, error)

type IBlockJsonFetcher

type IBlockJsonFetcher interface {
	CountBlocks() (int64, error)
	FetchBlockJsonBytes(height int64) ([]byte, error)
}

IBlockJsonFetcher describes an object that serves each block as json bytes

type ITransIndicesPath

type ITransIndicesPath interface {
	BlockHeight() int64
	NthTransInBlock() int64
}

type ITransLocatorByHash

type ITransLocatorByHash interface {
	GetTransIndicesPathByHash(sha256 indexedhashes.Sha256) (ITransIndicesPath, error)
}

ITransLocatorByHash describes an object that obtains a transaction's Indices Path (block/trans) based on hash

type ITransLocatorStore

type ITransLocatorStore interface {
	ITransLocatorByHash
	StoreIndicesPathForHash(sha256 indexedhashes.Sha256, blockHeight int64, nthTransInBlock int64) error
}

ITransLocatorStore describes an object that stores and retrieves transactions' Indices Path (block/trans) based on hash

func CreateOpenTransLocationStore

func CreateOpenTransLocationStore(folderName string) ITransLocatorStore

type JsonBlockEssential

type JsonBlockEssential struct {
	J_height int                  `json:"height"`
	J_hash   string               `json:"hash"`
	J_tx     []jsonTransEssential `json:"tx"`
	// contains filtered or unexported fields
}

func (*JsonBlockEssential) Hash

func (*JsonBlockEssential) HashSpecified

func (b *JsonBlockEssential) HashSpecified() bool

func (*JsonBlockEssential) Height

func (b *JsonBlockEssential) Height() int64

func (*JsonBlockEssential) HeightSpecified

func (b *JsonBlockEssential) HeightSpecified() bool

func (*JsonBlockEssential) IsBlockHandle

func (b *JsonBlockEssential) IsBlockHandle()

func (*JsonBlockEssential) IsInvalid

func (b *JsonBlockEssential) IsInvalid() bool

func (*JsonBlockEssential) NthTransaction

func (*JsonBlockEssential) TransactionCount

func (b *JsonBlockEssential) TransactionCount() (int64, error)

type OneBlockChain

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

OneBlockChain - We call it a one block chain, as one block is in memory at any point in time

func CreateOneBlockChain

func CreateOneBlockChain(fetcher IBlockJsonFetcher, foldername string) *OneBlockChain

func (*OneBlockChain) BlockInterface

func (*OneBlockChain) GenesisBlock

func (obc *OneBlockChain) GenesisBlock() chainreadinterface.IBlockHandle

func (*OneBlockChain) GenesisTransaction

func (obc *OneBlockChain) GenesisTransaction() (chainreadinterface.ITransHandle, error)

func (*OneBlockChain) InvalidBlock

func (obc *OneBlockChain) InvalidBlock() chainreadinterface.IBlockHandle

func (*OneBlockChain) InvalidTrans

func (obc *OneBlockChain) InvalidTrans() chainreadinterface.ITransHandle

func (*OneBlockChain) IsBlockTree

func (obc *OneBlockChain) IsBlockTree() bool

func (*OneBlockChain) LatestBlock

func (obc *OneBlockChain) LatestBlock() (chainreadinterface.IBlockHandle, error)

func (*OneBlockChain) LatestTransaction

func (obc *OneBlockChain) LatestTransaction() (chainreadinterface.ITransHandle, error)

func (*OneBlockChain) NextBlock

func (*OneBlockChain) NextTransaction

func (*OneBlockChain) ParentBlock

func (*OneBlockChain) PreviousTransaction

func (*OneBlockChain) TransInterface

func (*OneBlockChain) TxiInterface

func (*OneBlockChain) TxoInterface

type TransHandle

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

func (*TransHandle) Hash

func (th *TransHandle) Hash() (indexedhashes.Sha256, error)

func (*TransHandle) HashSpecified

func (th *TransHandle) HashSpecified() bool

func (*TransHandle) Height

func (th *TransHandle) Height() int64

func (*TransHandle) HeightSpecified

func (th *TransHandle) HeightSpecified() bool

func (*TransHandle) IndicesPath

func (th *TransHandle) IndicesPath() (int64, int64)

func (*TransHandle) IndicesPathSpecified

func (th *TransHandle) IndicesPathSpecified() bool

func (*TransHandle) IsInvalid

func (th *TransHandle) IsInvalid() bool

func (*TransHandle) IsTransHandle

func (th *TransHandle) IsTransHandle()

type TxiHandle

type TxiHandle struct {
	TxxIndicesPath
}

func (*TxiHandle) IndicesPath

func (th *TxiHandle) IndicesPath() (int64, int64, int64)

func (*TxiHandle) IndicesPathSpecified

func (th *TxiHandle) IndicesPathSpecified() bool

func (*TxiHandle) ParentIndex

func (th *TxiHandle) ParentIndex() int64

func (*TxiHandle) ParentSpecified

func (th *TxiHandle) ParentSpecified() bool

func (*TxiHandle) ParentTrans

func (th *TxiHandle) ParentTrans() chainreadinterface.ITransHandle

func (*TxiHandle) TxiHeight

func (th *TxiHandle) TxiHeight() int64

func (*TxiHandle) TxiHeightSpecified

func (th *TxiHandle) TxiHeightSpecified() bool

type TxoHandle

type TxoHandle struct {
	TxxIndicesPath
}

func (*TxoHandle) IndicesPath

func (th *TxoHandle) IndicesPath() (int64, int64, int64)

func (*TxoHandle) IndicesPathSpecified

func (th *TxoHandle) IndicesPathSpecified() bool

func (*TxoHandle) ParentIndex

func (th *TxoHandle) ParentIndex() int64

func (*TxoHandle) ParentSpecified

func (th *TxoHandle) ParentSpecified() bool

func (*TxoHandle) ParentTrans

func (th *TxoHandle) ParentTrans() chainreadinterface.ITransHandle

func (*TxoHandle) TxoHeight

func (th *TxoHandle) TxoHeight() int64

func (*TxoHandle) TxoHeightSpecified

func (th *TxoHandle) TxoHeightSpecified() bool

type TxxIndicesPath

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

TxxIndicesPath specifies block height, nth transaction within block, and vin/vout index (vindex) It is used for TxiHandle and TxoHandle

Jump to

Keyboard shortcuts

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