account

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: Apache-2.0 Imports: 6 Imported by: 16

README

账户定义

版本: v0.1

日期: 2018年09月26日

简介:

账户提供基本的账户信息及相关方法

账户接口
type Account interface {
	GetAddress() types.AccAddress
	SetAddress(addr types.AccAddress) error
	GetPublicKey() crypto.PubKey
	SetPublicKey(pubKey crypto.PubKey) error
	GetNonce() int64
	SetNonce(nonce int64) error
}

数据结构

BaseAccount
type BaseAccount struct {
	AccountAddress types.AccAddress `json:"account_address"` // account address
	Publickey      crypto.PubKey    `json:"public_key"`      // public key
	Nonce          int64            `json:"nonce"`           // identifies tx_status of an account
}

方法规定

  • 获得结构原型
  • getter/setter
  • 注册序列化的方法

Documentation

Index

Constants

View Source
const (
	AccountMapperName = "acc" // 用户获取账户存储的store的键名

)

Variables

This section is empty.

Functions

func AddressStoreKey

func AddressStoreKey(addr types.AccAddress) []byte

将地址转换成存储通用的key

func BuildAccountStoreQueryPath added in v0.0.4

func BuildAccountStoreQueryPath() []byte

func RegisterCodec

func RegisterCodec(cdc *go_amino.Codec)

为包内定义结构注册codec

Types

type Account

type Account interface {
	GetAddress() types.AccAddress
	SetAddress(addr types.AccAddress) error
	GetPublicKey() crypto.PubKey
	SetPublicKey(pubKey crypto.PubKey) error
	GetNonce() int64
	SetNonce(nonce int64) error
}

func ProtoBaseAccount

func ProtoBaseAccount() Account

type AccountMapper

type AccountMapper struct {
	*mapper.BaseMapper
	// contains filtered or unexported fields
}

对BaseAccount存储操作进行包装的结构,可进行序列化

func NewAccountMapper

func NewAccountMapper(cdc *go_amino.Codec, proto func() Account) *AccountMapper

用给定编码和原型生成mapper

func (*AccountMapper) Copy

func (mapper *AccountMapper) Copy() mapper.IMapper

func (*AccountMapper) GetAccount

func (mapper *AccountMapper) GetAccount(addr types.AccAddress) (acc Account)

从存储中获得账户

func (*AccountMapper) GetNonce

func (mapper *AccountMapper) GetNonce(addr types.AccAddress) (int64, types.Error)

获取地址代表账户的nonce

func (*AccountMapper) GetPubKey

func (mapper *AccountMapper) GetPubKey(addr types.AccAddress) (crypto.PubKey, types.Error)

获取地址代表账户的公钥

func (*AccountMapper) IterateAccounts

func (mapper *AccountMapper) IterateAccounts(process func(Account) (stop bool))

遍历并用闭包批量处理所存储的全部账户

func (*AccountMapper) NewAccountWithAddress

func (mapper *AccountMapper) NewAccountWithAddress(add types.AccAddress) Account

用指定地址生成账户返回

func (*AccountMapper) SetAccount

func (mapper *AccountMapper) SetAccount(acc Account)

存储账户

func (*AccountMapper) SetNonce

func (mapper *AccountMapper) SetNonce(addr types.AccAddress, nonce int64) types.Error

为特定账户设置新的nonce值

type BaseAccount

type BaseAccount struct {
	AccountAddress types.AccAddress `json:"account_address"` // account address
	Publickey      crypto.PubKey    `json:"public_key"`      // public key
	Nonce          int64            `json:"nonce"`           // identifies tx_status of an account
}

func (*BaseAccount) GetAddress

func (accnt *BaseAccount) GetAddress() types.AccAddress

getter for account address

func (*BaseAccount) GetNonce

func (accnt *BaseAccount) GetNonce() int64

getter for nonce

func (*BaseAccount) GetPublicKey added in v0.2.4

func (accnt *BaseAccount) GetPublicKey() crypto.PubKey

getter for public key

func (*BaseAccount) MarshalJSON added in v0.2.4

func (accnt *BaseAccount) MarshalJSON() ([]byte, error)

func (*BaseAccount) SetAddress

func (accnt *BaseAccount) SetAddress(addr types.AccAddress) error

setter for account address

func (*BaseAccount) SetNonce

func (accnt *BaseAccount) SetNonce(nonce int64) error

setter for nonce

func (*BaseAccount) SetPublicKey

func (accnt *BaseAccount) SetPublicKey(pubKey crypto.PubKey) error

setter for public key

func (*BaseAccount) UnmarshalJSON added in v0.2.4

func (accnt *BaseAccount) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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