core

package
v1.6.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: MIT, Apache-2.0, MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const StringEmpty = ""

Variables

View Source
var MethodNameList []types.MethodName
View Source
var MethodNamesMap = make(map[string]struct{})
View Source
var MethodsMap = chain.MethodsMap
View Source
var (
	NilAddress = Address{}
)
View Source
var RandSignBytes = func() []byte {
	randSignBytes, err := ioutil.ReadAll(io.LimitReader(rand.Reader, 32))
	if err != nil {
		panic(fmt.Errorf("rand secret failed %v", err))
	}

	return randSignBytes
}()
View Source
var SupportedMsgTypes = map[types.MsgType]*Types{
	types.MTDealProposal: {reflect.TypeOf(market.DealProposal{}), func(i interface{}) ([]byte, error) {
		return cborutil.Dump(i)
	}, nil},
	types.MTClientDeal: {reflect.TypeOf(market.ClientDealProposal{}), func(in interface{}) ([]byte, error) {
		ni, err := cborutil.AsIpld(in)
		if err != nil {
			return nil, err
		}
		return ni.Cid().Bytes(), nil
	}, nil},
	types.MTDrawRandomParam: {reflect.TypeOf(types2.DrawRandomParams{}), func(in interface{}) ([]byte, error) {
		param := in.(*types2.DrawRandomParams)
		return param.SignBytes()
	}, nil},
	types.MTSignedVoucher: {reflect.TypeOf(paych.SignedVoucher{}), func(in interface{}) ([]byte, error) {
		return (in.(*paych.SignedVoucher)).SigningBytes()
	}, nil},
	types.MTStorageAsk: {reflect.TypeOf(storagemarket.StorageAsk{}), func(in interface{}) ([]byte, error) {
		return cborutil.Dump(in)
	}, nil},
	types.MTAskResponse: {Type: reflect.TypeOf(network.AskResponse{}), /* contains filtered or unexported fields */},
	types.MTNetWorkResponse: {reflect.TypeOf(network.Response{}), func(in interface{}) ([]byte, error) {
		return cborutil.Dump(in)
	}, nil},

	types.MTBlock: {reflect.TypeOf(types.BlockHeader{}), func(in interface{}) ([]byte, error) {
		return in.(*types.BlockHeader).SignatureData()
	}, nil},
	types.MTChainMsg: {reflect.TypeOf(types.Message{}), func(in interface{}) ([]byte, error) {
		msg := in.(*types.Message)
		return msg.Cid().Bytes(), nil
	}, nil},
	types.MTProviderDealState: {reflect.TypeOf(storagemarket.ProviderDealState{}), func(in interface{}) ([]byte, error) {
		return cborutil.Dump(in)
	}, nil,
	},

	types.MTUnknown: {reflect.TypeOf([]byte{}), func(in interface{}) ([]byte, error) {
		msg, isok := in.([]byte)
		if !isok {
			return nil, fmt.Errorf("MTUnkown must be []byte")
		}
		return msg, nil
	}, func(in []byte, meta types.MsgMeta) (interface{}, error) {
		if meta.Type == types.MTUnknown {
			return in, nil
		}
		return nil, fmt.Errorf("un-expected MsgType:%s", meta.Type)
	}},
	types.MTVerifyAddress: {
		Type: reflect.TypeOf([]byte{}),
		// contains filtered or unexported fields
	},
}

signature type factory

Functions

func AggregateMethodNames

func AggregateMethodNames(methods []types.MethodName) ([]types.MethodName, error)

func ContextStrategyToken

func ContextStrategyToken(ctx context.Context) string

func GetMethodName

func GetMethodName(actCode Cid, method MethodNum) (string, error)

func GetSignBytes

func GetSignBytes(toSign []byte, meta types.MsgMeta) (interface{}, []byte, error)

Matches the type and returns the data that needs to be signed

func RegistSupportedMsgTypes

func RegistSupportedMsgTypes(msgType types.MsgType, p reflect.Type,
	fGetSignBytes FGetSignBytes, fParseObj FParseObj) (replaced bool)

Types

type Address

type Address = address.Address

type Cid

type Cid = cid.Cid

type ContextKey

type ContextKey string
const CtxKeyStrategy ContextKey = "strategy"

ctx key of strategy token

type EmptyValue

type EmptyValue struct{}

type FGetSignBytes

type FGetSignBytes func(in interface{}) ([]byte, error)

type FParseObj

type FParseObj func([]byte, types.MsgMeta) (interface{}, error)

type MethodNum

type MethodNum = abi.MethodNum

type Signature

type Signature = crypto.Signature

type StrategyLevel

type StrategyLevel = uint8
const (
	// default level, no strategy
	SLDisable StrategyLevel = iota
	// level 1, check struct type
	SLMetaType
	// level 2, check struct type and method in msg
	SLMethod
)
var WalletStrategyLevel StrategyLevel

wallet strategy level, it will be initialized from config at startup

type Types

type Types struct {
	Type reflect.Type
	// contains filtered or unexported fields
}

Abstract data types to be signed

Jump to

Keyboard shortcuts

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