account

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2018 License: Apache-2.0 Imports: 6 Imported by: 16

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 = "accountmapper"
)

Variables

This section is empty.

Functions

func AddressStoreKey

func AddressStoreKey(addr types.Address) []byte

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

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() uint64
	SetNonce(nonce uint64) error
}

func ProtoBaseAccount

func ProtoBaseAccount() Account

type AccountMapper

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

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

func NewAccountMapper

func NewAccountMapper(proto func() Account) *AccountMapper

用给定编码和原型生成mapper

func (*AccountMapper) Copy

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

func (*AccountMapper) DecodeAccount

func (mapper *AccountMapper) DecodeAccount(bz []byte) (acc Account)

func (*AccountMapper) EncodeAccount

func (mapper *AccountMapper) EncodeAccount(acc Account) []byte

func (*AccountMapper) GetAccount

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

从存储中获得账户

func (*AccountMapper) GetNonce

func (mapper *AccountMapper) GetNonce(addr types.Address) (uint64, 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) Name

func (mapper *AccountMapper) Name() string

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 uint64) 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          uint64        `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() uint64

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 uint64) 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