service

package
v0.0.0-...-943aac3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FinalizedWaitingBlockCount = 3
	ChainNewHead               = "chain_newHead"
	ChainFinalizedHead         = "chain_finalizedHead"
	StateStorage               = "state_storage"
	BlockTime                  = 6
)

FinalizedWaitingBlockCount Because when receive chain_finalizedHead, get block still not finalized so set Waiting block count to try avoid

Variables

View Source
var GlobalEventDetail *eventDetailWatcher

Functions

func GetExtrinsicFee

func GetExtrinsicFee(p websocket.WsConn, encodeExtrinsic string) (fee decimal.Decimal, err error)

GetExtrinsicFee

Types

type EventJSONData

type EventJSONData struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	TypeName string `json:"type_name"`
	Value    any    `json:"value"`
}

type JSONData

type JSONData struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	TypeName string `json:"type_name"`
	Value    Value  `json:"value"`
}

type Service

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

func New

func New(ctx context.Context, cfg *config.Config) (*Service, error)

func (*Service) AddEvent

func (s *Service) AddEvent(
	txn *dao.GormDB,
	block *model.ChainBlock,
	e []model.ChainEvent,
	hashMap map[string]string,
	feeMap map[string]decimal.Decimal) (eventCount int, err error)

func (*Service) BlockAsSampleJson

func (s *Service) BlockAsSampleJson(block *model.ChainBlock) *model.SampleBlockJson

func (*Service) CreateChainBlock

func (s *Service) CreateChainBlock(conn websocket.WsConn, hash string, block *rpcModel.Block, event string, spec int, finalized bool) (err error)

func (*Service) EmitLog

func (s *Service) EmitLog(txn *dao.GormDB, blockNum int, l []storage.DecoderLog, finalized bool, validatorList []string) (validator string, err error)

func (*Service) EventByIndex

func (s *Service) EventByIndex(index string) *model.ChainEvent

func (*Service) ExtrinsicsAsJson

func (s *Service) ExtrinsicsAsJson(e *model.ChainExtrinsic) *model.ChainExtrinsicJson

func (*Service) FillBlockData

func (s *Service) FillBlockData(conn websocket.WsConn, blockNum int, finalized bool) (err error)

func (*Service) GetBlockByHash

func (s *Service) GetBlockByHash(hash string) *model.ChainBlock

func (*Service) GetBlockByHashJson

func (s *Service) GetBlockByHashJson(hash string) *model.ChainBlockJson

func (*Service) GetBlockByNum

func (s *Service) GetBlockByNum(num int) *model.ChainBlockJson

func (*Service) GetBlocksSampleByNums

func (s *Service) GetBlocksSampleByNums(page, row int) []model.SampleBlockJson

func (*Service) GetCurrentBlockNum

func (s *Service) GetCurrentBlockNum(c context.Context) (uint64, error)

func (*Service) GetCurrentRuntimeSpecVersion

func (s *Service) GetCurrentRuntimeSpecVersion(blockNum int) int

func (*Service) GetExtrinsicByHash

func (s *Service) GetExtrinsicByHash(hash string) *model.ChainExtrinsic

func (*Service) GetExtrinsicByIndex

func (s *Service) GetExtrinsicByIndex(index string) *model.ExtrinsicDetail

func (*Service) GetExtrinsicDetailByHash

func (s *Service) GetExtrinsicDetailByHash(hash string) *model.ExtrinsicDetail

func (*Service) GetExtrinsicList

func (s *Service) GetExtrinsicList(page, row int, order string, query ...string) ([]*model.ChainExtrinsicJson, int)

func (*Service) RenderEvents

func (s *Service) RenderEvents(page, row int, order string, where ...string) ([]model.ChainEventJson, int)

func (*Service) Subscribe

func (s *Service) Subscribe(ctx context.Context, conn ws.WsConn)

func (*Service) SubstrateRuntimeInfo

func (s *Service) SubstrateRuntimeInfo(spec int) *metadata.Instant

func (*Service) SubstrateRuntimeList

func (s *Service) SubstrateRuntimeList() []model.RuntimeVersion

func (*Service) UpdateBlockData

func (s *Service) UpdateBlockData(conn websocket.WsConn, block *model.ChainBlock, finalized bool) (err error)

func (*Service) ValidatorsList

func (s *Service) ValidatorsList(conn websocket.WsConn, hash string) (validatorList []string)

type Solution

type Solution struct {
	Chunk            string `json:"chunk"`
	ChunkWitness     string `json:"chunk_witness"`
	HistorySize      int    `json:"history_size"`
	PieceOffset      int    `json:"piece_offset"`
	ProofOfSpace     string `json:"proof_of_space"`
	PublicKey        string `json:"public_key"`
	RecordCommitment string `json:"record_commitment"`
	RecordWitness    string `json:"record_witness"`
	RewardAddress    string `json:"reward_address"`
	SectorIndex      int    `json:"sector_index"`
}

type SubscribeService

type SubscribeService struct {
	*Service
	// contains filtered or unexported fields
}

type V0

type V0 struct {
	FutureProofOfTime string   `json:"future_proof_of_time"`
	Height            int      `json:"height"`
	ParentHash        string   `json:"parent_hash"`
	ProofOfTime       string   `json:"proof_of_time"`
	Slot              int      `json:"slot"`
	Solution          Solution `json:"solution"`
}

type Value

type Value struct {
	Signature string `json:"signature"`
	Vote      Vote   `json:"vote"`
}

type Vote

type Vote struct {
	V0 V0 `json:"V0"`
}

Jump to

Keyboard shortcuts

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