util

package
v0.6.0-preview Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package util is a generated protocol buffer package.

It is generated from these files:

dah.proto

It has these top-level messages:

TX

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadVarInt

func ReadVarInt(buffer *bytes.Buffer) uint64

ReadVarInt reads an int that is formatted in the Bitcoin style variable int format

Types

type ExecResult

type ExecResult struct {
	SumCurrentOutputs uint64
	SumPriorOutputs   uint64
	IsCoinbase        bool
}

ExecResult is the result of processing a transaction

type InMemoryStore

type InMemoryStore struct {
	Map     map[Key]*TX_TXOUT
	TranMap map[string][]byte
}

InMemoryStore used for unit testing

func (*InMemoryStore) DelState

func (ims *InMemoryStore) DelState(key Key) error

DelState deletes the given key and corresponding transactions

func (*InMemoryStore) GetState

func (ims *InMemoryStore) GetState(key Key) (*TX_TXOUT, bool, error)

GetState returns the transaction for the given key

func (*InMemoryStore) GetTran

func (ims *InMemoryStore) GetTran(key string) ([]byte, bool, error)

GetTran returns the transaction for the given hash

func (*InMemoryStore) PutState

func (ims *InMemoryStore) PutState(key Key, value *TX_TXOUT) error

PutState saves the key and transaction in memory

func (*InMemoryStore) PutTran

func (ims *InMemoryStore) PutTran(key string, value []byte) error

PutTran saves the hash and transaction in memory

type Key

type Key struct {
	TxHashAsHex string
	TxIndex     uint32
}

Key represents the key for a transaction in storage. It has both a hash and index

type Store

type Store interface {
	GetState(Key) (*TX_TXOUT, bool, error)
	PutState(Key, *TX_TXOUT) error
	DelState(Key) error
	GetTran(string) ([]byte, bool, error)
	PutTran(string, []byte) error
}

Store interface describes the storage used by this chaincode. The interface was created so either the state database store can be used or a in memory store can be used for unit testing.

func MakeInMemoryStore

func MakeInMemoryStore() Store

MakeInMemoryStore creates a new in memory store

type TX

type TX struct {
	Version  uint32      `protobuf:"varint,1,opt,name=version" json:"version,omitempty"`
	LockTime uint32      `protobuf:"varint,2,opt,name=lockTime" json:"lockTime,omitempty"`
	Txin     []*TX_TXIN  `protobuf:"bytes,3,rep,name=txin" json:"txin,omitempty"`
	Txout    []*TX_TXOUT `protobuf:"bytes,4,rep,name=txout" json:"txout,omitempty"`
	Blocks   [][]byte    `protobuf:"bytes,5,rep,name=blocks,proto3" json:"blocks,omitempty"`
	Fee      uint64      `protobuf:"varint,6,opt,name=fee" json:"fee,omitempty"`
}

func ParseUTXOBytes

func ParseUTXOBytes(txAsUTXOBytes []byte) *TX

ParseUTXOBytes parses a bitcoin sytle transaction

func (*TX) Descriptor

func (*TX) Descriptor() ([]byte, []int)

func (*TX) GetTxin

func (m *TX) GetTxin() []*TX_TXIN

func (*TX) GetTxout

func (m *TX) GetTxout() []*TX_TXOUT

func (*TX) ProtoMessage

func (*TX) ProtoMessage()

func (*TX) Reset

func (m *TX) Reset()

func (*TX) String

func (m *TX) String() string

type TX_TXIN

type TX_TXIN struct {
	Ix         uint32 `protobuf:"varint,1,opt,name=ix" json:"ix,omitempty"`
	SourceHash []byte `protobuf:"bytes,2,opt,name=sourceHash,proto3" json:"sourceHash,omitempty"`
	Script     []byte `protobuf:"bytes,3,opt,name=script,proto3" json:"script,omitempty"`
	Sequence   uint32 `protobuf:"varint,4,opt,name=sequence" json:"sequence,omitempty"`
}

func (*TX_TXIN) Descriptor

func (*TX_TXIN) Descriptor() ([]byte, []int)

func (*TX_TXIN) ProtoMessage

func (*TX_TXIN) ProtoMessage()

func (*TX_TXIN) Reset

func (m *TX_TXIN) Reset()

func (*TX_TXIN) String

func (m *TX_TXIN) String() string

type TX_TXOUT

type TX_TXOUT struct {
	Value    uint64 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
	Script   []byte `protobuf:"bytes,2,opt,name=script,proto3" json:"script,omitempty"`
	Color    []byte `protobuf:"bytes,3,opt,name=color,proto3" json:"color,omitempty"`
	Quantity uint64 `protobuf:"varint,4,opt,name=quantity" json:"quantity,omitempty"`
}

func (*TX_TXOUT) Descriptor

func (*TX_TXOUT) Descriptor() ([]byte, []int)

func (*TX_TXOUT) ProtoMessage

func (*TX_TXOUT) ProtoMessage()

func (*TX_TXOUT) Reset

func (m *TX_TXOUT) Reset()

func (*TX_TXOUT) String

func (m *TX_TXOUT) String() string

type UTXO

type UTXO struct {
	Store Store
}

UTXO includes the storage for the chaincode API or an in memory store for testing

func MakeUTXO

func MakeUTXO(store Store) *UTXO

MakeUTXO constructs a new UTXO with the given store

func (*UTXO) Execute

func (u *UTXO) Execute(txData []byte) (*ExecResult, error)

Execute processes the given transaction and outputs a result

func (*UTXO) GetTransactionHash

func (u *UTXO) GetTransactionHash(txData []byte) [32]byte

GetTransactionHash returns the Bitcoin hash (double sha256) of the given transaction

func (*UTXO) IsCoinbase

func (u *UTXO) IsCoinbase(index uint32) bool

IsCoinbase returns true if this is a coinbase transaction, false otherwise

func (*UTXO) Query

func (u *UTXO) Query(txHashHex string) ([]byte, error)

Query search the storage for a given transaction hash

Jump to

Keyboard shortcuts

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