utils

package module
v0.0.0-...-0cf994e Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: MIT Imports: 13 Imported by: 0

README

sawtooth-utils

Utilities methods and structs commonly used among Transaction Processors

Documentation

Index

Constants

View Source
const MaxLength = 70
View Source
const (
	PrefixEndPos = 6
)

Variables

This section is empty.

Functions

func BytesToHex

func BytesToHex(b []byte) string

BytesToHex return hex encoded string

func DecodeHexBytes

func DecodeHexBytes(b []byte) ([]byte, error)

DecodeHexBytes return hex decoded bytes

func DecodeHexStr

func DecodeHexStr(str string) ([]byte, error)

DecodeHexStr return hex decoded bytes

func HexDigest

func HexDigest(str string, startPos, endPos int64) string

HexDigest returns hex digest sub-stringed by designated start and stop pos

func NewTransactionProcessor

func NewTransactionProcessor(validator string, handler processor.TransactionHandler) *processor.TransactionProcessor

func ProofOfIntegrityHash

func ProofOfIntegrityHash(data []byte) string

ProofOfIntegrityHash create a proof of intergrity hash

func StrToHex

func StrToHex(str string) string

StrToHex return hex encoded string

func VerifyPOIHash

func VerifyPOIHash(b []byte, check string) (string, bool)

VerifyPOIHash verify proof of integrity hash provided for some data is valid

func VerifySig

func VerifySig(signature string, publicKey, message []byte, hexEnc bool) bool

VerifySig verify a signed message

Types

type AddressBuilder

type AddressBuilder struct {
	Prefix string
	Parts  []*AddressPart
}

func NewAddress

func NewAddress(prefix string) *AddressBuilder

func (*AddressBuilder) AddParts

func (a *AddressBuilder) AddParts(part ...*AddressPart) *AddressBuilder

func (*AddressBuilder) Build

func (a *AddressBuilder) Build() (string, bool)

func (*AddressBuilder) IsValidSize

func (a *AddressBuilder) IsValidSize() bool

type AddressPart

type AddressPart struct {
	Data           string
	DigestStartPos int64
	DigestEndPos   int64
}

func NewPart

func NewPart(data string, startPos, endPos int64) *AddressPart

type File

type File struct {
	Data         string `json:"data"`
	LastModified int64  `json:"last_modified"`
	Name         string `json:"name"`
	FileType     string `json:"file_type"`
}

File ...

type IPFSClient

type IPFSClient struct {
	Host  string
	Shell *shell.Shell
}

IPFSClient ...

func NewIPFSHTTPClient

func NewIPFSHTTPClient(host string) *IPFSClient

NewIPFSHTTPClient ...

func (*IPFSClient) AddFile

func (ipfs *IPFSClient) AddFile(filename, filetype string, data []byte) (string, string, error)

AddFile ...

func (*IPFSClient) GetFileName

func (ipfs *IPFSClient) GetFileName(name, filetype string) string

GetFileName ...

func (*IPFSClient) NewFile

func (ipfs *IPFSClient) NewFile(name string, data []byte) (*File, []byte)

NewFile ...

type MethodDelegate

type MethodDelegate interface {
	DelegateMethod(*processor_pb2.TpProcessRequest, *processor.Context) error
}

type MethodHandler

type MethodHandler interface {
	Handle(*processor_pb2.TpProcessRequest, *processor.Context, interface{}) error
	Method() string
}

type NamespaceMngr

type NamespaceMngr struct {
	NameSpaces []string
}

NamespaceMngr

func NewNamespaceMngr

func NewNamespaceMngr() *NamespaceMngr

func (*NamespaceMngr) ComputeDefaultPrefix

func (s *NamespaceMngr) ComputeDefaultPrefix(prefix string) string

ComputeDefaultPrefix returns namespace prefix of 6 bytes for our default prefixes that will be used to generate various state address's

func (*NamespaceMngr) RegisterNamespaces

func (s *NamespaceMngr) RegisterNamespaces(prefixes ...string) *NamespaceMngr

RegisterNamespaces register a namespace with our state address manager

type RPCClient

type RPCClient struct {
	MethodHandlers map[string]MethodHandler
	// contains filtered or unexported fields
}

func NewRPCClient

func NewRPCClient(methodHandlers []MethodHandler, delegateDB RPCDelegateCB) *RPCClient

func (*RPCClient) DelegateMethod

func (r *RPCClient) DelegateMethod(request *processor_pb2.TpProcessRequest, context *processor.Context) error

type RPCDelegateCB

type RPCDelegateCB func(request *processor_pb2.TpProcessRequest) (string, interface{}, error)

type Response

type Response struct {
	Name  string `json:"Name"`
	Hash  string `json:"Hash"`
	Bytes int64  `json:"Bytes"`
	Size  string `json:"Size"`
}

Response ...

type State

type State struct {
	Context *processor.Context
}

State ...

func NewStateInstance

func NewStateInstance(context *processor.Context) *State

NewStateInstance ...

type TransactionHandler

type TransactionHandler struct {
	FName          string   `json:"familyName"`
	FVersions      []string `json:"familyVersions"`
	MethodDelegate MethodDelegate
	NamespaceMngr  *NamespaceMngr
}

TransactionHandler ...

func NewTransactionHandler

func NewTransactionHandler(methodDelegate MethodDelegate, fname string, fversions, namespaces []string) *TransactionHandler

NewTransactionHandler returns a new transaction handler

func (*TransactionHandler) Apply

Apply ...

func (*TransactionHandler) FamilyName

func (t *TransactionHandler) FamilyName() string

FamilyName ...

func (*TransactionHandler) FamilyVersions

func (t *TransactionHandler) FamilyVersions() []string

FamilyVersions ...

func (*TransactionHandler) Namespaces

func (t *TransactionHandler) Namespaces() []string

Namespaces ...

Directories

Path Synopsis
protos

Jump to

Keyboard shortcuts

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