plain

package
v2.0.0-alpha+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Precision uint64 = 64
)

Variables

This section is empty.

Functions

func GetTokenOwnerString

func GetTokenOwnerString(owner *token.TokenOwner) (string, error)

GetTokenOwnerString returns a hex encoded string of the token owner. The owner is hashed to reduce the length.

Types

type BigQuantity

type BigQuantity struct {
	*big.Int
	Precision uint64
}

func (*BigQuantity) Add

func (q *BigQuantity) Add(b Quantity) (Quantity, error)

func (*BigQuantity) Cmp

func (q *BigQuantity) Cmp(b Quantity) (int, error)

func (*BigQuantity) Decimal

func (q *BigQuantity) Decimal() string

func (*BigQuantity) Hex

func (q *BigQuantity) Hex() string

func (*BigQuantity) Sub

func (q *BigQuantity) Sub(b Quantity) (Quantity, error)

type Issuer

type Issuer struct {
	TokenOwnerValidator identity.TokenOwnerValidator
}

An Issuer that can import new tokens

func (*Issuer) RequestIssue

func (i *Issuer) RequestIssue(tokensToIssue []*token.Token) (*token.TokenTransaction, error)

RequestIssue creates an issue request with the token owners, types, and quantities specified in tokensToIssue.

func (*Issuer) RequestTokenOperation

func (i *Issuer) RequestTokenOperation(request *token.TokenOperation) (*token.TokenTransaction, error)

RequestTokenOperation returns a token transaction matching the requested issue operation

type Manager added in v1.4.0

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

Manager is used to access TMS components.

func (*Manager) GetTxProcessor added in v1.4.0

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

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

func (*Manager) SetPolicyValidator added in v1.4.0

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

SetPolicyValidator sets the policy validator for the specified channel

type MemoryLedger added in v1.4.0

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

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

func NewMemoryLedger added in v1.4.0

func NewMemoryLedger() *MemoryLedger

NewMemoryLedger creates a new MemoryLedger

func (*MemoryLedger) DeleteState

func (p *MemoryLedger) DeleteState(namespace string, key string) error

DeleteState deletes the given namespace and key

func (*MemoryLedger) Done added in v1.4.0

func (p *MemoryLedger) Done()

Done releases resources occupied by the MemoryLedger

func (*MemoryLedger) GetState added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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 Quantity

type Quantity interface {

	// Add returns this + b without modify this.
	// If an overflow occurs, it returns an error.
	Add(b Quantity) (Quantity, error)

	// Add returns this - b without modify this.
	// If an overflow occurs, it returns an error.
	Sub(b Quantity) (Quantity, error)

	// Cmd compare this with b
	Cmp(b Quantity) (int, error)

	// Hex returns the hexadecimal representation of this quantity
	Hex() string

	// Decimal returns the decimal representation of this quantity
	Decimal() string
}

Quantity models a token quantity and its basic operations.

func NewZeroQuantity

func NewZeroQuantity(precision uint64) Quantity

NewZeroQuantity returns to zero quantity at the passed precision/ The precision is expressed in bits.

func ToQuantity

func ToQuantity(q string, precision uint64) (Quantity, error)

ToQuantity converts a string q to a BigQuantity of a given precision. Argument q is supposed to be formatted following big.Int#scan specification. The precision is expressed in bits.

type Transactor added in v1.4.0

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

A Transactor that can transfer tokens.

func (*Transactor) Done added in v1.4.0

func (t *Transactor) Done()

Done releases any resources held by this transactor

func (*Transactor) ListTokens added in v1.4.0

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

ListTokens queries the ledger and returns the unspent tokens owned by the user. It does not allow to query unspent tokens owned by other users.

func (*Transactor) RequestRedeem added in v1.4.0

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

RequestRedeem creates a TokenTransaction of type redeem request

func (*Transactor) RequestTokenOperation

func (t *Transactor) RequestTokenOperation(tokenIDs []*token.TokenId, op *token.TokenOperation) (*token.TokenTransaction, int, error)

/ RequestTokenOperation returns a token transaction matching the requested transfer operation

func (*Transactor) RequestTransfer added in v1.4.0

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

RequestTransfer creates a TokenTransaction of type transfer request

type Verifier

type Verifier struct {
	IssuingValidator    identity.IssuingValidator
	TokenOwnerValidator identity.TokenOwnerValidator
}

A Verifier validates and commits token transactions.

func (*Verifier) ProcessTx added in v1.4.0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL