account

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: Apache-2.0 Imports: 5 Imported by: 3 modules, 16 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

账户定义

版本: v0.1

日期: 2018年09月26日

简介:

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

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

数据结构

BaseAccount
type BaseAccount struct{
	AccountAddress common.Address `json:"account_address"` // account address
	Publickey      crypto.PubKey  `json:"public_key"`		// public key
	Nonce          uint64         `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.Address) []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.Address
	SetAddress(addr types.Address) error
	GetPubicKey() 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.Address) (acc Account)

从存储中获得账户

func (*AccountMapper) GetNonce

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

获取地址代表账户的nonce

func (*AccountMapper) GetPubKey

func (mapper *AccountMapper) GetPubKey(addr types.Address) (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.Address) Account

用指定地址生成账户返回

func (*AccountMapper) SetAccount

func (mapper *AccountMapper) SetAccount(acc Account)

存储账户

func (*AccountMapper) SetNonce

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

为特定账户设置新的nonce值

type BaseAccount

type BaseAccount struct {
	AccountAddress types.Address `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.Address

getter for account address

func (*BaseAccount) GetNonce

func (accnt *BaseAccount) GetNonce() int64

getter for nonce

func (*BaseAccount) GetPubicKey

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

getter for public key

func (*BaseAccount) SetAddress

func (accnt *BaseAccount) SetAddress(addr types.Address) 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

Jump to

Keyboard shortcuts

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