Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterLedgerServer(s *grpc.Server, srv LedgerServer)
- type BaseValidator
- type ChangeValidator
- type GetAddressStatementRequest
- func (*GetAddressStatementRequest) Descriptor() ([]byte, []int)
- func (m *GetAddressStatementRequest) GetAddress() string
- func (*GetAddressStatementRequest) ProtoMessage()
- func (m *GetAddressStatementRequest) Reset()
- func (m *GetAddressStatementRequest) String() string
- func (m *GetAddressStatementRequest) XXX_DiscardUnknown()
- func (m *GetAddressStatementRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *GetAddressStatementRequest) XXX_Merge(src proto.Message)
- func (m *GetAddressStatementRequest) XXX_Size() int
- func (m *GetAddressStatementRequest) XXX_Unmarshal(b []byte) error
- type GetAddressStatementResult
- func (*GetAddressStatementResult) Descriptor() ([]byte, []int)
- func (m *GetAddressStatementResult) GetTxs() []*Transaction
- func (*GetAddressStatementResult) ProtoMessage()
- func (m *GetAddressStatementResult) Reset()
- func (m *GetAddressStatementResult) String() string
- func (m *GetAddressStatementResult) XXX_DiscardUnknown()
- func (m *GetAddressStatementResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *GetAddressStatementResult) XXX_Merge(src proto.Message)
- func (m *GetAddressStatementResult) XXX_Size() int
- func (m *GetAddressStatementResult) XXX_Unmarshal(b []byte) error
- type GetLastTransactionRequest
- func (*GetLastTransactionRequest) Descriptor() ([]byte, []int)
- func (m *GetLastTransactionRequest) GetAddress() string
- func (*GetLastTransactionRequest) ProtoMessage()
- func (m *GetLastTransactionRequest) Reset()
- func (m *GetLastTransactionRequest) String() string
- func (m *GetLastTransactionRequest) XXX_DiscardUnknown()
- func (m *GetLastTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *GetLastTransactionRequest) XXX_Merge(src proto.Message)
- func (m *GetLastTransactionRequest) XXX_Size() int
- func (m *GetLastTransactionRequest) XXX_Unmarshal(b []byte) error
- type GetLastTransactionResult
- func (*GetLastTransactionResult) Descriptor() ([]byte, []int)
- func (m *GetLastTransactionResult) GetTx() *Transaction
- func (*GetLastTransactionResult) ProtoMessage()
- func (m *GetLastTransactionResult) Reset()
- func (m *GetLastTransactionResult) String() string
- func (m *GetLastTransactionResult) XXX_DiscardUnknown()
- func (m *GetLastTransactionResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *GetLastTransactionResult) XXX_Merge(src proto.Message)
- func (m *GetLastTransactionResult) XXX_Size() int
- func (m *GetLastTransactionResult) XXX_Unmarshal(b []byte) error
- type GetTransactionRequest
- func (*GetTransactionRequest) Descriptor() ([]byte, []int)
- func (m *GetTransactionRequest) GetHash() string
- func (*GetTransactionRequest) ProtoMessage()
- func (m *GetTransactionRequest) Reset()
- func (m *GetTransactionRequest) String() string
- func (m *GetTransactionRequest) XXX_DiscardUnknown()
- func (m *GetTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *GetTransactionRequest) XXX_Merge(src proto.Message)
- func (m *GetTransactionRequest) XXX_Size() int
- func (m *GetTransactionRequest) XXX_Unmarshal(b []byte) error
- type GetTransactionResult
- func (*GetTransactionResult) Descriptor() ([]byte, []int)
- func (m *GetTransactionResult) GetTx() *Transaction
- func (*GetTransactionResult) ProtoMessage()
- func (m *GetTransactionResult) Reset()
- func (m *GetTransactionResult) String() string
- func (m *GetTransactionResult) XXX_DiscardUnknown()
- func (m *GetTransactionResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *GetTransactionResult) XXX_Merge(src proto.Message)
- func (m *GetTransactionResult) XXX_Size() int
- func (m *GetTransactionResult) XXX_Unmarshal(b []byte) error
- type Ledger
- type LedgerClient
- type LedgerServer
- type LocalLedger
- func (ld *LocalLedger) GetAddressStatement(address string) ([]*Transaction, error)
- func (ld *LocalLedger) GetLastTransaction(address string) (*Transaction, error)
- func (ld *LocalLedger) GetTransaction(hash string) (*Transaction, error)
- func (ld *LocalLedger) Initialize(genesisTx *Transaction) error
- func (ld *LocalLedger) Register(sendTx *Transaction, receiveTx *Transaction) error
- func (ld *LocalLedger) Verify(sendTx *Transaction, receiveTx *Transaction) error
- func (ld *LocalLedger) VerifyTransaction(tx *Transaction, isNew bool) error
- type OpenValidator
- type ReceiveValidator
- type RegisterRequest
- func (*RegisterRequest) Descriptor() ([]byte, []int)
- func (m *RegisterRequest) GetReceiveTx() *Transaction
- func (m *RegisterRequest) GetSendTx() *Transaction
- func (*RegisterRequest) ProtoMessage()
- func (m *RegisterRequest) Reset()
- func (m *RegisterRequest) String() string
- func (m *RegisterRequest) XXX_DiscardUnknown()
- func (m *RegisterRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *RegisterRequest) XXX_Merge(src proto.Message)
- func (m *RegisterRequest) XXX_Size() int
- func (m *RegisterRequest) XXX_Unmarshal(b []byte) error
- type RegisterResult
- func (*RegisterResult) Descriptor() ([]byte, []int)
- func (*RegisterResult) ProtoMessage()
- func (m *RegisterResult) Reset()
- func (m *RegisterResult) String() string
- func (m *RegisterResult) XXX_DiscardUnknown()
- func (m *RegisterResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *RegisterResult) XXX_Merge(src proto.Message)
- func (m *RegisterResult) XXX_Size() int
- func (m *RegisterResult) XXX_Unmarshal(b []byte) error
- type SendValidator
- type Transaction
- func CreateGenesisTransaction(balance float64) (*Transaction, *address.Address, error)
- func CreateReceiveTransaction(send *Transaction, amount float64, receiveAddr *address.Address, ...) (*Transaction, error)
- func CreateSendTransaction(fromTipTx *Transaction, fromAddr *address.Address, to string, amount float64) (*Transaction, error)
- func NewOpenTransaction() *Transaction
- func NewReceiveTransaction() *Transaction
- func NewSendTransaction() *Transaction
- func NewTransactionFromBytes(d []byte) *Transaction
- func (tx *Transaction) CalculateHash() (string, error)
- func (tx *Transaction) CalculatePow() (int64, string, error)
- func (*Transaction) Descriptor() ([]byte, []int)
- func (m *Transaction) GetAddress() string
- func (m *Transaction) GetBalance() float64
- func (m *Transaction) GetHash() string
- func (tx *Transaction) GetHashableBytes() ([][]byte, error)
- func (m *Transaction) GetLink() string
- func (m *Transaction) GetPowNonce() int64
- func (m *Transaction) GetPowTarget() int32
- func (m *Transaction) GetPrevious() string
- func (m *Transaction) GetPubKey() string
- func (m *Transaction) GetSignature() string
- func (m *Transaction) GetTimestamp() int64
- func (m *Transaction) GetType() Transaction_Type
- func (*Transaction) ProtoMessage()
- func (m *Transaction) Reset()
- func (tx *Transaction) SetHash() error
- func (tx *Transaction) SetPow() error
- func (tx *Transaction) Sign(privateKey *ecdsa.PrivateKey) error
- func (m *Transaction) String() string
- func (tx *Transaction) ToBytes() []byte
- func (tx *Transaction) VerifyPow() (bool, error)
- func (tx *Transaction) VerifySignature() bool
- func (m *Transaction) XXX_DiscardUnknown()
- func (m *Transaction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Transaction) XXX_Merge(src proto.Message)
- func (m *Transaction) XXX_Size() int
- func (m *Transaction) XXX_Unmarshal(b []byte) error
- type TransactionStore
- func (ts *TransactionStore) GetTransaction(txHash string) (*Transaction, bool, error)
- func (ts *TransactionStore) GetTransactionChain(txHash string, includeAll bool) ([]*Transaction, error)
- func (ts *TransactionStore) IsEmpty() bool
- func (ts *TransactionStore) Retrieve(hash string) (*Transaction, error)
- func (ts *TransactionStore) Store(tx *Transaction) (*Transaction, error)
- type Transaction_Type
- type Validator
- type ValidatorCreator
- type VerifyRequest
- func (*VerifyRequest) Descriptor() ([]byte, []int)
- func (m *VerifyRequest) GetReceiveTx() *Transaction
- func (m *VerifyRequest) GetSendTx() *Transaction
- func (*VerifyRequest) ProtoMessage()
- func (m *VerifyRequest) Reset()
- func (m *VerifyRequest) String() string
- func (m *VerifyRequest) XXX_DiscardUnknown()
- func (m *VerifyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *VerifyRequest) XXX_Merge(src proto.Message)
- func (m *VerifyRequest) XXX_Size() int
- func (m *VerifyRequest) XXX_Unmarshal(b []byte) error
- type VerifyResult
- func (*VerifyResult) Descriptor() ([]byte, []int)
- func (*VerifyResult) ProtoMessage()
- func (m *VerifyResult) Reset()
- func (m *VerifyResult) String() string
- func (m *VerifyResult) XXX_DiscardUnknown()
- func (m *VerifyResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *VerifyResult) XXX_Merge(src proto.Message)
- func (m *VerifyResult) XXX_Size() int
- func (m *VerifyResult) XXX_Unmarshal(b []byte) error
- type VerifyTransactionRequest
- func (*VerifyTransactionRequest) Descriptor() ([]byte, []int)
- func (m *VerifyTransactionRequest) GetTx() *Transaction
- func (*VerifyTransactionRequest) ProtoMessage()
- func (m *VerifyTransactionRequest) Reset()
- func (m *VerifyTransactionRequest) String() string
- func (m *VerifyTransactionRequest) XXX_DiscardUnknown()
- func (m *VerifyTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *VerifyTransactionRequest) XXX_Merge(src proto.Message)
- func (m *VerifyTransactionRequest) XXX_Size() int
- func (m *VerifyTransactionRequest) XXX_Unmarshal(b []byte) error
- type VerifyTransactionResult
- func (*VerifyTransactionResult) Descriptor() ([]byte, []int)
- func (*VerifyTransactionResult) ProtoMessage()
- func (m *VerifyTransactionResult) Reset()
- func (m *VerifyTransactionResult) String() string
- func (m *VerifyTransactionResult) XXX_DiscardUnknown()
- func (m *VerifyTransactionResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *VerifyTransactionResult) XXX_Merge(src proto.Message)
- func (m *VerifyTransactionResult) XXX_Size() int
- func (m *VerifyTransactionResult) XXX_Unmarshal(b []byte) error
Constants ¶
View Source
const ( ErrLedgerAlreadyInitialized = errors.Error("ledger already initialized") ErrNotEnoughFunds = errors.Error("not enough funds") ErrInvalidTransactionSignature = errors.Error("invalid transaction signature") ErrInvalidTransactionHash = errors.Error("invalid transaction hash") ErrTransactionAlreadyInLedger = errors.Error("transaction already in ledger") ErrTransactionNotFound = errors.Error("previous not found") ErrPreviousTransactionNotFound = errors.Error("previous transaction not found") ErrHeadTransactionNotFound = errors.Error("head transaction not found") ErrPreviousTransactionIsNotHead = errors.Error("previous transaction is not the chain head") ErrSendTransactionIsNotPending = errors.Error("send transaction is not pending") ErrOpenTransactionNotFound = errors.Error("open transaction not found") ErrAddressDoesNotMatchPubKey = errors.Error("address does not match public key") ErrSendReceiveTransactionsNotLinked = errors.Error("send and receive transaction not linked") ErrSendReceiveTransactionsCantBeSameAddress = errors.Error("send and receive can not be on the same address") ErrSentAmountDiffersFromReceivedAmount = errors.Error("sent amount differs from received amount") ErrInvalidReceiveTransaction = errors.Error("invalid receive transaction") ErrInvalidSendTransaction = errors.Error("invalid send transaction") )
View Source
const ( ErrInvalidTransactionType = errors.Error("invalid transaction type") ErrInvalidTransactionTimestamp = errors.Error("invalid transaction timestamp") ErrTransactionAddressCantBeEmpty = errors.Error("transaction address can not be empty") ErrPreviousTransactionCantBeEmpty = errors.Error("previous transaction can not be empty") ErrTransactionSignatureCantBeEmpty = errors.Error("transaction signature can not be empty") ErrTransactionPowNonceCantBeZero = errors.Error("transaction PoW nonce can not be zero") ErrTransactionHashCantBeEmpty = errors.Error("transaction hash can not be empty") ErrTransactionLinkCantBeEmpty = errors.Error("transaction link can not be empty") ErrDestinationNotFound = errors.Error("destination not found") ErrSourceNotFound = errors.Error("source not found") ErrInvalidSourceType = errors.Error("invalid source type") ErrPubKeyCantBeEmpty = errors.Error("transaction public key can not be empty") )
Variables ¶
View Source
var Transaction_Type_name = map[int32]string{
0: "ZERO",
1: "OPEN",
2: "SEND",
3: "RECEIVE",
4: "CHANGE",
}
View Source
var Transaction_Type_value = map[string]int32{
"ZERO": 0,
"OPEN": 1,
"SEND": 2,
"RECEIVE": 3,
"CHANGE": 4,
}
Functions ¶
func RegisterLedgerServer ¶
func RegisterLedgerServer(s *grpc.Server, srv LedgerServer)
Types ¶
type BaseValidator ¶
type BaseValidator struct {
// contains filtered or unexported fields
}
func (*BaseValidator) IsFilled ¶
func (v *BaseValidator) IsFilled(tx *Transaction) (bool, error)
func (*BaseValidator) IsValid ¶
func (v *BaseValidator) IsValid(tx *Transaction) (bool, error)
type ChangeValidator ¶
type ChangeValidator struct {
BaseValidator
}
func (*ChangeValidator) IsFilled ¶
func (v *ChangeValidator) IsFilled(tx *Transaction) (bool, error)
func (*ChangeValidator) IsValid ¶
func (v *ChangeValidator) IsValid(tx *Transaction) (bool, error)
type GetAddressStatementRequest ¶
type GetAddressStatementRequest struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*GetAddressStatementRequest) Descriptor ¶
func (*GetAddressStatementRequest) Descriptor() ([]byte, []int)
func (*GetAddressStatementRequest) GetAddress ¶
func (m *GetAddressStatementRequest) GetAddress() string
func (*GetAddressStatementRequest) ProtoMessage ¶
func (*GetAddressStatementRequest) ProtoMessage()
func (*GetAddressStatementRequest) Reset ¶
func (m *GetAddressStatementRequest) Reset()
func (*GetAddressStatementRequest) String ¶
func (m *GetAddressStatementRequest) String() string
func (*GetAddressStatementRequest) XXX_DiscardUnknown ¶
func (m *GetAddressStatementRequest) XXX_DiscardUnknown()
func (*GetAddressStatementRequest) XXX_Marshal ¶
func (m *GetAddressStatementRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*GetAddressStatementRequest) XXX_Merge ¶
func (dst *GetAddressStatementRequest) XXX_Merge(src proto.Message)
func (*GetAddressStatementRequest) XXX_Size ¶
func (m *GetAddressStatementRequest) XXX_Size() int
func (*GetAddressStatementRequest) XXX_Unmarshal ¶
func (m *GetAddressStatementRequest) XXX_Unmarshal(b []byte) error
type GetAddressStatementResult ¶
type GetAddressStatementResult struct { Txs []*Transaction `protobuf:"bytes,1,rep,name=txs,proto3" json:"txs,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*GetAddressStatementResult) Descriptor ¶
func (*GetAddressStatementResult) Descriptor() ([]byte, []int)
func (*GetAddressStatementResult) GetTxs ¶
func (m *GetAddressStatementResult) GetTxs() []*Transaction
func (*GetAddressStatementResult) ProtoMessage ¶
func (*GetAddressStatementResult) ProtoMessage()
func (*GetAddressStatementResult) Reset ¶
func (m *GetAddressStatementResult) Reset()
func (*GetAddressStatementResult) String ¶
func (m *GetAddressStatementResult) String() string
func (*GetAddressStatementResult) XXX_DiscardUnknown ¶
func (m *GetAddressStatementResult) XXX_DiscardUnknown()
func (*GetAddressStatementResult) XXX_Marshal ¶
func (m *GetAddressStatementResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*GetAddressStatementResult) XXX_Merge ¶
func (dst *GetAddressStatementResult) XXX_Merge(src proto.Message)
func (*GetAddressStatementResult) XXX_Size ¶
func (m *GetAddressStatementResult) XXX_Size() int
func (*GetAddressStatementResult) XXX_Unmarshal ¶
func (m *GetAddressStatementResult) XXX_Unmarshal(b []byte) error
type GetLastTransactionRequest ¶
type GetLastTransactionRequest struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*GetLastTransactionRequest) Descriptor ¶
func (*GetLastTransactionRequest) Descriptor() ([]byte, []int)
func (*GetLastTransactionRequest) GetAddress ¶
func (m *GetLastTransactionRequest) GetAddress() string
func (*GetLastTransactionRequest) ProtoMessage ¶
func (*GetLastTransactionRequest) ProtoMessage()
func (*GetLastTransactionRequest) Reset ¶
func (m *GetLastTransactionRequest) Reset()
func (*GetLastTransactionRequest) String ¶
func (m *GetLastTransactionRequest) String() string
func (*GetLastTransactionRequest) XXX_DiscardUnknown ¶
func (m *GetLastTransactionRequest) XXX_DiscardUnknown()
func (*GetLastTransactionRequest) XXX_Marshal ¶
func (m *GetLastTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*GetLastTransactionRequest) XXX_Merge ¶
func (dst *GetLastTransactionRequest) XXX_Merge(src proto.Message)
func (*GetLastTransactionRequest) XXX_Size ¶
func (m *GetLastTransactionRequest) XXX_Size() int
func (*GetLastTransactionRequest) XXX_Unmarshal ¶
func (m *GetLastTransactionRequest) XXX_Unmarshal(b []byte) error
type GetLastTransactionResult ¶
type GetLastTransactionResult struct { Tx *Transaction `protobuf:"bytes,1,opt,name=tx,proto3" json:"tx,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*GetLastTransactionResult) Descriptor ¶
func (*GetLastTransactionResult) Descriptor() ([]byte, []int)
func (*GetLastTransactionResult) GetTx ¶
func (m *GetLastTransactionResult) GetTx() *Transaction
func (*GetLastTransactionResult) ProtoMessage ¶
func (*GetLastTransactionResult) ProtoMessage()
func (*GetLastTransactionResult) Reset ¶
func (m *GetLastTransactionResult) Reset()
func (*GetLastTransactionResult) String ¶
func (m *GetLastTransactionResult) String() string
func (*GetLastTransactionResult) XXX_DiscardUnknown ¶
func (m *GetLastTransactionResult) XXX_DiscardUnknown()
func (*GetLastTransactionResult) XXX_Marshal ¶
func (m *GetLastTransactionResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*GetLastTransactionResult) XXX_Merge ¶
func (dst *GetLastTransactionResult) XXX_Merge(src proto.Message)
func (*GetLastTransactionResult) XXX_Size ¶
func (m *GetLastTransactionResult) XXX_Size() int
func (*GetLastTransactionResult) XXX_Unmarshal ¶
func (m *GetLastTransactionResult) XXX_Unmarshal(b []byte) error
type GetTransactionRequest ¶
type GetTransactionRequest struct { Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*GetTransactionRequest) Descriptor ¶
func (*GetTransactionRequest) Descriptor() ([]byte, []int)
func (*GetTransactionRequest) GetHash ¶
func (m *GetTransactionRequest) GetHash() string
func (*GetTransactionRequest) ProtoMessage ¶
func (*GetTransactionRequest) ProtoMessage()
func (*GetTransactionRequest) Reset ¶
func (m *GetTransactionRequest) Reset()
func (*GetTransactionRequest) String ¶
func (m *GetTransactionRequest) String() string
func (*GetTransactionRequest) XXX_DiscardUnknown ¶
func (m *GetTransactionRequest) XXX_DiscardUnknown()
func (*GetTransactionRequest) XXX_Marshal ¶
func (m *GetTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*GetTransactionRequest) XXX_Merge ¶
func (dst *GetTransactionRequest) XXX_Merge(src proto.Message)
func (*GetTransactionRequest) XXX_Size ¶
func (m *GetTransactionRequest) XXX_Size() int
func (*GetTransactionRequest) XXX_Unmarshal ¶
func (m *GetTransactionRequest) XXX_Unmarshal(b []byte) error
type GetTransactionResult ¶
type GetTransactionResult struct { Tx *Transaction `protobuf:"bytes,1,opt,name=tx,proto3" json:"tx,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*GetTransactionResult) Descriptor ¶
func (*GetTransactionResult) Descriptor() ([]byte, []int)
func (*GetTransactionResult) GetTx ¶
func (m *GetTransactionResult) GetTx() *Transaction
func (*GetTransactionResult) ProtoMessage ¶
func (*GetTransactionResult) ProtoMessage()
func (*GetTransactionResult) Reset ¶
func (m *GetTransactionResult) Reset()
func (*GetTransactionResult) String ¶
func (m *GetTransactionResult) String() string
func (*GetTransactionResult) XXX_DiscardUnknown ¶
func (m *GetTransactionResult) XXX_DiscardUnknown()
func (*GetTransactionResult) XXX_Marshal ¶
func (m *GetTransactionResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*GetTransactionResult) XXX_Merge ¶
func (dst *GetTransactionResult) XXX_Merge(src proto.Message)
func (*GetTransactionResult) XXX_Size ¶
func (m *GetTransactionResult) XXX_Size() int
func (*GetTransactionResult) XXX_Unmarshal ¶
func (m *GetTransactionResult) XXX_Unmarshal(b []byte) error
type Ledger ¶
type Ledger interface { Initialize(genesisTx *Transaction) error GetLastTransaction(address string) (*Transaction, error) GetTransaction(hash string) (*Transaction, error) GetAddressStatement(address string) ([]*Transaction, error) Register(sendTx *Transaction, receiveTx *Transaction) error VerifyTransaction(tx *Transaction, isNew bool) error Verify(sendTx *Transaction, receiveTx *Transaction) error }
type LedgerClient ¶
type LedgerClient interface { Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResult, error) GetLastTransaction(ctx context.Context, in *GetLastTransactionRequest, opts ...grpc.CallOption) (*GetLastTransactionResult, error) GetTransaction(ctx context.Context, in *GetTransactionRequest, opts ...grpc.CallOption) (*GetTransactionResult, error) VerifyTransaction(ctx context.Context, in *VerifyTransactionRequest, opts ...grpc.CallOption) (*VerifyTransactionResult, error) Verify(ctx context.Context, in *VerifyRequest, opts ...grpc.CallOption) (*VerifyResult, error) GetAddressStatement(ctx context.Context, in *GetAddressStatementRequest, opts ...grpc.CallOption) (*GetAddressStatementResult, error) }
LedgerClient is the client API for Ledger service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewLedgerClient ¶
func NewLedgerClient(cc *grpc.ClientConn) LedgerClient
type LedgerServer ¶
type LedgerServer interface { Register(context.Context, *RegisterRequest) (*RegisterResult, error) GetLastTransaction(context.Context, *GetLastTransactionRequest) (*GetLastTransactionResult, error) GetTransaction(context.Context, *GetTransactionRequest) (*GetTransactionResult, error) VerifyTransaction(context.Context, *VerifyTransactionRequest) (*VerifyTransactionResult, error) Verify(context.Context, *VerifyRequest) (*VerifyResult, error) GetAddressStatement(context.Context, *GetAddressStatementRequest) (*GetAddressStatementResult, error) }
LedgerServer is the server API for Ledger service.
type LocalLedger ¶
type LocalLedger struct {
// contains filtered or unexported fields
}
func NewLocalLedger ¶
func NewLocalLedger(txStore *TransactionStore) *LocalLedger
func (*LocalLedger) GetAddressStatement ¶
func (ld *LocalLedger) GetAddressStatement(address string) ([]*Transaction, error)
func (*LocalLedger) GetLastTransaction ¶
func (ld *LocalLedger) GetLastTransaction(address string) (*Transaction, error)
func (*LocalLedger) GetTransaction ¶
func (ld *LocalLedger) GetTransaction(hash string) (*Transaction, error)
func (*LocalLedger) Initialize ¶
func (ld *LocalLedger) Initialize(genesisTx *Transaction) error
func (*LocalLedger) Register ¶
func (ld *LocalLedger) Register(sendTx *Transaction, receiveTx *Transaction) error
func (*LocalLedger) Verify ¶
func (ld *LocalLedger) Verify(sendTx *Transaction, receiveTx *Transaction) error
func (*LocalLedger) VerifyTransaction ¶
func (ld *LocalLedger) VerifyTransaction(tx *Transaction, isNew bool) error
type OpenValidator ¶
type OpenValidator struct {
BaseValidator
}
func (*OpenValidator) IsFilled ¶
func (v *OpenValidator) IsFilled(tx *Transaction) (bool, error)
func (*OpenValidator) IsValid ¶
func (v *OpenValidator) IsValid(tx *Transaction) (bool, error)
type ReceiveValidator ¶
type ReceiveValidator struct {
BaseValidator
}
func (*ReceiveValidator) HasValidSource ¶
func (v *ReceiveValidator) HasValidSource(tx *Transaction) (bool, error)
func (*ReceiveValidator) IsFilled ¶
func (v *ReceiveValidator) IsFilled(tx *Transaction) (bool, error)
func (*ReceiveValidator) IsValid ¶
func (v *ReceiveValidator) IsValid(tx *Transaction) (bool, error)
type RegisterRequest ¶
type RegisterRequest struct { SendTx *Transaction `protobuf:"bytes,1,opt,name=sendTx,proto3" json:"sendTx,omitempty"` ReceiveTx *Transaction `protobuf:"bytes,2,opt,name=receiveTx,proto3" json:"receiveTx,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*RegisterRequest) Descriptor ¶
func (*RegisterRequest) Descriptor() ([]byte, []int)
func (*RegisterRequest) GetReceiveTx ¶
func (m *RegisterRequest) GetReceiveTx() *Transaction
func (*RegisterRequest) GetSendTx ¶
func (m *RegisterRequest) GetSendTx() *Transaction
func (*RegisterRequest) ProtoMessage ¶
func (*RegisterRequest) ProtoMessage()
func (*RegisterRequest) Reset ¶
func (m *RegisterRequest) Reset()
func (*RegisterRequest) String ¶
func (m *RegisterRequest) String() string
func (*RegisterRequest) XXX_DiscardUnknown ¶
func (m *RegisterRequest) XXX_DiscardUnknown()
func (*RegisterRequest) XXX_Marshal ¶
func (m *RegisterRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*RegisterRequest) XXX_Merge ¶
func (dst *RegisterRequest) XXX_Merge(src proto.Message)
func (*RegisterRequest) XXX_Size ¶
func (m *RegisterRequest) XXX_Size() int
func (*RegisterRequest) XXX_Unmarshal ¶
func (m *RegisterRequest) XXX_Unmarshal(b []byte) error
type RegisterResult ¶
type RegisterResult struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*RegisterResult) Descriptor ¶
func (*RegisterResult) Descriptor() ([]byte, []int)
func (*RegisterResult) ProtoMessage ¶
func (*RegisterResult) ProtoMessage()
func (*RegisterResult) Reset ¶
func (m *RegisterResult) Reset()
func (*RegisterResult) String ¶
func (m *RegisterResult) String() string
func (*RegisterResult) XXX_DiscardUnknown ¶
func (m *RegisterResult) XXX_DiscardUnknown()
func (*RegisterResult) XXX_Marshal ¶
func (m *RegisterResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*RegisterResult) XXX_Merge ¶
func (dst *RegisterResult) XXX_Merge(src proto.Message)
func (*RegisterResult) XXX_Size ¶
func (m *RegisterResult) XXX_Size() int
func (*RegisterResult) XXX_Unmarshal ¶
func (m *RegisterResult) XXX_Unmarshal(b []byte) error
type SendValidator ¶
type SendValidator struct {
BaseValidator
}
func (*SendValidator) HasValidDestination ¶
func (v *SendValidator) HasValidDestination(tx *Transaction) (bool, error)
func (*SendValidator) IsFilled ¶
func (v *SendValidator) IsFilled(tx *Transaction) (bool, error)
func (*SendValidator) IsValid ¶
func (v *SendValidator) IsValid(tx *Transaction) (bool, error)
type Transaction ¶
type Transaction struct { Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` Type Transaction_Type `protobuf:"varint,2,opt,name=type,proto3,enum=ledger.Transaction_Type" json:"type,omitempty"` Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` Previous string `protobuf:"bytes,4,opt,name=previous,proto3" json:"previous,omitempty"` Link string `protobuf:"bytes,5,opt,name=link,proto3" json:"link,omitempty"` Balance float64 `protobuf:"fixed64,6,opt,name=balance,proto3" json:"balance,omitempty"` PowTarget int32 `protobuf:"varint,7,opt,name=powTarget,proto3" json:"powTarget,omitempty"` PowNonce int64 `protobuf:"varint,8,opt,name=powNonce,proto3" json:"powNonce,omitempty"` Hash string `protobuf:"bytes,9,opt,name=hash,proto3" json:"hash,omitempty"` PubKey string `protobuf:"bytes,10,opt,name=pubKey,proto3" json:"pubKey,omitempty"` Signature string `protobuf:"bytes,11,opt,name=signature,proto3" json:"signature,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func CreateGenesisTransaction ¶
func CreateGenesisTransaction(balance float64) (*Transaction, *address.Address, error)
func CreateReceiveTransaction ¶
func CreateReceiveTransaction(send *Transaction, amount float64, receiveAddr *address.Address, receiveTipTx *Transaction) (*Transaction, error)
func CreateSendTransaction ¶
func CreateSendTransaction(fromTipTx *Transaction, fromAddr *address.Address, to string, amount float64) (*Transaction, error)
func NewOpenTransaction ¶
func NewOpenTransaction() *Transaction
func NewReceiveTransaction ¶
func NewReceiveTransaction() *Transaction
func NewSendTransaction ¶
func NewSendTransaction() *Transaction
func NewTransactionFromBytes ¶
func NewTransactionFromBytes(d []byte) *Transaction
func (*Transaction) CalculateHash ¶
func (tx *Transaction) CalculateHash() (string, error)
func (*Transaction) CalculatePow ¶
func (tx *Transaction) CalculatePow() (int64, string, error)
func (*Transaction) Descriptor ¶
func (*Transaction) Descriptor() ([]byte, []int)
func (*Transaction) GetAddress ¶
func (m *Transaction) GetAddress() string
func (*Transaction) GetBalance ¶
func (m *Transaction) GetBalance() float64
func (*Transaction) GetHash ¶
func (m *Transaction) GetHash() string
func (*Transaction) GetHashableBytes ¶
func (tx *Transaction) GetHashableBytes() ([][]byte, error)
func (*Transaction) GetLink ¶
func (m *Transaction) GetLink() string
func (*Transaction) GetPowNonce ¶
func (m *Transaction) GetPowNonce() int64
func (*Transaction) GetPowTarget ¶
func (m *Transaction) GetPowTarget() int32
func (*Transaction) GetPrevious ¶
func (m *Transaction) GetPrevious() string
func (*Transaction) GetPubKey ¶
func (m *Transaction) GetPubKey() string
func (*Transaction) GetSignature ¶
func (m *Transaction) GetSignature() string
func (*Transaction) GetTimestamp ¶
func (m *Transaction) GetTimestamp() int64
func (*Transaction) GetType ¶
func (m *Transaction) GetType() Transaction_Type
func (*Transaction) ProtoMessage ¶
func (*Transaction) ProtoMessage()
func (*Transaction) Reset ¶
func (m *Transaction) Reset()
func (*Transaction) SetHash ¶
func (tx *Transaction) SetHash() error
func (*Transaction) SetPow ¶
func (tx *Transaction) SetPow() error
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(privateKey *ecdsa.PrivateKey) error
func (*Transaction) String ¶
func (m *Transaction) String() string
func (*Transaction) ToBytes ¶
func (tx *Transaction) ToBytes() []byte
func (*Transaction) VerifyPow ¶
func (tx *Transaction) VerifyPow() (bool, error)
func (*Transaction) VerifySignature ¶
func (tx *Transaction) VerifySignature() bool
func (*Transaction) XXX_DiscardUnknown ¶
func (m *Transaction) XXX_DiscardUnknown()
func (*Transaction) XXX_Marshal ¶
func (m *Transaction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*Transaction) XXX_Merge ¶
func (dst *Transaction) XXX_Merge(src proto.Message)
func (*Transaction) XXX_Size ¶
func (m *Transaction) XXX_Size() int
func (*Transaction) XXX_Unmarshal ¶
func (m *Transaction) XXX_Unmarshal(b []byte) error
type TransactionStore ¶
type TransactionStore struct {
// contains filtered or unexported fields
}
func NewTransactionStore ¶
func NewTransactionStore(store keyvaluestore.Storer, validatorCreator ValidatorCreator) *TransactionStore
func (*TransactionStore) GetTransaction ¶
func (ts *TransactionStore) GetTransaction(txHash string) (*Transaction, bool, error)
func (*TransactionStore) GetTransactionChain ¶
func (ts *TransactionStore) GetTransactionChain(txHash string, includeAll bool) ([]*Transaction, error)
func (*TransactionStore) IsEmpty ¶
func (ts *TransactionStore) IsEmpty() bool
func (*TransactionStore) Retrieve ¶
func (ts *TransactionStore) Retrieve(hash string) (*Transaction, error)
func (*TransactionStore) Store ¶
func (ts *TransactionStore) Store(tx *Transaction) (*Transaction, error)
type Transaction_Type ¶
type Transaction_Type int32
const ( Transaction_ZERO Transaction_Type = 0 Transaction_OPEN Transaction_Type = 1 Transaction_SEND Transaction_Type = 2 Transaction_RECEIVE Transaction_Type = 3 Transaction_CHANGE Transaction_Type = 4 )
func (Transaction_Type) EnumDescriptor ¶
func (Transaction_Type) EnumDescriptor() ([]byte, []int)
func (Transaction_Type) String ¶
func (x Transaction_Type) String() string
type Validator ¶
type Validator interface { IsFilled(tx *Transaction) (bool, error) IsValid(tx *Transaction) (bool, error) }
type ValidatorCreator ¶
type ValidatorCreator interface {
CreateValidatorForTransaction(txType Transaction_Type, store keyvaluestore.Storer) Validator
}
func NewValidatorCreator ¶
func NewValidatorCreator() ValidatorCreator
type VerifyRequest ¶
type VerifyRequest struct { SendTx *Transaction `protobuf:"bytes,1,opt,name=sendTx,proto3" json:"sendTx,omitempty"` ReceiveTx *Transaction `protobuf:"bytes,2,opt,name=receiveTx,proto3" json:"receiveTx,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*VerifyRequest) Descriptor ¶
func (*VerifyRequest) Descriptor() ([]byte, []int)
func (*VerifyRequest) GetReceiveTx ¶
func (m *VerifyRequest) GetReceiveTx() *Transaction
func (*VerifyRequest) GetSendTx ¶
func (m *VerifyRequest) GetSendTx() *Transaction
func (*VerifyRequest) ProtoMessage ¶
func (*VerifyRequest) ProtoMessage()
func (*VerifyRequest) Reset ¶
func (m *VerifyRequest) Reset()
func (*VerifyRequest) String ¶
func (m *VerifyRequest) String() string
func (*VerifyRequest) XXX_DiscardUnknown ¶
func (m *VerifyRequest) XXX_DiscardUnknown()
func (*VerifyRequest) XXX_Marshal ¶
func (m *VerifyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*VerifyRequest) XXX_Merge ¶
func (dst *VerifyRequest) XXX_Merge(src proto.Message)
func (*VerifyRequest) XXX_Size ¶
func (m *VerifyRequest) XXX_Size() int
func (*VerifyRequest) XXX_Unmarshal ¶
func (m *VerifyRequest) XXX_Unmarshal(b []byte) error
type VerifyResult ¶
type VerifyResult struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*VerifyResult) Descriptor ¶
func (*VerifyResult) Descriptor() ([]byte, []int)
func (*VerifyResult) ProtoMessage ¶
func (*VerifyResult) ProtoMessage()
func (*VerifyResult) Reset ¶
func (m *VerifyResult) Reset()
func (*VerifyResult) String ¶
func (m *VerifyResult) String() string
func (*VerifyResult) XXX_DiscardUnknown ¶
func (m *VerifyResult) XXX_DiscardUnknown()
func (*VerifyResult) XXX_Marshal ¶
func (m *VerifyResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*VerifyResult) XXX_Merge ¶
func (dst *VerifyResult) XXX_Merge(src proto.Message)
func (*VerifyResult) XXX_Size ¶
func (m *VerifyResult) XXX_Size() int
func (*VerifyResult) XXX_Unmarshal ¶
func (m *VerifyResult) XXX_Unmarshal(b []byte) error
type VerifyTransactionRequest ¶
type VerifyTransactionRequest struct { Tx *Transaction `protobuf:"bytes,1,opt,name=tx,proto3" json:"tx,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*VerifyTransactionRequest) Descriptor ¶
func (*VerifyTransactionRequest) Descriptor() ([]byte, []int)
func (*VerifyTransactionRequest) GetTx ¶
func (m *VerifyTransactionRequest) GetTx() *Transaction
func (*VerifyTransactionRequest) ProtoMessage ¶
func (*VerifyTransactionRequest) ProtoMessage()
func (*VerifyTransactionRequest) Reset ¶
func (m *VerifyTransactionRequest) Reset()
func (*VerifyTransactionRequest) String ¶
func (m *VerifyTransactionRequest) String() string
func (*VerifyTransactionRequest) XXX_DiscardUnknown ¶
func (m *VerifyTransactionRequest) XXX_DiscardUnknown()
func (*VerifyTransactionRequest) XXX_Marshal ¶
func (m *VerifyTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*VerifyTransactionRequest) XXX_Merge ¶
func (dst *VerifyTransactionRequest) XXX_Merge(src proto.Message)
func (*VerifyTransactionRequest) XXX_Size ¶
func (m *VerifyTransactionRequest) XXX_Size() int
func (*VerifyTransactionRequest) XXX_Unmarshal ¶
func (m *VerifyTransactionRequest) XXX_Unmarshal(b []byte) error
type VerifyTransactionResult ¶
type VerifyTransactionResult struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*VerifyTransactionResult) Descriptor ¶
func (*VerifyTransactionResult) Descriptor() ([]byte, []int)
func (*VerifyTransactionResult) ProtoMessage ¶
func (*VerifyTransactionResult) ProtoMessage()
func (*VerifyTransactionResult) Reset ¶
func (m *VerifyTransactionResult) Reset()
func (*VerifyTransactionResult) String ¶
func (m *VerifyTransactionResult) String() string
func (*VerifyTransactionResult) XXX_DiscardUnknown ¶
func (m *VerifyTransactionResult) XXX_DiscardUnknown()
func (*VerifyTransactionResult) XXX_Marshal ¶
func (m *VerifyTransactionResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*VerifyTransactionResult) XXX_Merge ¶
func (dst *VerifyTransactionResult) XXX_Merge(src proto.Message)
func (*VerifyTransactionResult) XXX_Size ¶
func (m *VerifyTransactionResult) XXX_Size() int
func (*VerifyTransactionResult) XXX_Unmarshal ¶
func (m *VerifyTransactionResult) XXX_Unmarshal(b []byte) error
Click to show internal directories.
Click to hide internal directories.