reservoir

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2017 License: ISC Imports: 28 Imported by: 1

Documentation

Overview

Cache for transactions that have been verified

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBackupBeforeInit = fmt.Errorf("can not backup data before initialisation")
	ErrLoadMoreThanOnce = fmt.Errorf("can not recover data more than once")
)
View Source
var (
	ErrInvalidLength = fmt.Errorf("invalid length of proof filter")
)

Functions

func DeleteByLink(link merkle.Digest)

remove a record using a link id

func DeleteByTxId added in v0.3.5

func DeleteByTxId(txId merkle.Digest)

remove a record using a transaction id

func Disable added in v0.3.29

func Disable()

lock down to prevent proofer from getting data

func Enable added in v0.3.29

func Enable()

allow proofer to run again

func FetchVerified added in v0.3.5

func FetchVerified(count int) ([]merkle.Digest, []transactionrecord.Packed, int, error)

fetch a series of verified transactions

func Finalise

func Finalise()

stop all

func Initialise

func Initialise(reservoirDataFile string) error

create the cache

func ReadCounters added in v0.3.5

func ReadCounters() (int, int, []int)

func ScaledDifficulty added in v0.3.30

func ScaledDifficulty(count int) *difficulty.Difficulty

produce a scaled difficulty based on the number of items in a block to be processed and include a quantity discount

func SetTransferVerified added in v0.5.0

func SetTransferVerified(payId pay.PayId, detail *PaymentDetail)

Types

type IssueInfo added in v0.3.5

type IssueInfo struct {
	Id         pay.PayId
	Nonce      PayNonce
	Difficulty *difficulty.Difficulty
	TxIds      []merkle.Digest
	Packed     []byte
}

result returned by store issues

func StoreIssues added in v0.3.5

func StoreIssues(issues []*transactionrecord.BitmarkIssue, isVerified bool) (*IssueInfo, bool, error)

store packed record(s) in the Unverified table

return payment id and a duplicate flag

for duplicate to be true all transactions must all match exactly to a previous set - this is to allow for multiple submission from client without receiving a duplicate transaction error

type PayNonce added in v0.3.30

type PayNonce [8]byte

type to represent a payment nonce Note: no reversal is required for this

func NewPayNonce added in v0.3.30

func NewPayNonce() PayNonce

create a random pay nonce

func (PayNonce) GoString added in v0.3.30

func (paynonce PayNonce) GoString() string

convert a binary pay nonce to big endian hex string for use by the fmt package (for %#v)

func (PayNonce) MarshalText added in v0.3.30

func (paynonce PayNonce) MarshalText() ([]byte, error)

convert pay nonce to big endian hex text

func (PayNonce) String added in v0.3.30

func (paynonce PayNonce) String() string

convert a binary pay nonce to big endian hex string for use by the fmt package (for %s)

func (*PayNonce) UnmarshalText added in v0.3.30

func (paynonce *PayNonce) UnmarshalText(s []byte) error

convert little endian hex text into a pay nonce

type PaymentDetail added in v0.5.0

type PaymentDetail struct {
	Currency currency.Currency
	TxID     string
	Amounts  map[string]uint64
}

type PaymentSegment added in v0.5.0

type PaymentSegment [currency.Count]*transactionrecord.Payment

a single segment of a payment e.g. for an issue or transfer block owner

type ProofFilter added in v0.5.7

type ProofFilter [4096]byte

ProofFilter is a bloom filter which is used to examine whether an issue is verified or not

func (*ProofFilter) Add added in v0.5.7

func (p *ProofFilter) Add(transaction []byte)

Add a transaction to the proof filter

func (ProofFilter) Has added in v0.5.7

func (p ProofFilter) Has(transaction []byte) bool

Has is to check whether a transaction is added into the filter

func (ProofFilter) MarshalText added in v0.5.7

func (p ProofFilter) MarshalText() ([]byte, error)

MarshalText is for encode the filter to JSON

func (*ProofFilter) UnmarshalText added in v0.5.7

func (p *ProofFilter) UnmarshalText(s []byte) error

UnmarshalText is for decode the filter from JSON

type ReservoirStore added in v0.5.7

type ReservoirStore struct {
	Assets       map[transactionrecord.AssetIndex]transactionrecord.Packed
	Issues       []transactionrecord.Packed
	ProofFilters map[string]ProofFilter
	Transfers    []transactionrecord.Packed
	// contains filtered or unexported fields
}

ReservoirStore is the struct for backup and recover unconfirmed issues and transfer

var Store *ReservoirStore

func NewReservoirStore added in v0.5.7

func NewReservoirStore(filename string) *ReservoirStore

NewReservoirStore returns a ReservoirStore with a given backup file

func (ReservoirStore) Backup added in v0.5.7

func (rs ReservoirStore) Backup() error

Backup is to save current pending and verified items to disk

func (*ReservoirStore) Restore added in v0.5.7

func (rs *ReservoirStore) Restore() error

Restore is to recover pending and verified items from disk

type TrackingStatus added in v0.3.30

type TrackingStatus int

result of track payment/try proof

const (
	TrackingNotFound  TrackingStatus = iota
	TrackingAccepted  TrackingStatus = iota
	TrackingProcessed TrackingStatus = iota
	TrackingInvalid   TrackingStatus = iota
)

possible status values

func TryProof added in v0.3.30

func TryProof(payId pay.PayId, clientNonce []byte) TrackingStatus

instead of paying, try a proof from the client nonce

func (TrackingStatus) MarshalText added in v0.3.30

func (ts TrackingStatus) MarshalText() ([]byte, error)

convert the tracking value for JSON

func (TrackingStatus) String added in v0.3.30

func (ts TrackingStatus) String() string

convert the tracking value for printf

func (*TrackingStatus) UnmarshalText added in v0.3.30

func (ts *TrackingStatus) UnmarshalText(s []byte) error

convert the tracking value from JSON to enumeration

type TransactionState added in v0.3.30

type TransactionState int

status

const (
	StateUnknown   TransactionState = iota
	StatePending   TransactionState = iota
	StateVerified  TransactionState = iota
	StateConfirmed TransactionState = iota
)

func TransactionStatus added in v0.3.30

func TransactionStatus(txId merkle.Digest) TransactionState

get status of a transaction

func (TransactionState) String added in v0.3.30

func (state TransactionState) String() string

type TransferInfo added in v0.3.5

type TransferInfo struct {
	Id       pay.PayId
	TxId     merkle.Digest
	Packed   []byte
	Payments []transactionrecord.PaymentAlternative
}

result returned by store transfer

func StoreTransfer added in v0.3.5

func StoreTransfer(transfer *transactionrecord.BitmarkTransfer) (*TransferInfo, bool, error)

Jump to

Keyboard shortcuts

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