chain

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SignedBlockType eos.SignedBlockType
	SignedBlockType = eos.SignedBlockType
	// GoAwayMessageType eos.GoAwayMessageType
	GoAwayMessageType = eos.GoAwayMessageType
)

Variables

View Source
var (
	// ErrChainFork error by block fork in chain
	ErrChainFork = errors.New("errorChainFork")
)
View Source
var TypeSize = eos.TypeSize

TypeSize size for eos types

Functions

func IsSamePubKey

func IsSamePubKey(p1, p2 PublicKey) bool

IsSamePubKey p1 == p2

func MarshalBinary

func MarshalBinary(v interface{}) ([]byte, error)

MarshalBinary call eos MarshalBinary

Types

type AccountName

type AccountName = eos.AccountName

AccountName eos.AccountName

func AN

func AN(in string) AccountName

AN from string to account name

type ActMsgHandler

type ActMsgHandler func(act *ActionMsg)

ActMsgHandler act msg handler func type

type Action

type Action = eos.Action

Action chain action

type ActionMsg

type ActionMsg struct {
	BlockNum      uint32
	BlockID       Checksum256
	TransactionID Checksum256
	Timestamp     time.Time
	Act           Action
}

ActionMsg msg when a action is committed to the chain

type ActionName

type ActionName = eos.ActionName

ActionName eos.ActionName

func ActN

func ActN(in string) ActionName

ActN from string to action name

type BlkMsgHandler

type BlkMsgHandler func(act *BlockMsg)

BlkMsgHandler blk msg handler func type

type BlockHeader

type BlockHeader = eos.BlockHeader

BlockHeader header data for block

type BlockMsg

type BlockMsg struct {
	Block SignedBlock
}

BlockMsg msg when a block is committed to the chain

type BlockState

type BlockState struct {
	BlockID                          string                    `json:"id"`
	BlockNum                         uint32                    `json:"block_num"`
	DPoSProposedIrreversibleBlockNum uint32                    `json:"dpos_proposed_irreversible_blocknum"`
	DPoSIrreversibleBlockNum         uint32                    `json:"dpos_irreversible_blocknum"`
	ActiveSchedule                   *eos.ProducerSchedule     `json:"active_schedule"`
	BlockrootMerkle                  *MerkleRoot               `json:"blockroot_merkle"`
	ProducerToLastProduced           [][2]EOSNameOrUint32      `json:"producer_to_last_produced"`
	ProducerToLastImpliedIRB         [][2]EOSNameOrUint32      `json:"producer_to_last_implied_irb"`
	BlockSigningKey                  ecc.PublicKey             `json:"block_signing_key"`
	ConfirmCount                     []uint32                  `json:"confirm_count"`
	PendingSchedule                  *PendingSchedule          `json:"pending_schedule"`
	ActivatedProtocolFeatures        map[string][]eos.HexBytes `json:"activated_protocol_features"`
	SignedBlock                      *eos.SignedBlock          `json:"block"`
	Validated                        bool                      `json:"validated"`
}

BlockState block detail state from a signed block data and the chain state

func NewBlockStateByBlock

func NewBlockStateByBlock(sb *SignedBlock) *BlockState

NewBlockStateByBlock just tmp imp

type Chain

type Chain struct {
	PendingState      pendingState           `json:"pending"`
	ScheduleProducers ScheduleProducersDatas `json:"scheduleProducers"`
	// contains filtered or unexported fields
}

Chain eosc chain

func New

func New(ctx context.Context, logger *zap.Logger) *Chain

New create chain

func (*Chain) Init

func (c *Chain) Init(genesis *Genesis) error

Init init the chain

func (*Chain) PushBlock

func (c *Chain) PushBlock(b *BlockState) error

PushBlock try to append a block from net to chain, in eosio a block produced by self also need push block, but for a light node, cannot be producer

func (*Chain) Wait

func (c *Chain) Wait()

type Checksum256

type Checksum256 = eos.Checksum256

Checksum256 id

func GetBlockHeaderHash

func GetBlockHeaderHash(block *BlockHeader) Checksum256

GetBlockHeaderHash get block header for verify

func HashCheckSumPair

func HashCheckSumPair(c1, c2 Checksum256) Checksum256

HashCheckSumPair get sha256 hash from c1+c2

func Merkle

func Merkle(ids []Checksum256) Checksum256

Merkle calc merkle hash from checksums

type EOSNameOrUint32

type EOSNameOrUint32 interface{}

type Genesis

type Genesis = chaintype.Genesis

Genesis genesis datas for chain

type GoAwayMessage

type GoAwayMessage = eos.GoAwayMessage

GoAwayMessage eos.GoAwayMessage

type IncrementalMerkle

type IncrementalMerkle struct {
	NodeCount   uint64        `json:"node_count"`
	ActiveNodes []Checksum256 `json:"active_nodes"`
}

IncrementalMerkle incremental tree From github.com/eosspark/eos-go, change checksum type to Checksum256

func (*IncrementalMerkle) Append

func (m *IncrementalMerkle) Append(digest Checksum256) Checksum256

Append Add a node to the incremental tree and recalculate the _active_nodes so they are prepared for the next append.

func (IncrementalMerkle) GetRoot

func (m IncrementalMerkle) GetRoot() Checksum256

GetRoot return the current root of the incremental merkle

func (IncrementalMerkle) IsEmpty

func (m IncrementalMerkle) IsEmpty() bool

IsEmpty if is empty

type MerkleRoot

type MerkleRoot struct {
	ActiveNodes []string `json:"_active_nodes"`
	NodeCount   uint32   `json:"_node_count"`
}

type Packet

type Packet = eos.Packet

Packet eos.Packet

type PendingSchedule

type PendingSchedule struct {
	ScheduleLIBNum uint32            `json:"schedule_lib_num"`
	ScheduleHash   eos.HexBytes      `json:"schedule_hash"`
	Schedule       *ProducerSchedule `json:"schedule"`
}

type PermissionName

type PermissionName = eos.PermissionName

PermissionName eos.PermissionName

func PN

func PN(in string) PermissionName

PN from string to permission name

type PrivateKey

type PrivateKey = ecc.PrivateKey

PrivateKey ecc.PrivateKey

type ProducerKey

type ProducerKey = eos.ProducerKey

ProducerKey eos ProducerKey type

type ProducerSchedule

type ProducerSchedule = eos.ProducerSchedule

ProducerSchedule eos ProducerSchedule type

type PublicKey

type PublicKey = ecc.PublicKey

PublicKey ecc.PublicKey

func MustNewPublicKey

func MustNewPublicKey(pubKey string) PublicKey

MustNewPublicKey call ecc MustNewPublicKey

type SHA256Bytes

type SHA256Bytes = Checksum256

SHA256Bytes for sha256 from eosio lib

type ScheduleProducersDatas

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

ScheduleProducersDatas all schedule producers datas by version

func (*ScheduleProducersDatas) GetScheduleProducer

func (s *ScheduleProducersDatas) GetScheduleProducer(version uint32, name AccountName) (ProducerKey, error)

GetScheduleProducer get producer by version and account name

func (*ScheduleProducersDatas) GetScheduleProducersHash

func (s *ScheduleProducersDatas) GetScheduleProducersHash() Checksum256

GetScheduleProducersHash get schedule producers hash for check

func (*ScheduleProducersDatas) Init

func (s *ScheduleProducersDatas) Init(genesis *Genesis)

Init init producers in chain boot

func (*ScheduleProducersDatas) OnBlock

func (s *ScheduleProducersDatas) OnBlock(msg *SignedBlock) error

OnBlock on block to update datas

type ScopeName

type ScopeName = eos.ScopeName

ScopeName eos.ScopeName

type SignedBlock

type SignedBlock = eos.SignedBlock

SignedBlock Signed block in chain, for a light node, all block will be signed from others

type TableName

type TableName = eos.TableName

TableName eos.TableName

type Transaction

type Transaction = eos.Transaction

Transaction chain transaction

type TransactionMsg

type TransactionMsg struct {
	BlockNum  uint32
	BlockID   Checksum256
	Timestamp time.Time
	Trx       Transaction
}

TransactionMsg msg when a transaction is committed to the chain

type TrxMsgHandler

type TrxMsgHandler func(act *TransactionMsg)

TrxMsgHandler trx msg handler func type

Jump to

Keyboard shortcuts

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