ainterface

package
v0.0.0-...-7ee7fde Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: Apache-2.0 Imports: 11 Imported by: 9

Documentation

Overview

Copyright (c) 2018-2020. The asimov developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2018-2020. The asimov developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2018-2020. The asimov developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Index

Constants

View Source
const (
	// Round payload = RoundStartUnix 8 bytes + duration 8 bytes
	RoundPayLoad = 16
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetInfo

type AssetInfo struct {
	Exist       bool     `json:"exist"`
	Name        string   `json:"name"`
	Symbol      string   `json:"symbol"`
	Description string   `json:"description"`
	Total       uint64   `json:"total"`
	History     []uint64 `json:"history"`
}

type BlockNode

type BlockNode interface {
	Hash() common.Hash
	StateRoot() common.Hash
	Round() uint32
	Slot() uint16
	Height() int32
	GasUsed() uint64
	GasLimit() uint64
}

type Consensus

type Consensus interface {
	Start() error
	Halt() error
	GetRoundInterval() int64
}

type ContractManager

type ContractManager interface {
	// Init manager by genesis data.
	Init(chain fvm.ChainContext, genesisCoinbaseData []byte) error

	// Get latest contract by height.
	GetActiveContractByHeight(height int32, contractAddr common.Address) *chaincfg.ContractInfo

	GetContractAddressByAsset(
		gas uint64,
		block *asiutil.Block,
		stateDB vm.StateDB,
		chainConfig *params.ChainConfig,
		assets []string) ([]common.Address, bool, uint64)

	GetAssetInfoByAssetId(
		block *asiutil.Block,
		stateDB vm.StateDB,
		chainConfig *params.ChainConfig,
		assets []string) ([]AssetInfo, error)

	// Get fees from state
	GetFees(block *asiutil.Block,
		stateDB vm.StateDB,
		chainConfig *params.ChainConfig) (map[protos.Asset]int32, error)

	// Get template from state
	GetTemplate(block *asiutil.Block,
		gas uint64,
		stateDB vm.StateDB,
		chainConfig *params.ChainConfig,
		category uint16,
		name string) (TemplateWarehouseContent, bool, uint64)

	GetTemplates(block *asiutil.Block,
		gas uint64,
		stateDB vm.StateDB,
		chainConfig *params.ChainConfig,
		getCountFunc string,
		getTemplatesFunc string,
		category uint16,
		pageNo int,
		pageSize int) (int, []TemplateWarehouseContent, error, uint64)

	// Get signed up validators
	GetSignedUpValidators(
		consensus common.Address,
		block *asiutil.Block,
		stateDB vm.StateDB,
		chainConfig *params.ChainConfig,
		miners []string) ([]common.Address, []uint32, error)

	IsLimit(block *asiutil.Block,
		stateDB vm.StateDB, asset *protos.Asset) int

	IsSupport(block *asiutil.Block,
		stateDB vm.StateDB, gasLimit uint64, asset *protos.Asset, address []byte) (bool, uint64)

	DisconnectBlock(block *asiutil.Block)
}

ContractManager provides a generic interface that the is called when system contract state need to be validated and each round started from the tip of the main chain for the purpose of supporting system contracts.

type GetValidatorsCallBack

type GetValidatorsCallBack func([]string) ([]common.Address, []int32, error)

type IBtcClient

type IBtcClient interface {
	GetBitcoinMinerInfo(result interface{}, height int32, count int32) error
	GetBitcoinBlockChainInfo(result interface{}) error
}

type IRoundManager

type IRoundManager interface {
	Init(round uint32, db database.Transactor, c IBtcClient) error
	// let the manager run
	Start()
	Halt()
	GetContract() common.Address

	GetHsMappingByRound(round uint32) (map[string]*ValidatorInfo, error)

	GetRoundInterval(round int64) int64
	GetNextRound(round *Round) (*Round, error)

	HasValidator(validator common.Address) bool
	GetValidators(blockHash common.Hash, round uint32, fn GetValidatorsCallBack) ([]*common.Address, map[common.Address]uint16, error)
}

type Page

type Page struct {
	TotalLength  int `json:"totalLength"`
	TemplateInfo []TemplateWarehouseContent
}

type RegistryCenterContent

type RegistryCenterContent struct {
	Name       string `json:"name"`
	ByteCode   string `json:"byteCode"`
	CreateTime int64  `json:"createTime"`
	Status     uint8  `json:"status"`
}

type Round

type Round struct {
	Round          uint32
	RoundStartUnix int64
	Duration       int64
}

func (*Round) Deserialize

func (round *Round) Deserialize(r io.Reader) error

Deserialize decodes a round from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field.

func (*Round) Serialize

func (round *Round) Serialize(w io.Writer) error

Serialize encodes a round from w into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field.

func (*Round) SerializeSize

func (round *Round) SerializeSize() int

type TemplateWarehouseContent

type TemplateWarehouseContent struct {
	Name         string `json:"name"`
	Key          string `json:"key"`
	CreateTime   int64  `json:"createTime"`
	ApproveCount uint8  `json:"approveCount"`
	RejectCount  uint8  `json:"rejectCount"`
	Reviewers    uint8  `json:"reviewers"`
	Status       uint8  `json:"status"`
}

type ValidatorInfo

type ValidatorInfo struct {
	Address   common.Address
	MinerName string
}

Jump to

Keyboard shortcuts

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