block

package
v0.0.0-...-bcfd2cf Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsHash

func IsHash(text string) bool

IsHash returns true is the string is a block hash

func IsHeight

func IsHeight(arg string) bool

IsHeight returns true is the string a block height

func NewService

func NewService(k kv.DB, c *cache.Cache) *service

NewService instantiates a new Service layer for customer

func Routes

func Routes(g *echo.Group, s Service)

Routes mounts all /block, /blocks and /block-height based routes on the main group

Types

type Block

type Block struct {
	ID                string    `json:"id,omitempty"`
	Height            int32     `json:"height,omitempty"`
	Version           int32     `json:"version,omitempty"`
	Timestamp         time.Time `json:"timestamp,omitempty"`
	Bits              uint32    `json:"bits,omitempty"`
	Nonce             uint32    `json:"nonce,omitempty"`
	MerkleRoot        string    `json:"merkle_root,omitempty"`
	Transactions      []string  `json:"transactions,omitempty"`
	TxCount           int       `json:"tx_count,omitempty"`
	Size              int       `json:"size,omitempty"`
	Weight            int       `json:"weight,omitempty"`
	Previousblockhash string    `json:"previousblockhash,omitempty"`
}

Block model defined by standard

type BlockOut

type BlockOut struct {
	Block
	Transactions []tx.Tx `json:"transactions"`
}

BlockOut enhanced model block with full transactions

type Service

type Service interface {
	StoreBlock(b *Block, txs []tx.Tx) (err error)
	ReadFromHeight(height int32) (block Block, err error)
	ReadHeight() (height int32, err error)
	GetFromHash(hash string) (Block, error)
	GetFromHeight(height int32) (*BlockOut, error)
	GetFromHashWithTxs(hash string) (*BlockOut, error)
	GetLast() (*BlockOut, error)
	GetFromHeightRange(height int32, first int) (blocks []BlockOut, err error)
	GetStored() (blocks []Block, err error)
	GetStoredList(from int32) (blocks map[string]interface{}, err error)
	Remove(block *Block) error
	RemoveLast() error
	GetStoredTxs() (transactions []string, err error)
	GetTxBlock(hash string) (block *BlockOut, err error)
	GetTxBlockHeight(hash string) (height int32, err error)
}

Service interface exports available methods for tx service

Jump to

Keyboard shortcuts

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