Documentation ¶
Index ¶
- type Account
- type Payload
- type PrivateData
- type State
- func (s *State) AddAccount(account *Account) error
- func (s *State) AddPayload(data *Payload) error
- func (s *State) GetAccount(id string) (*Account, error)
- func (s *State) GetAccountPubKey(id string) (*crypto.Key, error)
- func (s *State) GetPayload(id string) (*Payload, error)
- func (s *State) HasAccount(id string) bool
- func (s *State) HasPayload(id string) bool
- func (s *State) ListAccounts() (result []*Account, err error)
- func (s *State) SearchAccounts(query interface{}, limit, offset int) (result []*Account, err error)
- func (s *State) SearchPayloads(query interface{}, limit, offset int) (result []*Payload, err error)
- func (s *State) SetAccount(account *Account) error
- func (s *State) SetPayload(data *Payload) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { ID string `msg:"_id" json:"_id" mapstructure:"_id" bson:"_id"` PubKey string `msg:"public_key" json:"public_key" mapstructure:"public_key" bson:"public_key"` }
Account struct keeps account related fields.
type Payload ¶
type Payload struct { ID string `msg:"_id" json:"_id" mapstructure:"_id" bson:"_id"` SenderAccountID string `msg:"sender_account_id" json:"sender_account_id" mapstructure:"sender_account_id" bson:"sender_account_id"` PublicData interface{} `msg:"public_data" json:"public_data" mapstructure:"public_data" bson:"public_data"` PrivateData []*PrivateData `msg:"private_data" json:"private_data" mapstructure:"private_data" bson:"private_data"` CreatedAt float64 `msg:"created_at" json:"created_at" mapstructure:"created_at" bson:"created_at"` }
Payload struct keeps transaction data related fields.
- PublicData keeps open data of any structure;
- PrivateData keeps encrypted data set by receiver's public key with ECDH algorithm and represented as base64 string;
- CreatedAt is date of object creation in UNIX time (milliseconds).
type PrivateData ¶
type PrivateData struct { ReceiverAccountID string `msg:"receiver_account_id" json:"receiver_account_id" mapstructure:"receiver_account_id" bson:"receiver_account_id"` Data interface{} `msg:"data" json:"data" mapstructure:"data" bson:"data"` }
PrivateData keeps information about receiver and data, encrypted by receiver's public key
type State ¶
State struct contains pointer to MongoDB instance.
func NewStateFromDB ¶
NewStateFromDB method constructs MongoDB state.
func (*State) AddAccount ¶
AddAccount method adds new account if all checks were passed.
func (*State) AddPayload ¶
AddPayload method adds new payload to the state if it not exists.
func (*State) GetAccount ¶
GetAccount method returns account from accounts collection by given accoutn id.
func (*State) GetAccountPubKey ¶
GetAccountPubKey method returns public key by given account id.
func (*State) GetPayload ¶
GetPayload method gets data from state by it identifier.
func (*State) HasAccount ¶
HasAccount method checks if account exists in state or not exists.
func (*State) HasPayload ¶
HasPayload method checks exists payload in state ot not.
func (*State) ListAccounts ¶
ListAccounts method returns all accounts from the state.
func (*State) SearchAccounts ¶ added in v1.2.0
SearchAccounts method returns accounts by given search query, limit and offset parameters.
func (*State) SearchPayloads ¶
SearchPayloads method finds payloads using mongodb query language.
func (*State) SetAccount ¶
SetAccount method adds account in state.
func (*State) SetPayload ¶
SetPayload inserts new payload to state without any checks.