service

package
v0.0.0-...-f5db1f5 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxHeadChangeProcess = 5

	LookBackLimit = 900
)

Variables

View Source
var DefaultMaxFee = venusTypes.MustParseFIL("0.007")
View Source
var ErrRecordExist = xerrors.Errorf("record exist")

Functions

func CapGasFee

func CapGasFee(msg *venusTypes.UnsignedMessage, maxFee abi.TokenAmount)

func DialArgs

func DialArgs(addr string) (string, error)

func MessagerService

func MessagerService() fx.Option

func ToSignedMsg

func ToSignedMsg(ctx context.Context, walletCli IWalletClient, msg *types.Message) (venusTypes.SignedMessage, error)

Types

type AddressInfo

type AddressInfo struct {
	State        types.State
	SelectMsgNum uint64
	WalletClient IWalletClient
}

type AddressService

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

func NewAddressService

func NewAddressService(repo repo.Repo, logger *logrus.Logger) *AddressService

func (*AddressService) DeleteAddress

func (addressService *AddressService) DeleteAddress(ctx context.Context, addr address.Address) (address.Address, error)

func (*AddressService) GetAddress

func (addressService *AddressService) GetAddress(ctx context.Context, addr address.Address) (*types.Address, error)

func (*AddressService) HasAddress

func (addressService *AddressService) HasAddress(ctx context.Context, addr address.Address) (bool, error)

func (*AddressService) ListAddress

func (addressService *AddressService) ListAddress(ctx context.Context) ([]*types.Address, error)

func (*AddressService) SaveAddress

func (addressService *AddressService) SaveAddress(ctx context.Context, address *types.Address) (types.UUID, error)

func (*AddressService) UpdateAddress

func (addressService *AddressService) UpdateAddress(ctx context.Context, address *types.Address) error

func (*AddressService) UpdateNonce

func (addressService *AddressService) UpdateNonce(ctx context.Context, addr address.Address, nonce uint64) (address.Address, error)

type IWalletClient

type IWalletClient interface {
	WalletList(context.Context) ([]address.Address, error)
	WalletHas(context.Context, address.Address) (bool, error)
	WalletSign(ctx context.Context, signer address.Address, toSign []byte, meta core.MsgMeta) (*crypto.Signature, error)
}

type MemWallet

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

func NewMemWallet

func NewMemWallet() *MemWallet

just for test

func (*MemWallet) WalletHas

func (memWallet *MemWallet) WalletHas(ctx context.Context, addr address.Address) (bool, error)

func (*MemWallet) WalletList

func (memWallet *MemWallet) WalletList(ctx context.Context) ([]address.Address, error)

func (*MemWallet) WalletSign

func (memWallet *MemWallet) WalletSign(ctx context.Context, addr address.Address, data []byte, meta core.MsgMeta) (*crypto.Signature, error)

type MessageSelector

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

func NewMessageSelector

func NewMessageSelector(repo repo.Repo,
	log *logrus.Logger,
	cfg *config.MessageServiceConfig,
	nodeClient *NodeClient,
	addressService *AddressService,
	walletService *WalletService,
	sps *SharedParamsService) *MessageSelector

func (*MessageSelector) GasEstimateMessageGas

func (messageSelector *MessageSelector) GasEstimateMessageGas(ctx context.Context, msg *venusTypes.UnsignedMessage, meta *types.MsgMeta, tsk venusTypes.TipSetKey) (*venusTypes.UnsignedMessage, error)

func (*MessageSelector) SelectMessage

func (messageSelector *MessageSelector) SelectMessage(ctx context.Context, ts *venusTypes.TipSet) (*MsgSelectResult, error)

type MessageService

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

func NewMessageService

func NewMessageService(repo repo.Repo,
	nc *NodeClient,
	logger *logrus.Logger,
	cfg *config.MessageServiceConfig,
	messageState *MessageState,
	addressService *AddressService,
	walletService *WalletService,
	sps *SharedParamsService,
	nodeService *NodeService) (*MessageService, error)

func (*MessageService) GetMessageByCid

func (ms *MessageService) GetMessageByCid(ctx context.Context, id cid.Cid) (*types.Message, error)

func (*MessageService) GetMessageByFromAndNonce

func (ms *MessageService) GetMessageByFromAndNonce(ctx context.Context, from address.Address, nonce uint64) (*types.Message, error)

func (*MessageService) GetMessageBySignedCid

func (ms *MessageService) GetMessageBySignedCid(ctx context.Context, signedCid cid.Cid) (*types.Message, error)

func (*MessageService) GetMessageByUid

func (ms *MessageService) GetMessageByUid(ctx context.Context, id string) (*types.Message, error)

func (*MessageService) GetMessageByUnsignedCid

func (ms *MessageService) GetMessageByUnsignedCid(ctx context.Context, unsignedCid cid.Cid) (*types.Message, error)

func (*MessageService) GetMessageState

func (ms *MessageService) GetMessageState(ctx context.Context, id string) (types.MessageState, error)

func (*MessageService) HasMessageByUid

func (ms *MessageService) HasMessageByUid(ctx context.Context, id string) (bool, error)

func (*MessageService) ListBlockedMessage

func (ms *MessageService) ListBlockedMessage(ctx context.Context, addr address.Address, d time.Duration) ([]*types.Message, error)

func (*MessageService) ListFailedMessage

func (ms *MessageService) ListFailedMessage(ctx context.Context) ([]*types.Message, error)

func (*MessageService) ListFilledMessageByAddress

func (ms *MessageService) ListFilledMessageByAddress(ctx context.Context, addr address.Address) ([]*types.Message, error)

func (*MessageService) ListMessage

func (ms *MessageService) ListMessage(ctx context.Context) ([]*types.Message, error)

func (*MessageService) ListMessageByAddress

func (ms *MessageService) ListMessageByAddress(ctx context.Context, addr address.Address) ([]*types.Message, error)

func (*MessageService) ListMessageByFromState

func (ms *MessageService) ListMessageByFromState(ctx context.Context, from address.Address, state types.MessageState, pageIndex, pageSize int) ([]*types.Message, error)

func (*MessageService) MarkBadMessage

func (ms *MessageService) MarkBadMessage(ctx context.Context, id string) (struct{}, error)

func (*MessageService) ProcessNewHead

func (ms *MessageService) ProcessNewHead(ctx context.Context, apply, revert []*venusTypes.TipSet) error

func (*MessageService) PushMessage

func (ms *MessageService) PushMessage(ctx context.Context, msg *types.Message) error

func (*MessageService) ReconnectCheck

func (ms *MessageService) ReconnectCheck(ctx context.Context, head *venusTypes.TipSet) error

func (*MessageService) ReplaceMessage

func (ms *MessageService) ReplaceMessage(ctx context.Context, id string, auto bool, maxFee string, gasLimit int64, gasPremium string, gasFeecap string) (cid.Cid, error)

func (*MessageService) RepublishMessage

func (ms *MessageService) RepublishMessage(ctx context.Context, id string) (struct{}, error)

func (*MessageService) StartPushMessage

func (ms *MessageService) StartPushMessage(ctx context.Context)

func (*MessageService) UpdateAllFilledMessage

func (ms *MessageService) UpdateAllFilledMessage(ctx context.Context) (int, error)

func (*MessageService) UpdateMessageInfoByCid

func (ms *MessageService) UpdateMessageInfoByCid(unsignedCid string, receipt *venusTypes.MessageReceipt,
	height abi.ChainEpoch, state types.MessageState, tsKey venusTypes.TipSetKey) (string, error)

func (*MessageService) UpdateMessageStateByCid

func (ms *MessageService) UpdateMessageStateByCid(ctx context.Context, cid string, state types.MessageState) (string, error)

func (*MessageService) UpdateMessageStateByID

func (ms *MessageService) UpdateMessageStateByID(ctx context.Context, id string, state types.MessageState) (string, error)

func (*MessageService) UpdateSignedMessageByID

func (ms *MessageService) UpdateSignedMessageByID(ctx context.Context, id string) (string, error)

type MessageState

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

func NewMessageState

func NewMessageState(repo repo.Repo, logger *logrus.Logger, cfg *config.MessageStateConfig) (*MessageState, error)

func (*MessageState) DeleteMessage

func (ms *MessageState) DeleteMessage(id string)

func (*MessageState) GetMessage

func (ms *MessageState) GetMessage(id string) (*types.Message, bool)

func (*MessageState) GetMessageStateByCid

func (ms *MessageState) GetMessageStateByCid(cid string) (types.MessageState, bool)

func (*MessageState) MutatorMessage

func (ms *MessageState) MutatorMessage(id string, f func(*types.Message) error) error

func (*MessageState) SetMessage

func (ms *MessageState) SetMessage(id string, message *types.Message)

func (*MessageState) UpdateMessageByCid

func (ms *MessageState) UpdateMessageByCid(cid cid.Cid, f func(message *types.Message) error) error

type MsgSelectResult

type MsgSelectResult struct {
	SelectMsg     []*types.Message
	ExpireMsg     []*types.Message
	ToPushMsg     []*venusTypes.SignedMessage
	ModifyAddress []*types.Address
	ErrMsg        []msgErrInfo
}

type NodeClient

type NodeClient struct {
	ChainNotify            func(context.Context) (<-chan []*chain.HeadChange, error)
	ChainHead              func(context.Context) (*types.TipSet, error)
	ChainGetTipSet         func(context.Context, types.TipSetKey) (*types.TipSet, error)
	ChainGetBlock          func(context.Context, cid.Cid) (*types.BlockHeader, error)
	ChainGetBlockMessages  func(context.Context, cid.Cid) (*chain2.BlockMessages, error)
	ChainGetParentMessages func(ctx context.Context, bcid cid.Cid) ([]chain2.Message, error)
	ChainGetParentReceipts func(context.Context, cid.Cid) ([]*types.MessageReceipt, error)
	StateAccountKey        func(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
	StateSearchMsg         func(context.Context, cid.Cid) (*chain.MsgLookup, error)
	StateGetActor          func(context.Context, address.Address, types.TipSetKey) (*types.Actor, error)

	GasEstimateMessageGas func(context.Context, *types.UnsignedMessage, *types.MessageSendSpec, types.TipSetKey) (*types.UnsignedMessage, error)
	GasEstimateFeeCap     func(context.Context, *types.UnsignedMessage, int64, types.TipSetKey) (big.Int, error)
	GasEstimateGasPremium func(context.Context, uint64, address.Address, int64, types.TipSetKey) (big.Int, error)
	GasEstimateGasLimit   func(ctx context.Context, msgIn *types.UnsignedMessage, tsk types.TipSetKey) (int64, error)

	MpoolPush      func(context.Context, *types.SignedMessage) (cid.Cid, error)
	MpoolBatchPush func(context.Context, []*types.SignedMessage) ([]cid.Cid, error)
}

func NewNodeClient

func NewNodeClient(ctx context.Context, cfg *config.NodeConfig) (*NodeClient, jsonrpc.ClientCloser, error)

type NodeEvents

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

func StartNodeEvents

func StartNodeEvents(lc fx.Lifecycle, client *NodeClient, msgService *MessageService, log *logrus.Logger) *NodeEvents

type NodeService

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

func NewNodeService

func NewNodeService(repo repo.Repo, logger *logrus.Logger) *NodeService

func (*NodeService) DeleteNode

func (ns *NodeService) DeleteNode(ctx context.Context, name string) (struct{}, error)

func (*NodeService) GetNode

func (ns *NodeService) GetNode(ctx context.Context, name string) (*types.Node, error)

func (*NodeService) HasNode

func (ns *NodeService) HasNode(ctx context.Context, name string) (bool, error)

func (*NodeService) ListNode

func (ns *NodeService) ListNode(ctx context.Context) ([]*types.Node, error)

func (*NodeService) SaveNode

func (ns *NodeService) SaveNode(ctx context.Context, node *types.Node) (struct{}, error)

type Params

type Params struct {
	*types.SharedParams

	ScanIntervalChan chan time.Duration
}

type ServiceMap

type ServiceMap map[reflect.Type]interface{}

func MakeServiceMap

func MakeServiceMap(msgService *MessageService,
	walletService *WalletService,
	addressService *AddressService,
	sps *SharedParamsService,
	nodeService *NodeService) ServiceMap

type SharedParamsService

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

func NewSharedParamsService

func NewSharedParamsService(repo repo.Repo, logger *logrus.Logger) (*SharedParamsService, error)

func (*SharedParamsService) GetParams

func (sps *SharedParamsService) GetParams() *Params

func (*SharedParamsService) GetSharedParams

func (sps *SharedParamsService) GetSharedParams(ctx context.Context) (*types.SharedParams, error)

func (*SharedParamsService) RefreshSharedParams

func (sps *SharedParamsService) RefreshSharedParams(ctx context.Context) (struct{}, error)

func (*SharedParamsService) SetParams

func (sps *SharedParamsService) SetParams(sharedParams *types.SharedParams)

func (*SharedParamsService) SetSharedParams

func (sps *SharedParamsService) SetSharedParams(ctx context.Context, params *types.SharedParams) (struct{}, error)

type TipsetCache

type TipsetCache struct {
	Cache      map[int64]*tipsetFormat
	CurrHeight int64
	// contains filtered or unexported fields
}

func (*TipsetCache) AddTs

func (tsCache *TipsetCache) AddTs(list ...*tipsetFormat)

func (*TipsetCache) ExistTs

func (tsCache *TipsetCache) ExistTs(height int64) bool

func (*TipsetCache) ListTs

func (tsCache *TipsetCache) ListTs() tipsetList

func (*TipsetCache) ReduceTs

func (tsCache *TipsetCache) ReduceTs()

func (*TipsetCache) RemoveTs

func (tsCache *TipsetCache) RemoveTs(list []*tipsetFormat)

type WalletClient

type WalletClient struct {
	Internal struct {
		WalletList func(context.Context) ([]address.Address, error)
		WalletHas  func(ctx context.Context, address address.Address) (bool, error)
		WalletSign func(ctx context.Context, signer address.Address, toSign []byte, meta core.MsgMeta) (*crypto.Signature, error)
	}
}

func NewWalletClient

func NewWalletClient(ctx context.Context, url, token string) (WalletClient, jsonrpc.ClientCloser, error)

func (*WalletClient) WalletHas

func (walletClient *WalletClient) WalletHas(ctx context.Context, addr address.Address) (bool, error)

func (*WalletClient) WalletList

func (walletClient *WalletClient) WalletList(ctx context.Context) ([]address.Address, error)

func (*WalletClient) WalletSign

func (walletClient *WalletClient) WalletSign(ctx context.Context, signer address.Address, toSign []byte, meta core.MsgMeta) (*crypto.Signature, error)

type WalletInfo

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

type WalletService

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

func NewWalletService

func NewWalletService(repo repo.Repo,
	logger *logrus.Logger,
	nodeClient *NodeClient,
	addressService *AddressService,
	cfg *config.WalletConfig,
	sps *SharedParamsService) (*WalletService, error)

func (*WalletService) ActiveAddress

func (walletService *WalletService) ActiveAddress(ctx context.Context, walletName string, addr address.Address) (address.Address, error)

func (*WalletService) AllAddresses

func (walletService *WalletService) AllAddresses() map[address.Address]struct{}

func (*WalletService) DeleteWallet

func (walletService *WalletService) DeleteWallet(ctx context.Context, name string) (string, error)

func (*WalletService) ForbiddenAddress

func (walletService *WalletService) ForbiddenAddress(ctx context.Context, walletName string, addr address.Address) (address.Address, error)

func (*WalletService) GetAddressInfo

func (walletService *WalletService) GetAddressInfo(walletName string, addr address.Address) (AddressInfo, bool)

func (*WalletService) GetAddressesInfo

func (walletService *WalletService) GetAddressesInfo(addr address.Address) (map[string]AddressInfo, bool)

func (*WalletService) GetWalletAddress

func (walletService *WalletService) GetWalletAddress(ctx context.Context, walletName string, addr address.Address) (*types.WalletAddress, error)

func (*WalletService) GetWalletByID

func (walletService *WalletService) GetWalletByID(ctx context.Context, uuid types.UUID) (*types.Wallet, error)

func (*WalletService) GetWalletByName

func (walletService *WalletService) GetWalletByName(ctx context.Context, name string) (*types.Wallet, error)

func (*WalletService) HasAddress

func (walletService *WalletService) HasAddress(walletName string, addr address.Address) bool

func (*WalletService) HasWallet

func (walletService *WalletService) HasWallet(ctx context.Context, name string) (bool, error)

func (*WalletService) HasWalletAddress

func (walletService *WalletService) HasWalletAddress(ctx context.Context, walletName string, addr address.Address) (bool, error)

func (*WalletService) ListRemoteWalletAddress

func (walletService *WalletService) ListRemoteWalletAddress(ctx context.Context, walletName string) ([]address.Address, error)

func (*WalletService) ListWallet

func (walletService *WalletService) ListWallet(ctx context.Context) ([]*types.Wallet, error)

func (*WalletService) ListWalletAddress

func (walletService *WalletService) ListWalletAddress(ctx context.Context) ([]*types.WalletAddress, error)

func (*WalletService) ListWalletClient

func (walletService *WalletService) ListWalletClient() ([]string, []IWalletClient)

func (*WalletService) ProcessWallet

func (walletService *WalletService) ProcessWallet(ctx context.Context, walletName string, cli IWalletClient) error

func (*WalletService) SaveWallet

func (walletService *WalletService) SaveWallet(ctx context.Context, wallet *types.Wallet) (types.UUID, error)

func (*WalletService) SetSelectMsgNum

func (walletService *WalletService) SetSelectMsgNum(ctx context.Context, walletName string, addr address.Address, num uint64) (address.Address, error)

Jump to

Keyboard shortcuts

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