blc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderSet = wire.NewSet(NewBlockSet)

Functions

func IsValidChain

func IsValidChain(blocks []*Block) bool

Types

type Action

type Action int
const (
	QueryLatestAction Action = iota
	QueryAllAction
	ResponseAction
)

type Block

type Block struct {
	Index        int64  `json:"index"`
	PreviousHash string `json:"previousHash"`
	Timestamp    int64  `json:"timestamp"`
	Data         string `json:"data"`
	Hash         string `json:"hash"`
	Address      string `json:"address"`
}

func (*Block) CalHash

func (b *Block) CalHash() string

func (*Block) String

func (b *Block) String() string

type BlockSet

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

func NewBlockSet

func NewBlockSet(address string) *BlockSet

func (*BlockSet) Add

func (bs *BlockSet) Add(b *Block)

func (*BlockSet) Latest

func (bs *BlockSet) Latest() *Block

func (*BlockSet) LatestMessage

func (bs *BlockSet) LatestMessage() []byte

func (*BlockSet) Len

func (bs *BlockSet) Len() int

func (*BlockSet) List

func (bs *BlockSet) List() []*Block

func (*BlockSet) MarshalJSON

func (bs *BlockSet) MarshalJSON() ([]byte, error)

func (*BlockSet) NextBlock

func (bs *BlockSet) NextBlock(data string) *Block

func (*BlockSet) SetBlocks

func (bs *BlockSet) SetBlocks(blocks []*Block)

type ByIndex

type ByIndex []*Block

func (ByIndex) Len

func (b ByIndex) Len() int

func (ByIndex) Less

func (b ByIndex) Less(i, j int) bool

func (ByIndex) Swap

func (b ByIndex) Swap(i, j int)

type ResponseBlockchain

type ResponseBlockchain struct {
	Type Action `json:"type"`
	Data []byte `json:"data"`
}

Jump to

Keyboard shortcuts

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