...

Package plain

import "github.com/hyperledger/fabric/token/tms/plain"
Overview
Index

Overview ▾

Index ▾

Variables
func GenerateKeyForTest(txID string, index int) (string, error)
type HistoryIterator
    func (it *HistoryIterator) Next() (string, *token.TokenTransaction, error)
type Issuer
    func (i *Issuer) RequestExpectation(request *token.ExpectationRequest) (*token.TokenTransaction, error)
    func (i *Issuer) RequestImport(tokensToIssue []*token.TokenToIssue) (*token.TokenTransaction, error)
type Manager
    func (m *Manager) GetTxProcessor(channel string) (transaction.TMSTxProcessor, error)
    func (m *Manager) SetPolicyValidator(channel string, validator identity.IssuingValidator)
type MemoryLedger
    func NewMemoryLedger() *MemoryLedger
    func (p *MemoryLedger) Done()
    func (p *MemoryLedger) GetState(namespace string, key string) ([]byte, error)
    func (p *MemoryLedger) GetStateRangeScanIterator(namespace string, startKey string, endKey string) (ledger.ResultsIterator, error)
    func (p *MemoryLedger) SetState(namespace string, key string, value []byte) error
type MemoryPool
    func NewMemoryPool() *MemoryPool
    func (p *MemoryPool) CommitUpdate(transactionData []tms.TransactionData) error
    func (p *MemoryPool) HistoryIterator() *HistoryIterator
    func (p *MemoryPool) Iterator() *PoolIterator
    func (p *MemoryPool) OutputByID(id string) (*token.PlainOutput, error)
    func (p *MemoryPool) TxByID(txID string) (*token.TokenTransaction, error)
type OutputNotFoundError
    func (o *OutputNotFoundError) Error() string
type PoolIterator
    func (it *PoolIterator) Next() (string, *token.PlainOutput, error)
type Transactor
    func (t *Transactor) Done()
    func (t *Transactor) ListTokens() (*token.UnspentTokens, error)
    func (t *Transactor) RequestApprove(request *token.ApproveRequest) (*token.TokenTransaction, error)
    func (t *Transactor) RequestExpectation(request *token.ExpectationRequest) (*token.TokenTransaction, error)
    func (t *Transactor) RequestRedeem(request *token.RedeemRequest) (*token.TokenTransaction, error)
    func (t *Transactor) RequestTransfer(request *token.TransferRequest) (*token.TokenTransaction, error)
    func (t *Transactor) RequestTransferFrom(request *token.TransferRequest) (*token.TokenTransaction, error)
type TxNotFoundError
    func (p *TxNotFoundError) Error() string
type Verifier
    func (v *Verifier) ProcessTx(txID string, creator identity.PublicInfo, ttx *token.TokenTransaction, simulator ledger.LedgerWriter) error

Package files

issuer.go ledger.go manager.go pool.go transactor.go verifier.go

Variables

var TokenInputSpentMarker = []byte{1}

func GenerateKeyForTest

func GenerateKeyForTest(txID string, index int) (string, error)

GenerateKeyForTest is here only for testing purposes, to be removed later.

type HistoryIterator

HistoryIterator is an iterator for iterating through the transaction history.

type HistoryIterator struct {
    // contains filtered or unexported fields
}

func (*HistoryIterator) Next

func (it *HistoryIterator) Next() (string, *token.TokenTransaction, error)

Next gets the next transaction from the history, or io.EOF if there are no more transactions.

type Issuer

An Issuer that can import new tokens

type Issuer struct{}

func (*Issuer) RequestExpectation

func (i *Issuer) RequestExpectation(request *token.ExpectationRequest) (*token.TokenTransaction, error)

RequestExpectation allows indirect import based on the expectation. It creates a token transaction with the outputs as specified in the expectation.

func (*Issuer) RequestImport

func (i *Issuer) RequestImport(tokensToIssue []*token.TokenToIssue) (*token.TokenTransaction, error)

RequestImport creates an import request with the token owners, types, and quantities specified in tokensToIssue.

type Manager

Manager is used to access TMS components.

type Manager struct {
    // contains filtered or unexported fields
}

func (*Manager) GetTxProcessor

func (m *Manager) GetTxProcessor(channel string) (transaction.TMSTxProcessor, error)

GetTxProcessor returns a TMSTxProcessor that is used to process token transactions.

func (*Manager) SetPolicyValidator

func (m *Manager) SetPolicyValidator(channel string, validator identity.IssuingValidator)

SetPolicyValidator sets the policy validator for the specified channel

type MemoryLedger

A MemoryLedger is an in-memory ledger of transactions and unspent outputs. This implementation is only meant for testing.

type MemoryLedger struct {
    // contains filtered or unexported fields
}

func NewMemoryLedger

func NewMemoryLedger() *MemoryLedger

NewMemoryLedger creates a new MemoryLedger

func (*MemoryLedger) Done

func (p *MemoryLedger) Done()

Done releases resources occupied by the MemoryLedger

func (*MemoryLedger) GetState

func (p *MemoryLedger) GetState(namespace string, key string) ([]byte, error)

GetState gets the value for given namespace and Key. For a chaincode, the namespace corresponds to the chaincodeID

func (*MemoryLedger) GetStateRangeScanIterator

func (p *MemoryLedger) GetStateRangeScanIterator(namespace string, startKey string, endKey string) (ledger.ResultsIterator, error)

GetStateRangeScanIterator gets the values for a given namespace that lie in an interval determined by startKey and endKey. this is a mock function.

func (*MemoryLedger) SetState

func (p *MemoryLedger) SetState(namespace string, key string, value []byte) error

SetState sets the given value for the given namespace and Key. For a chaincode, the namespace corresponds to the chaincodeID

type MemoryPool

A MemoryPool is an in-memory ledger of transactions and unspent outputs. This implementation is only meant for testing.

type MemoryPool struct {
    // contains filtered or unexported fields
}

func NewMemoryPool

func NewMemoryPool() *MemoryPool

NewMemoryPool creates a new MemoryPool

func (*MemoryPool) CommitUpdate

func (p *MemoryPool) CommitUpdate(transactionData []tms.TransactionData) error

CommitUpdate commits transaction data into the pool.

func (*MemoryPool) HistoryIterator

func (p *MemoryPool) HistoryIterator() *HistoryIterator

HistoryIterator creates a new HistoryIterator for iterating through the transaction history.

func (*MemoryPool) Iterator

func (p *MemoryPool) Iterator() *PoolIterator

Iterator returns an iterator of the unspent outputs based on a copy of the pool.

func (*MemoryPool) OutputByID

func (p *MemoryPool) OutputByID(id string) (*token.PlainOutput, error)

OutputByID gets an output by its ID.

func (*MemoryPool) TxByID

func (p *MemoryPool) TxByID(txID string) (*token.TokenTransaction, error)

TxByID gets a transaction by its transaction ID. If no transaction exists with the given ID, a TxNotFoundError is returned.

type OutputNotFoundError

OutputNotFoundError is returned when an entry was not found in the pool.

type OutputNotFoundError struct {
    ID string
}

func (*OutputNotFoundError) Error

func (o *OutputNotFoundError) Error() string

type PoolIterator

PoolIterator is an iterator for iterating through the items in the pool.

type PoolIterator struct {
    // contains filtered or unexported fields
}

func (*PoolIterator) Next

func (it *PoolIterator) Next() (string, *token.PlainOutput, error)

Next gets the next output from the pool, or io.EOF if there are no more outputs.

type Transactor

A Transactor that can transfer tokens.

type Transactor struct {
    PublicCredential []byte
    Ledger           ledger.LedgerReader
}

func (*Transactor) Done

func (t *Transactor) Done()

Done releases any resources held by this transactor

func (*Transactor) ListTokens

func (t *Transactor) ListTokens() (*token.UnspentTokens, error)

ListTokens creates a TokenTransaction that lists the unspent tokens owned by owner.

func (*Transactor) RequestApprove

func (t *Transactor) RequestApprove(request *token.ApproveRequest) (*token.TokenTransaction, error)

func (*Transactor) RequestExpectation

func (t *Transactor) RequestExpectation(request *token.ExpectationRequest) (*token.TokenTransaction, error)

RequestExpectation allows indirect transfer based on the expectation. It creates a token transaction based on the outputs as specified in the expectation.

func (*Transactor) RequestRedeem

func (t *Transactor) RequestRedeem(request *token.RedeemRequest) (*token.TokenTransaction, error)

RequestRedeem creates a TokenTransaction of type redeem request

func (*Transactor) RequestTransfer

func (t *Transactor) RequestTransfer(request *token.TransferRequest) (*token.TokenTransaction, error)

RequestTransfer creates a TokenTransaction of type transfer request func (t *Transactor) RequestTransfer(inTokens []*token.InputId, tokensToTransfer []*token.RecipientTransferShare) (*token.TokenTransaction, error) {

func (*Transactor) RequestTransferFrom

func (t *Transactor) RequestTransferFrom(request *token.TransferRequest) (*token.TokenTransaction, error)

type TxNotFoundError

TxNotFoundError is returned when a transaction was not found in the pool.

type TxNotFoundError struct {
    TxID string
}

func (*TxNotFoundError) Error

func (p *TxNotFoundError) Error() string

type Verifier

A Verifier validates and commits token transactions.

type Verifier struct {
    IssuingValidator identity.IssuingValidator
}

func (*Verifier) ProcessTx

func (v *Verifier) ProcessTx(txID string, creator identity.PublicInfo, ttx *token.TokenTransaction, simulator ledger.LedgerWriter) error

ProcessTx checks that transactions are correct wrt. the most recent ledger state. ProcessTx checks are ones that shall be done sequentially, since transactions within a block may introduce dependencies.