Documentation ¶
Overview ¶
Package types defines commonly used types for sql-chain.
Index ¶
- Constants
- Variables
- type Account
- type Ack
- type AckHeader
- type AckResponse
- type AddTxReq
- type AddTxResp
- type AdviseNewBlockReq
- type AdviseNewBlockResp
- type BPBlock
- func (b *BPBlock) BlockHash() *hash.Hash
- func (b *BPBlock) GetTxHashes() []*hash.Hash
- func (b *BPBlock) PackAndSignBlock(signer *asymmetric.PrivateKey) error
- func (b *BPBlock) ParentHash() *hash.Hash
- func (b *BPBlock) Producer() proto.AccountAddress
- func (b *BPBlock) SetHash() error
- func (b *BPBlock) Timestamp() time.Time
- func (b *BPBlock) Verify() error
- func (b *BPBlock) VerifyHash() error
- type BPHeader
- type BPSignedHeader
- type BaseAccount
- type Block
- func (b *Block) BlockHash() *hash.Hash
- func (b *Block) CalcNextID() (id uint64, ok bool)
- func (b *Block) GenesisHash() *hash.Hash
- func (b *Block) PackAndSignBlock(signer *ca.PrivateKey) (err error)
- func (b *Block) PackAsGenesis() (err error)
- func (b *Block) ParentHash() *hash.Hash
- func (b *Block) Producer() proto.NodeID
- func (b *Block) Signee() *ca.PublicKey
- func (b *Block) Timestamp() time.Time
- func (b *Block) Verify() (err error)
- func (b *Block) VerifyAsGenesis() (err error)
- type Blocks
- type CreateDatabase
- type CreateDatabaseHeader
- type CreateDatabaseRequest
- type CreateDatabaseRequestHeader
- type CreateDatabaseResponse
- type CreateDatabaseResponseHeader
- type DropDatabaseRequest
- type DropDatabaseRequestHeader
- type DropDatabaseResponse
- type FetchBlockByCountReq
- type FetchBlockReq
- type FetchBlockResp
- type FetchLastIrreversibleBlockReq
- type FetchLastIrreversibleBlockResp
- type FetchTxBillingReq
- type FetchTxBillingResp
- type GetDatabaseRequest
- type GetDatabaseRequestHeader
- type GetDatabaseResponse
- type GetDatabaseResponseHeader
- type Header
- type InitService
- type InitServiceResponse
- type InitServiceResponseHeader
- type IssueKeys
- type IssueKeysHeader
- type MinerIncome
- type MinerInfo
- type MinerKey
- type NamedArg
- type NextAccountNonceReq
- type NextAccountNonceResp
- type OrderMakerReq
- type OrderTakerReq
- type OrderTakerResp
- type PermStat
- type ProvideService
- type ProvideServiceHeader
- type ProviderProfile
- type Query
- type QueryAccountSQLChainProfilesReq
- type QueryAccountSQLChainProfilesResp
- type QueryAccountTokenBalanceReq
- type QueryAccountTokenBalanceResp
- type QueryAsTx
- type QueryKey
- type QuerySQLChainProfileReq
- type QuerySQLChainProfileResp
- type QueryTxStateReq
- type QueryTxStateResp
- type QueryType
- type Range
- type Request
- type RequestHeader
- type RequestPayload
- type ResourceMeta
- type Response
- type ResponseHeader
- type ResponsePayload
- type ResponseRow
- type SQLChainProfile
- type SQLChainRole
- type SQLChainUser
- type ServiceInstance
- type SignedAckHeader
- type SignedCreateDatabaseRequestHeader
- type SignedCreateDatabaseResponseHeader
- type SignedDropDatabaseRequestHeader
- type SignedGetDatabaseRequestHeader
- type SignedGetDatabaseResponseHeader
- type SignedHeader
- type SignedInitServiceResponseHeader
- type SignedRequestHeader
- type SignedResponseHeader
- type SignedUpdateServiceHeader
- type Status
- type SubReq
- type SubResp
- type TokenType
- type Transfer
- type TransferHeader
- type UpdateBilling
- type UpdateBillingHeader
- type UpdatePermission
- type UpdatePermissionHeader
- type UpdateService
- type UpdateServiceHeader
- type UpdateServiceResponse
- type UpdateType
- type UserArrears
- type UserCost
- type UserPermission
- type UserPermissionRole
Constants ¶
const ( // Read defines the read user permission. Read UserPermissionRole = 1 << iota // Write defines the writer user permission. Write // Super defines the super user permission. Super // Invalid defines the invalid permission Invalid // ReadOnly defines the reader user permission. ReadOnly = Read // WriteOnly defines the writer user permission. WriteOnly = Write // ReadWrite defines the reader && writer user permission. ReadWrite = Read | Write // Admin defines the privilege to full control the database. Admin = Read | Write | Super // Void defines the initial permission. Void UserPermissionRole = 0 )
const ( // ReplicateFromBeginning is the replication offset observes from genesis block. ReplicateFromBeginning = int32(0) // ReplicateFromNewest is the replication offset observes from block head of current node. ReplicateFromNewest = int32(-1) )
Variables ¶
var ( // ErrMerkleRootVerification indicates a failed merkle root verificatin. ErrMerkleRootVerification = errors.New("merkle root verification failed") // ErrNodePublicKeyNotMatch indicates that the public key given with a node does not match the // one in the key store. ErrNodePublicKeyNotMatch = errors.New("node publick key doesn't match") // ErrSignVerification indicates a failed signature verification. ErrSignVerification = errors.New("signature verification failed") // ErrBillingNotMatch indicates that the billing request doesn't match the local result. ErrBillingNotMatch = errors.New("billing request doesn't match") // ErrHashVerification indicates a failed hash verification. ErrHashVerification = errors.New("hash verification failed") // ErrInvalidGenesis indicates a failed genesis block verification. ErrInvalidGenesis = errors.New("invalid genesis block") )
var TokenList = map[TokenType]string{ Particle: "Particle", Wave: "Wave", }
TokenList lists supporting token.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { Address proto.AccountAddress TokenBalance [SupportTokenNumber]uint64 Rating float64 NextNonce pi.AccountNonce }
Account store its balance, and other mate data.
type Ack ¶
type Ack struct { proto.Envelope Header SignedAckHeader `json:"h"` }
Ack defines a whole client ack request entity.
type AckHeader ¶
type AckHeader struct { Response ResponseHeader `json:"r"` ResponseHash hash.Hash `json:"rh"` NodeID proto.NodeID `json:"i"` // ack node id Timestamp time.Time `json:"t"` // time in UTC zone }
AckHeader defines client ack entity.
func (*AckHeader) GetQueryKey ¶
GetQueryKey returns the request query key.
func (*AckHeader) GetRequestHash ¶
GetRequestHash returns the request hash.
func (*AckHeader) GetRequestTimestamp ¶
GetRequestTimestamp returns the request timestamp.
func (*AckHeader) GetResponseHash ¶
GetResponseHash returns the response hash.
func (*AckHeader) GetResponseTimestamp ¶
GetResponseTimestamp returns the response timestamp.
type AddTxReq ¶
type AddTxReq struct { proto.Envelope TTL uint32 // defines the broadcast TTL on BP network. Tx interfaces.Transaction }
AddTxReq defines a request of the AddTx RPC method.
type AdviseNewBlockReq ¶
AdviseNewBlockReq defines a request of the AdviseNewBlock RPC method.
type AdviseNewBlockResp ¶
AdviseNewBlockResp defines a response of the AdviseNewBlock RPC method.
type BPBlock ¶
type BPBlock struct { SignedHeader BPSignedHeader Transactions []pi.Transaction }
BPBlock defines the main chain block.
func (*BPBlock) GetTxHashes ¶
GetTxHashes returns all hashes of tx in block.{Billings, ...}.
func (*BPBlock) PackAndSignBlock ¶
func (b *BPBlock) PackAndSignBlock(signer *asymmetric.PrivateKey) error
PackAndSignBlock computes block's hash and sign it.
func (*BPBlock) ParentHash ¶
ParentHash returns the parent hash field of the block header.
func (*BPBlock) Producer ¶
func (b *BPBlock) Producer() proto.AccountAddress
Producer returns the producer of block.
func (*BPBlock) SetHash ¶
SetHash sets the block header hash, including the merkle root of the packed transactions.
func (*BPBlock) VerifyHash ¶
VerifyHash verifies the block header hash, including the merkle root of the packed transactions.
type BPHeader ¶
type BPHeader struct { Version int32 Producer proto.AccountAddress MerkleRoot hash.Hash ParentHash hash.Hash Timestamp time.Time }
BPHeader defines the main chain block header.
type BPSignedHeader ¶
type BPSignedHeader struct { BPHeader verifier.DefaultHashSignVerifierImpl }
BPSignedHeader defines the main chain header with the signature.
type BaseAccount ¶
type BaseAccount struct { Account pi.TransactionTypeMixin }
BaseAccount defines the base account type header.
func NewBaseAccount ¶
func NewBaseAccount(account *Account) *BaseAccount
NewBaseAccount returns new instance.
func (*BaseAccount) GetAccountAddress ¶
func (b *BaseAccount) GetAccountAddress() proto.AccountAddress
GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
func (*BaseAccount) GetAccountNonce ¶
func (b *BaseAccount) GetAccountNonce() pi.AccountNonce
GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
func (*BaseAccount) Hash ¶
func (b *BaseAccount) Hash() (h hash.Hash)
Hash implements interfaces/Transaction.Hash.
func (*BaseAccount) Sign ¶
func (b *BaseAccount) Sign(signer *asymmetric.PrivateKey) (err error)
Sign implements interfaces/Transaction.Sign.
func (*BaseAccount) Verify ¶
func (b *BaseAccount) Verify() (err error)
Verify implements interfaces/Transaction.Verify.
type Block ¶
type Block struct { SignedHeader SignedHeader FailedReqs []*Request QueryTxs []*QueryAsTx Acks []*SignedAckHeader }
Block is a node of blockchain.
func CreateRandomBlock ¶
CreateRandomBlock create a new random block
func (*Block) CalcNextID ¶
CalcNextID calculates the next query id by examinating every query in block, and adds write query number to the last offset.
TODO(leventeliu): too tricky. Consider simply adding next id to each block header.
func (*Block) GenesisHash ¶
GenesisHash returns the parent hash field of the block header.
func (*Block) PackAndSignBlock ¶
func (b *Block) PackAndSignBlock(signer *ca.PrivateKey) (err error)
PackAndSignBlock generates the signature for the Block from the given PrivateKey.
func (*Block) PackAsGenesis ¶
PackAsGenesis generates the hash of the genesis block.
func (*Block) ParentHash ¶
ParentHash returns the parent hash field of the block header.
func (*Block) VerifyAsGenesis ¶
VerifyAsGenesis verifies the block as a genesis block.
type CreateDatabase ¶
type CreateDatabase struct { CreateDatabaseHeader pi.TransactionTypeMixin verifier.DefaultHashSignVerifierImpl }
CreateDatabase defines the database creation transaction.
func NewCreateDatabase ¶
func NewCreateDatabase(header *CreateDatabaseHeader) *CreateDatabase
NewCreateDatabase returns new instance.
func (*CreateDatabase) GetAccountAddress ¶
func (cd *CreateDatabase) GetAccountAddress() proto.AccountAddress
GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
func (*CreateDatabase) Sign ¶
func (cd *CreateDatabase) Sign(signer *asymmetric.PrivateKey) (err error)
Sign implements interfaces/Transaction.Sign.
func (*CreateDatabase) Verify ¶
func (cd *CreateDatabase) Verify() error
Verify implements interfaces/Transaction.Verify.
type CreateDatabaseHeader ¶
type CreateDatabaseHeader struct { Owner proto.AccountAddress ResourceMeta ResourceMeta GasPrice uint64 AdvancePayment uint64 TokenType TokenType Nonce pi.AccountNonce }
CreateDatabaseHeader defines the database creation transaction header.
func (*CreateDatabaseHeader) GetAccountNonce ¶
func (h *CreateDatabaseHeader) GetAccountNonce() pi.AccountNonce
GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
type CreateDatabaseRequest ¶
type CreateDatabaseRequest struct { proto.Envelope Header SignedCreateDatabaseRequestHeader }
CreateDatabaseRequest defines client create database rpc request entity.
func (*CreateDatabaseRequest) Sign ¶
func (r *CreateDatabaseRequest) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the request.
func (*CreateDatabaseRequest) Verify ¶
func (r *CreateDatabaseRequest) Verify() error
Verify checks hash and signature in request header.
type CreateDatabaseRequestHeader ¶
type CreateDatabaseRequestHeader struct {
ResourceMeta ResourceMeta
}
CreateDatabaseRequestHeader defines client create database rpc header.
type CreateDatabaseResponse ¶
type CreateDatabaseResponse struct { proto.Envelope Header SignedCreateDatabaseResponseHeader }
CreateDatabaseResponse defines client create database rpc response entity.
func (*CreateDatabaseResponse) Sign ¶
func (r *CreateDatabaseResponse) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the response.
func (*CreateDatabaseResponse) Verify ¶
func (r *CreateDatabaseResponse) Verify() error
Verify checks hash and signature in response header.
type CreateDatabaseResponseHeader ¶
type CreateDatabaseResponseHeader struct {
InstanceMeta ServiceInstance
}
CreateDatabaseResponseHeader defines client create database rpc response header.
type DropDatabaseRequest ¶
type DropDatabaseRequest struct { proto.Envelope Header SignedDropDatabaseRequestHeader }
DropDatabaseRequest defines client drop database rpc request entity.
func (*DropDatabaseRequest) Sign ¶
func (r *DropDatabaseRequest) Sign(signer *asymmetric.PrivateKey) error
Sign the request.
func (*DropDatabaseRequest) Verify ¶
func (r *DropDatabaseRequest) Verify() error
Verify checks hash and signature in request header.
type DropDatabaseRequestHeader ¶
type DropDatabaseRequestHeader struct {
DatabaseID proto.DatabaseID
}
DropDatabaseRequestHeader defines client drop database rpc request header.
type DropDatabaseResponse ¶
type DropDatabaseResponse struct{}
DropDatabaseResponse defines client drop database rpc response entity.
type FetchBlockByCountReq ¶
FetchBlockByCountReq define a request of the FetchBlockByCount RPC method.
type FetchBlockReq ¶
FetchBlockReq defines a request of the FetchBlock RPC method.
type FetchBlockResp ¶
FetchBlockResp defines a response of the FetchBlock RPC method.
type FetchLastIrreversibleBlockReq ¶
type FetchLastIrreversibleBlockReq struct { proto.Envelope Address proto.AccountAddress }
FetchLastIrreversibleBlockReq defines a request of the FetchLastIrreversibleBlock RPC method.
type FetchLastIrreversibleBlockResp ¶
type FetchLastIrreversibleBlockResp struct { proto.Envelope Count uint32 Height uint32 Block *BPBlock SQLChains []*SQLChainProfile }
FetchLastIrreversibleBlockResp defines a response of the FetchLastIrreversibleBlock RPC method.
type FetchTxBillingReq ¶
FetchTxBillingReq defines a request of the FetchTxBilling RPC method.
type FetchTxBillingResp ¶
FetchTxBillingResp defines a response of the FetchTxBilling RPC method.
type GetDatabaseRequest ¶
type GetDatabaseRequest struct { proto.Envelope Header SignedGetDatabaseRequestHeader }
GetDatabaseRequest defines client get database rpc request entity.
func (*GetDatabaseRequest) Sign ¶
func (r *GetDatabaseRequest) Sign(signer *asymmetric.PrivateKey) error
Sign the request.
func (*GetDatabaseRequest) Verify ¶
func (r *GetDatabaseRequest) Verify() error
Verify checks hash and signature in request header.
type GetDatabaseRequestHeader ¶
type GetDatabaseRequestHeader struct {
DatabaseID proto.DatabaseID
}
GetDatabaseRequestHeader defines client get database rpc request header entity.
type GetDatabaseResponse ¶
type GetDatabaseResponse struct { proto.Envelope Header SignedGetDatabaseResponseHeader }
GetDatabaseResponse defines client get database rpc response entity.
func (*GetDatabaseResponse) Sign ¶
func (r *GetDatabaseResponse) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the request.
func (*GetDatabaseResponse) Verify ¶
func (r *GetDatabaseResponse) Verify() (err error)
Verify checks hash and signature in response header.
type GetDatabaseResponseHeader ¶
type GetDatabaseResponseHeader struct {
InstanceMeta ServiceInstance
}
GetDatabaseResponseHeader defines client get database rpc response header entity.
type Header ¶
type Header struct { Version int32 Producer proto.NodeID GenesisHash hash.Hash ParentHash hash.Hash MerkleRoot hash.Hash Timestamp time.Time }
Header is a block header.
type InitService ¶
InitService defines worker service init request.
type InitServiceResponse ¶
type InitServiceResponse struct {
Header SignedInitServiceResponseHeader
}
InitServiceResponse defines worker service init response.
func (*InitServiceResponse) Sign ¶
func (rs *InitServiceResponse) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the request.
func (*InitServiceResponse) Verify ¶
func (rs *InitServiceResponse) Verify() error
Verify checks hash and signature in init service response header.
type InitServiceResponseHeader ¶
type InitServiceResponseHeader struct {
Instances []ServiceInstance
}
InitServiceResponseHeader defines worker service init response header.
type IssueKeys ¶
type IssueKeys struct { IssueKeysHeader interfaces.TransactionTypeMixin verifier.DefaultHashSignVerifierImpl }
IssueKeys defines the database creation transaction.
func NewIssueKeys ¶
func NewIssueKeys(header *IssueKeysHeader) *IssueKeys
NewIssueKeys returns new instance.
func (*IssueKeys) GetAccountAddress ¶
func (ik *IssueKeys) GetAccountAddress() proto.AccountAddress
GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
func (*IssueKeys) Sign ¶
func (ik *IssueKeys) Sign(signer *asymmetric.PrivateKey) (err error)
Sign implements interfaces/Transaction.Sign.
type IssueKeysHeader ¶
type IssueKeysHeader struct { TargetSQLChain proto.AccountAddress MinerKeys []MinerKey Nonce interfaces.AccountNonce }
IssueKeysHeader defines an encryption key header.
func (*IssueKeysHeader) GetAccountNonce ¶
func (h *IssueKeysHeader) GetAccountNonce() interfaces.AccountNonce
GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
type MinerIncome ¶
type MinerIncome struct { Miner proto.AccountAddress Income uint64 }
MinerIncome defines the income of miner.
type MinerInfo ¶
type MinerInfo struct { Address proto.AccountAddress NodeID proto.NodeID Name string PendingIncome uint64 ReceivedIncome uint64 UserArrears []*UserArrears Deposit uint64 Status Status EncryptionKey string }
MinerInfo defines a miner.
type MinerKey ¶
type MinerKey struct { Miner proto.AccountAddress EncryptionKey string }
MinerKey defines an encryption key associated with miner address.
type NamedArg ¶
type NamedArg struct { Name string Value interface{} }
NamedArg defines the named argument structure for database.
type NextAccountNonceReq ¶
type NextAccountNonceReq struct { proto.Envelope Addr proto.AccountAddress }
NextAccountNonceReq defines a request of the NextAccountNonce RPC method.
type NextAccountNonceResp ¶
type NextAccountNonceResp struct { proto.Envelope Addr proto.AccountAddress Nonce interfaces.AccountNonce }
NextAccountNonceResp defines a response of the NextAccountNonce RPC method.
type OrderMakerReq ¶
OrderMakerReq defines a request of the order maker in database market.
type OrderTakerReq ¶
type OrderTakerReq struct { proto.Envelope DBMeta ResourceMeta }
OrderTakerReq defines a request of the order taker in database market.
type OrderTakerResp ¶
OrderTakerResp defines a response of the order taker in database market.
type PermStat ¶
type PermStat struct { Permission *UserPermission Status Status }
PermStat defines the permissions status structure.
type ProvideService ¶
type ProvideService struct { ProvideServiceHeader interfaces.TransactionTypeMixin verifier.DefaultHashSignVerifierImpl }
ProvideService define the miner providing service transaction.
func NewProvideService ¶
func NewProvideService(h *ProvideServiceHeader) *ProvideService
NewProvideService returns new instance.
func (*ProvideService) GetAccountAddress ¶
func (ps *ProvideService) GetAccountAddress() proto.AccountAddress
GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
func (*ProvideService) Sign ¶
func (ps *ProvideService) Sign(signer *asymmetric.PrivateKey) (err error)
Sign implements interfaces/Transaction.Sign.
func (*ProvideService) Verify ¶
func (ps *ProvideService) Verify() error
Verify implements interfaces/Transaction.Verify.
type ProvideServiceHeader ¶
type ProvideServiceHeader struct { Space uint64 // reserved storage space in bytes Memory uint64 // reserved memory in bytes LoadAvgPerCPU float64 // max loadAvg15 per CPU TargetUser []proto.AccountAddress GasPrice uint64 TokenType TokenType NodeID proto.NodeID Nonce interfaces.AccountNonce }
ProvideServiceHeader define the miner providing service transaction header.
func (*ProvideServiceHeader) GetAccountNonce ¶
func (h *ProvideServiceHeader) GetAccountNonce() interfaces.AccountNonce
GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
type ProviderProfile ¶
type ProviderProfile struct { Provider proto.AccountAddress Space uint64 // reserved storage space in bytes Memory uint64 // reserved memory in bytes LoadAvgPerCPU float64 // max loadAvg15 per CPU TargetUser []proto.AccountAddress Deposit uint64 // default 10 Particle GasPrice uint64 TokenType TokenType // default Particle NodeID proto.NodeID }
ProviderProfile defines a provider list.
type QueryAccountSQLChainProfilesReq ¶
type QueryAccountSQLChainProfilesReq struct { proto.Envelope Addr proto.AccountAddress }
QueryAccountSQLChainProfilesReq defines a request of QueryAccountSQLChainProfiles RPC method.
type QueryAccountSQLChainProfilesResp ¶
type QueryAccountSQLChainProfilesResp struct { proto.Envelope Addr proto.AccountAddress Profiles []*SQLChainProfile }
QueryAccountSQLChainProfilesResp defines a response of QueryAccountSQLChainProfiles RPC method.
type QueryAccountTokenBalanceReq ¶
type QueryAccountTokenBalanceReq struct { proto.Envelope Addr proto.AccountAddress TokenType TokenType }
QueryAccountTokenBalanceReq defines a request of the QueryAccountTokenBalance RPC method.
type QueryAccountTokenBalanceResp ¶
type QueryAccountTokenBalanceResp struct { proto.Envelope Addr proto.AccountAddress OK bool Balance uint64 }
QueryAccountTokenBalanceResp defines a request of the QueryAccountTokenBalance RPC method.
type QueryAsTx ¶
type QueryAsTx struct { Request *Request Response *SignedResponseHeader }
QueryAsTx defines a tx struct which is combined with request and signed response header for block.
type QueryKey ¶
type QueryKey struct { NodeID proto.NodeID `json:"id"` ConnectionID uint64 `json:"cid"` SeqNo uint64 `json:"seq"` }
QueryKey defines an unique query key of a request.
type QuerySQLChainProfileReq ¶
type QuerySQLChainProfileReq struct { proto.Envelope DBID proto.DatabaseID }
QuerySQLChainProfileReq defines a request of the QuerySQLChainProfile RPC method.
type QuerySQLChainProfileResp ¶
type QuerySQLChainProfileResp struct { proto.Envelope Profile SQLChainProfile }
QuerySQLChainProfileResp defines a response of the QuerySQLChainProfile RPC method.
type QueryTxStateReq ¶
QueryTxStateReq defines a request of the QueryTxState RPC method.
type QueryTxStateResp ¶
QueryTxStateResp defines a response of the QueryTxState RPC method.
type QueryType ¶
type QueryType int32
QueryType enumerates available query type, currently read/write.
type Request ¶
type Request struct { proto.Envelope Header SignedRequestHeader `json:"h"` Payload RequestPayload `json:"p"` // contains filtered or unexported fields }
Request defines a complete query request.
func (*Request) GetMarshalCache ¶
GetMarshalCache gets _marshalCache.
func (*Request) SetMarshalCache ¶
SetMarshalCache sets _marshalCache.
func (*Request) Sign ¶
func (r *Request) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the request.
type RequestHeader ¶
type RequestHeader struct { QueryType QueryType `json:"qt"` NodeID proto.NodeID `json:"id"` // request node id DatabaseID proto.DatabaseID `json:"dbid"` // request database id ConnectionID uint64 `json:"cid"` SeqNo uint64 `json:"seq"` Timestamp time.Time `json:"t"` // time in UTC zone BatchCount uint64 `json:"bc"` // query count in this request QueriesHash hash.Hash `json:"qh"` // hash of query payload }
RequestHeader defines a query request header.
func (*RequestHeader) GetQueryKey ¶
func (h *RequestHeader) GetQueryKey() QueryKey
GetQueryKey returns a unique query key of this request.
type RequestPayload ¶
type RequestPayload struct {
Queries []Query `json:"qs"`
}
RequestPayload defines a queries payload.
type ResourceMeta ¶
type ResourceMeta struct { TargetMiners []proto.AccountAddress // designated miners Node uint16 // reserved node count Space uint64 // reserved storage space in bytes Memory uint64 // reserved memory in bytes LoadAvgPerCPU float64 // max loadAvg15 per CPU EncryptionKey string // encryption key for database instance UseEventualConsistency bool // use eventual consistency replication if enabled ConsistencyLevel float64 // customized strong consistency level IsolationLevel int // customized isolation level }
ResourceMeta defines single database resource meta.
type Response ¶
type Response struct { Header SignedResponseHeader `json:"h"` Payload ResponsePayload `json:"p"` }
Response defines a complete query response.
func (*Response) VerifyHash ¶
VerifyHash verify the hash of the response.
type ResponseHeader ¶
type ResponseHeader struct { Request RequestHeader `json:"r"` RequestHash hash.Hash `json:"rh"` NodeID proto.NodeID `json:"id"` // response node id Timestamp time.Time `json:"t"` // time in UTC zone RowCount uint64 `json:"c"` // response row count of payload LogOffset uint64 `json:"o"` // request log offset LastInsertID int64 `json:"l"` // insert insert id AffectedRows int64 `json:"a"` // affected rows PayloadHash hash.Hash `json:"dh"` // hash of query response payload ResponseAccount proto.AccountAddress `json:"aa"` // response account }
ResponseHeader defines a query response header.
func (*ResponseHeader) GetRequestHash ¶
func (h *ResponseHeader) GetRequestHash() hash.Hash
GetRequestHash returns the request hash.
func (*ResponseHeader) GetRequestTimestamp ¶
func (h *ResponseHeader) GetRequestTimestamp() time.Time
GetRequestTimestamp returns the request timestamp.
type ResponsePayload ¶
type ResponsePayload struct { Columns []string `json:"c"` DeclTypes []string `json:"t"` Rows []ResponseRow `json:"r"` }
ResponsePayload defines column names and rows of query response.
type ResponseRow ¶
type ResponseRow struct {
Values []interface{}
}
ResponseRow defines single row of query response.
type SQLChainProfile ¶
type SQLChainProfile struct { ID proto.DatabaseID Address proto.AccountAddress Period uint64 GasPrice uint64 LastUpdatedHeight uint32 TokenType TokenType Owner proto.AccountAddress // first miner in the list is leader Miners []*MinerInfo Users []*SQLChainUser EncodedGenesis []byte Meta ResourceMeta // dumped from db creation tx }
SQLChainProfile defines a SQLChainProfile related to an account.
type SQLChainRole ¶
type SQLChainRole byte
SQLChainRole defines roles of account in a SQLChain.
const ( // Miner defines the miner role as a SQLChain user. Miner SQLChainRole = iota // Customer defines the customer role as a SQLChain user. Customer // NumberOfRoles defines the SQLChain roles number. NumberOfRoles )
type SQLChainUser ¶
type SQLChainUser struct { Address proto.AccountAddress Permission *UserPermission AdvancePayment uint64 Arrears uint64 Deposit uint64 Status Status }
SQLChainUser defines a SQLChain user.
type ServiceInstance ¶
type ServiceInstance struct { DatabaseID proto.DatabaseID Peers *proto.Peers ResourceMeta ResourceMeta GenesisBlock *Block }
ServiceInstance defines single instance to be initialized.
type SignedAckHeader ¶
type SignedAckHeader struct { AckHeader verifier.DefaultHashSignVerifierImpl }
SignedAckHeader defines client signed ack entity.
func (*SignedAckHeader) Sign ¶
func (sh *SignedAckHeader) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the request.
func (*SignedAckHeader) Verify ¶
func (sh *SignedAckHeader) Verify() (err error)
Verify checks hash and signature in ack header.
type SignedCreateDatabaseRequestHeader ¶
type SignedCreateDatabaseRequestHeader struct { CreateDatabaseRequestHeader verifier.DefaultHashSignVerifierImpl }
SignedCreateDatabaseRequestHeader defines signed client create database request header.
func (*SignedCreateDatabaseRequestHeader) Sign ¶
func (sh *SignedCreateDatabaseRequestHeader) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the request.
func (*SignedCreateDatabaseRequestHeader) Verify ¶
func (sh *SignedCreateDatabaseRequestHeader) Verify() (err error)
Verify checks hash and signature in create database request header.
type SignedCreateDatabaseResponseHeader ¶
type SignedCreateDatabaseResponseHeader struct { CreateDatabaseResponseHeader verifier.DefaultHashSignVerifierImpl }
SignedCreateDatabaseResponseHeader defines signed client create database response header.
func (*SignedCreateDatabaseResponseHeader) Sign ¶
func (sh *SignedCreateDatabaseResponseHeader) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the response.
func (*SignedCreateDatabaseResponseHeader) Verify ¶
func (sh *SignedCreateDatabaseResponseHeader) Verify() (err error)
Verify checks hash and signature in create database response header.
type SignedDropDatabaseRequestHeader ¶
type SignedDropDatabaseRequestHeader struct { DropDatabaseRequestHeader verifier.DefaultHashSignVerifierImpl }
SignedDropDatabaseRequestHeader defines signed client drop database rpc request header.
func (*SignedDropDatabaseRequestHeader) Sign ¶
func (sh *SignedDropDatabaseRequestHeader) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the request.
func (*SignedDropDatabaseRequestHeader) Verify ¶
func (sh *SignedDropDatabaseRequestHeader) Verify() (err error)
Verify checks hash and signature in request header.
type SignedGetDatabaseRequestHeader ¶
type SignedGetDatabaseRequestHeader struct { GetDatabaseRequestHeader verifier.DefaultHashSignVerifierImpl }
SignedGetDatabaseRequestHeader defines signed client get database rpc request header entity.
func (*SignedGetDatabaseRequestHeader) Sign ¶
func (sh *SignedGetDatabaseRequestHeader) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the request.
func (*SignedGetDatabaseRequestHeader) Verify ¶
func (sh *SignedGetDatabaseRequestHeader) Verify() (err error)
Verify checks hash and signature in request header.
type SignedGetDatabaseResponseHeader ¶
type SignedGetDatabaseResponseHeader struct { GetDatabaseResponseHeader verifier.DefaultHashSignVerifierImpl }
SignedGetDatabaseResponseHeader defines client get database rpc response header entity.
func (*SignedGetDatabaseResponseHeader) Sign ¶
func (sh *SignedGetDatabaseResponseHeader) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the request.
func (*SignedGetDatabaseResponseHeader) Verify ¶
func (sh *SignedGetDatabaseResponseHeader) Verify() (err error)
Verify checks hash and signature in response header.
type SignedHeader ¶
type SignedHeader struct { Header HSV verifier.DefaultHashSignVerifierImpl }
SignedHeader is block header along with its producer signature.
func (*SignedHeader) ComputeHash ¶
func (s *SignedHeader) ComputeHash() error
ComputeHash computes the hash of the signed header.
func (*SignedHeader) Sign ¶
func (s *SignedHeader) Sign(signer *ca.PrivateKey) error
Sign calls DefaultHashSignVerifierImpl to calculate header hash and sign it with signer.
func (*SignedHeader) Verify ¶
func (s *SignedHeader) Verify() error
Verify verifies the signature of the signed header.
func (*SignedHeader) VerifyHash ¶
func (s *SignedHeader) VerifyHash() error
VerifyHash verifies the hash of the signed header.
type SignedInitServiceResponseHeader ¶
type SignedInitServiceResponseHeader struct { InitServiceResponseHeader verifier.DefaultHashSignVerifierImpl }
SignedInitServiceResponseHeader defines signed worker service init response header.
func (*SignedInitServiceResponseHeader) Sign ¶
func (sh *SignedInitServiceResponseHeader) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the request.
func (*SignedInitServiceResponseHeader) Verify ¶
func (sh *SignedInitServiceResponseHeader) Verify() (err error)
Verify checks hash and signature in init service response header.
type SignedRequestHeader ¶
type SignedRequestHeader struct { RequestHeader verifier.DefaultHashSignVerifierImpl }
SignedRequestHeader defines a signed query request header.
func (*SignedRequestHeader) Sign ¶
func (sh *SignedRequestHeader) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the request.
func (*SignedRequestHeader) Verify ¶
func (sh *SignedRequestHeader) Verify() (err error)
Verify checks hash and signature in request header.
type SignedResponseHeader ¶
type SignedResponseHeader struct { ResponseHeader ResponseHash hash.Hash }
SignedResponseHeader defines a signed query response header.
func (*SignedResponseHeader) BuildHash ¶
func (sh *SignedResponseHeader) BuildHash() (err error)
BuildHash computes the hash of the response header.
func (*SignedResponseHeader) Hash ¶
func (sh *SignedResponseHeader) Hash() hash.Hash
Hash returns the response header hash.
func (*SignedResponseHeader) VerifyHash ¶
func (sh *SignedResponseHeader) VerifyHash() (err error)
VerifyHash verify the hash of the response.
type SignedUpdateServiceHeader ¶
type SignedUpdateServiceHeader struct { UpdateServiceHeader verifier.DefaultHashSignVerifierImpl }
SignedUpdateServiceHeader defines signed service update header.
func (*SignedUpdateServiceHeader) Sign ¶
func (sh *SignedUpdateServiceHeader) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the request.
func (*SignedUpdateServiceHeader) Verify ¶
func (sh *SignedUpdateServiceHeader) Verify() (err error)
Verify checks hash and signature in update service header.
type Status ¶
type Status int32
Status defines status of a SQLChain user/miner.
const ( // UnknownStatus defines initial status. UnknownStatus Status = iota // Normal defines no bad thing happens. Normal // Reminder defines the user needs to increase advance payment. Reminder // Arrears defines the user is in arrears. Arrears // Arbitration defines the user/miner is in an arbitration. Arbitration // NumberOfStatus defines the number of status. NumberOfStatus )
func (*Status) EnableQuery ¶
EnableQuery indicates whether the account is permitted to query.
type TokenType ¶
type TokenType int32
TokenType defines token's type.
type Transfer ¶
type Transfer struct { TransferHeader pi.TransactionTypeMixin verifier.DefaultHashSignVerifierImpl }
Transfer defines the transfer transaction.
func NewTransfer ¶
func NewTransfer(header *TransferHeader) *Transfer
NewTransfer returns new instance.
func (*Transfer) GetAccountAddress ¶
func (t *Transfer) GetAccountAddress() proto.AccountAddress
GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
func (*Transfer) GetAccountNonce ¶
func (t *Transfer) GetAccountNonce() pi.AccountNonce
GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
func (*Transfer) Sign ¶
func (t *Transfer) Sign(signer *asymmetric.PrivateKey) (err error)
Sign implements interfaces/Transaction.Sign.
type TransferHeader ¶
type TransferHeader struct {
Sender, Receiver proto.AccountAddress
Nonce pi.AccountNonce
Amount uint64
TokenType TokenType
}
TransferHeader defines the transfer transaction header.
type UpdateBilling ¶
type UpdateBilling struct { UpdateBillingHeader pi.TransactionTypeMixin verifier.DefaultHashSignVerifierImpl }
UpdateBilling defines the UpdateBilling transaction.
func NewUpdateBilling ¶
func NewUpdateBilling(header *UpdateBillingHeader) *UpdateBilling
NewUpdateBilling returns new instance.
func (*UpdateBilling) GetAccountAddress ¶
func (ub *UpdateBilling) GetAccountAddress() proto.AccountAddress
GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
func (*UpdateBilling) GetAccountNonce ¶
func (ub *UpdateBilling) GetAccountNonce() pi.AccountNonce
GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
func (*UpdateBilling) Sign ¶
func (ub *UpdateBilling) Sign(signer *asymmetric.PrivateKey) (err error)
Sign implements interfaces/Transaction.Sign.
func (*UpdateBilling) Verify ¶
func (ub *UpdateBilling) Verify() (err error)
Verify implements interfaces/Transaction.Verify.
type UpdateBillingHeader ¶
type UpdateBillingHeader struct { Receiver proto.AccountAddress Nonce pi.AccountNonce Users []*UserCost Range Range Version int32 `hsp:"v,version"` }
UpdateBillingHeader defines the UpdateBilling transaction header.
type UpdatePermission ¶
type UpdatePermission struct { UpdatePermissionHeader interfaces.TransactionTypeMixin verifier.DefaultHashSignVerifierImpl }
UpdatePermission defines the updating sqlchain permission transaction.
func NewUpdatePermission ¶
func NewUpdatePermission(header *UpdatePermissionHeader) *UpdatePermission
NewUpdatePermission returns new instance.
func (*UpdatePermission) GetAccountAddress ¶
func (up *UpdatePermission) GetAccountAddress() proto.AccountAddress
GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
func (*UpdatePermission) Sign ¶
func (up *UpdatePermission) Sign(signer *asymmetric.PrivateKey) (err error)
Sign implements interfaces/Transaction.Sign.
func (*UpdatePermission) Verify ¶
func (up *UpdatePermission) Verify() error
Verify implements interfaces/Transaction.Verify.
type UpdatePermissionHeader ¶
type UpdatePermissionHeader struct { TargetSQLChain proto.AccountAddress TargetUser proto.AccountAddress Permission *UserPermission Nonce interfaces.AccountNonce }
UpdatePermissionHeader defines the updating sqlchain permission transaction header.
func (*UpdatePermissionHeader) GetAccountNonce ¶
func (u *UpdatePermissionHeader) GetAccountNonce() interfaces.AccountNonce
GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
type UpdateService ¶
type UpdateService struct { proto.Envelope Header SignedUpdateServiceHeader }
UpdateService defines service update type.
func (*UpdateService) Sign ¶
func (s *UpdateService) Sign(signer *asymmetric.PrivateKey) (err error)
Sign the request.
func (*UpdateService) Verify ¶
func (s *UpdateService) Verify() error
Verify checks hash and signature in update service.
type UpdateServiceHeader ¶
type UpdateServiceHeader struct { Op UpdateType Instance ServiceInstance }
UpdateServiceHeader defines service update header.
type UpdateServiceResponse ¶
type UpdateServiceResponse struct{}
UpdateServiceResponse defines empty response entity.
type UpdateType ¶
type UpdateType int32
UpdateType defines service update type.
const ( // CreateDB indicates create database operation. CreateDB UpdateType = iota // UpdateDB indicates database peers update operation. UpdateDB // DropDB indicates drop database operation. DropDB )
type UserArrears ¶
type UserArrears struct { User proto.AccountAddress Arrears uint64 }
UserArrears defines user's arrears.
type UserCost ¶
type UserCost struct { User proto.AccountAddress Cost uint64 Miners []*MinerIncome }
UserCost defines the cost of user.
type UserPermission ¶
type UserPermission struct { // User role to access database. Role UserPermissionRole // SQL pattern regulations for user queries // only a fully matched (case-sensitive) sql query is permitted to execute. Patterns []string // contains filtered or unexported fields }
UserPermission defines permissions of a SQLChain user.
func UserPermissionFromRole ¶
func UserPermissionFromRole(role UserPermissionRole) *UserPermission
UserPermissionFromRole construct a new user permission instance from primitive user permission role enum.
func (*UserPermission) HasDisallowedQueryPatterns ¶
func (up *UserPermission) HasDisallowedQueryPatterns(queries []Query) (query string, status bool)
HasDisallowedQueryPatterns returns whether the queries are permitted.
func (*UserPermission) HasReadPermission ¶
func (up *UserPermission) HasReadPermission() bool
HasReadPermission returns true if user owns read permission.
func (*UserPermission) HasSuperPermission ¶
func (up *UserPermission) HasSuperPermission() bool
HasSuperPermission returns true if user owns super permission.
func (*UserPermission) HasWritePermission ¶
func (up *UserPermission) HasWritePermission() bool
HasWritePermission returns true if user owns write permission.
func (*UserPermission) IsValid ¶
func (up *UserPermission) IsValid() bool
IsValid returns whether the permission object is valid or not.
type UserPermissionRole ¶
type UserPermissionRole int32
UserPermissionRole defines role of user permission including admin/write/read.
func (*UserPermissionRole) FromString ¶
func (r *UserPermissionRole) FromString(perm string)
FromString converts string to UserPermissionRole.
func (UserPermissionRole) MarshalJSON ¶
func (r UserPermissionRole) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (UserPermissionRole) String ¶
func (r UserPermissionRole) String() string
String implements the fmt.Stringer interface.
func (*UserPermissionRole) UnmarshalJSON ¶
func (r *UserPermissionRole) UnmarshalJSON(data []byte) (err error)
UnmarshalJSON implements the json.Unmarshler interface.
Source Files ¶
- account.go
- ack_type.go
- baseaccount.go
- block.go
- bp_block.go
- bprpc.go
- createdb.go
- db_service_types.go
- doc.go
- errors.go
- init_service_type.go
- issuekeys.go
- observer.go
- provideservice.go
- request_type.go
- response_type.go
- token.go
- transfer.go
- update_service_type.go
- updatebilling.go
- updatepermission.go
- util.go