digest

package
v0.0.0-...-bbac14e Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: GPL-3.0 Imports: 55 Imported by: 0

Documentation

Overview

Package digest provides api features.

Index

Constants

View Source
const (
	ProblemMimetype    = "application/problem+json; charset=utf-8"
	ProblemNamespace   = "https://github.com/spikeekips/mitum-currency/problems"
	DefaultProblemType = "others"
)

Variables

View Source
var (
	AccountValueType = hint.Type("mitum-currency-account-value")
	AccountValueHint = hint.NewHint(AccountValueType, "v0.0.1")
)
View Source
var (
	DefaultCacheExpire = time.Hour
	SkipCacheError     = util.NewError("skip cache")
)
View Source
var (
	BaseHalType = hint.Type("mitum-currency-hal")
	BaseHalHint = hint.NewHint(BaseHalType, "v0.0.1")
)
View Source
var (
	HTTP2EncoderHintHeader = http.CanonicalHeaderKey("x-mitum-encoder-hint")
	HALMimetype            = "application/hal+json; charset=utf-8"
)
View Source
var (
	HandlerPathNodeInfo                   = `/`
	HandlerPathCurrencies                 = `/currency`
	HandlerPathCurrency                   = `/currency/{currencyid:.*}`
	HandlerPathManifests                  = `/block/manifests`
	HandlerPathOperations                 = `/block/operations`
	HandlerPathOperation                  = `/block/operation/{hash:(?i)[0-9a-z][0-9a-z]+}`
	HandlerPathBlockByHeight              = `/block/{height:[0-9]+}`
	HandlerPathBlockByHash                = `/block/{hash:(?i)[0-9a-z][0-9a-z]+}`
	HandlerPathOperationsByHeight         = `/block/{height:[0-9]+}/operations`
	HandlerPathManifestByHeight           = `/block/{height:[0-9]+}/manifest`
	HandlerPathManifestByHash             = `/block/{hash:(?i)[0-9a-z][0-9a-z]+}/manifest`
	HandlerPathAccount                    = `/account/{address:(?i)` + base.REStringAddressString + `}`            // revive:disable-line:line-length-limit
	HandlerPathAccountOperations          = `/account/{address:(?i)` + base.REStringAddressString + `}/operations` // revive:disable-line:line-length-limit
	HandlerPathAccounts                   = `/accounts`
	HandlerPathOperationBuildFactTemplate = `/builder/operation/fact/template/{fact:[\w][\w\-]*}`
	HandlerPathOperationBuildFact         = `/builder/operation/fact`
	HandlerPathOperationBuildSign         = `/builder/operation/sign`
	HandlerPathOperationBuild             = `/builder/operation`
	HandlerPathSend                       = `/builder/send`
)
View Source
var (
	NodeInfoType = hint.Type("mitum-currency-node-info")
	NodeInfoHint = hint.NewHint(NodeInfoType, "v0.0.1")
)
View Source
var (
	OperationValueType = hint.Type("mitum-currency-operation-value")
	OperationValueHint = hint.NewHint(OperationValueType, "v0.0.1")
)
View Source
var (
	ProblemType = hint.Type("mitum-currency-problem")
	ProblemHint = hint.NewHint(ProblemType, "v0.0.1")
)
View Source
var AllCollections = []string{
	defaultColNameAccount,
	defaultColNameExtension,
	defaultColNameBalance,
	defaultColNameOperation,
}
View Source
var DigestStorageLastBlockKey = "digest_last_block"
View Source
var GlobalItemsLimit int64 = 10
View Source
var HALJSONConfigDefault = jsoniter.Config{
	EscapeHTML: false,
}.Froze()
View Source
var RateLimitHandlerMap = map[string]string{
	"node-info":                       HandlerPathNodeInfo,
	"currencies":                      HandlerPathCurrencies,
	"currency":                        HandlerPathCurrency,
	"block-manifests":                 HandlerPathManifests,
	"block-operations":                HandlerPathOperations,
	"block-operation":                 HandlerPathOperation,
	"block-by-height":                 HandlerPathBlockByHeight,
	"block-by-hash":                   HandlerPathBlockByHash,
	"block-operations-by-height":      HandlerPathOperationsByHeight,
	"block-manifest-by-height":        HandlerPathManifestByHeight,
	"block-manifest-by-hash":          HandlerPathManifestByHash,
	"account":                         HandlerPathAccount,
	"account-operations":              HandlerPathAccountOperations,
	"accounts":                        HandlerPathAccounts,
	"builder-operation-fact-template": HandlerPathOperationBuildFactTemplate,
	"builder-operation-fact":          HandlerPathOperationBuildFact,
	"builder-operation-sign":          HandlerPathOperationBuildSign,
	"builder-operation":               HandlerPathOperationBuild,
	"builder-send":                    HandlerPathSend,
}
View Source
var (
	UnknownProblem = NewProblem(DefaultProblemType, "unknown problem occurred")
)

Functions

func CacheKey

func CacheKey(key string, s ...string) string

func CacheKeyFromRequest

func CacheKeyFromRequest(r *http.Request) string

func CacheKeyPath

func CacheKeyPath(r *http.Request) string

func DefaultItemsLimiter

func DefaultItemsLimiter(string) int64

func DigestBlock

func DigestBlock(ctx context.Context, st *Database, blk block.Block) error

func HTTP2HandleError

func HTTP2HandleError(w http.ResponseWriter, err error)

func HTTP2NotSupported

func HTTP2NotSupported(w http.ResponseWriter, err error)

func HTTP2ProblemWithError

func HTTP2ProblemWithError(w http.ResponseWriter, err error, status int)

func HTTP2Stream

func HTTP2Stream(enc encoder.Encoder, w http.ResponseWriter, bufsize int, status int) (*jsoniter.Stream, func())

func HTTP2WriteCache

func HTTP2WriteCache(w http.ResponseWriter, key string, expire time.Duration)

func HTTP2WriteHal

func HTTP2WriteHal(enc encoder.Encoder, w http.ResponseWriter, hal Hal, status int)

func HTTP2WriteHalBytes

func HTTP2WriteHalBytes(enc encoder.Encoder, w http.ResponseWriter, b []byte, status int)

func HTTP2WritePoblem

func HTTP2WritePoblem(w http.ResponseWriter, pr Problem, status int)

func IsAccountState

func IsAccountState(st state.State) (currency.Account, bool, error)

func IsBalanceState

func IsBalanceState(st state.State) (currency.Amount, bool, error)

func LoadBalance

func LoadBalance(decoder func(interface{}) error, encs *encoder.Encoders) (state.State, error)

func LoadContractAccountStatus

func LoadContractAccountStatus(decoder func(interface{}) error, encs *encoder.Encoders) (state.State, error)

func LoadCurrenciesFromDatabase

func LoadCurrenciesFromDatabase(
	st *mongodbstorage.Database,
	height base.Height,
	callback func(state.State) (bool, error),
) error

func LoadFromCache

func LoadFromCache(cache Cache, key string, w http.ResponseWriter) error

func LoadOperationHash

func LoadOperationHash(decoder func(interface{}) error) (valuehash.Hash, error)

func MakeCacheKey

func MakeCacheKey(key string) string

func ScanCRLF

func ScanCRLF(data []byte, atEOF bool) (int, []byte, error)

func WriteFromCache

func WriteFromCache(b []byte, w http.ResponseWriter) error

Types

type AccountDoc

type AccountDoc struct {
	mongodbstorage.BaseDoc
	// contains filtered or unexported fields
}

func NewAccountDoc

func NewAccountDoc(rs AccountValue, enc encoder.Encoder) (AccountDoc, error)

func (AccountDoc) MarshalBSON

func (doc AccountDoc) MarshalBSON() ([]byte, error)

type AccountValue

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

func LoadAccountValue

func LoadAccountValue(decoder func(interface{}) error, encs *encoder.Encoders) (AccountValue, error)

func NewAccountValue

func NewAccountValue(st state.State) (AccountValue, error)

func (AccountValue) Account

func (va AccountValue) Account() currency.Account

func (AccountValue) Balance

func (va AccountValue) Balance() []currency.Amount

func (AccountValue) Height

func (va AccountValue) Height() base.Height

func (AccountValue) Hint

func (AccountValue) Hint() hint.Hint

func (AccountValue) MarshalBSON

func (va AccountValue) MarshalBSON() ([]byte, error)

func (AccountValue) MarshalJSON

func (va AccountValue) MarshalJSON() ([]byte, error)

func (AccountValue) Owner

func (va AccountValue) Owner() base.Address

func (AccountValue) PreviousHeight

func (va AccountValue) PreviousHeight() base.Height

func (AccountValue) SetBalance

func (va AccountValue) SetBalance(balance []currency.Amount) AccountValue

func (AccountValue) SetContractAccountStatus

func (va AccountValue) SetContractAccountStatus(owner base.Address, active bool) AccountValue

func (AccountValue) SetHeight

func (va AccountValue) SetHeight(height base.Height) AccountValue

func (AccountValue) SetPreviousHeight

func (va AccountValue) SetPreviousHeight(height base.Height) AccountValue

func (*AccountValue) UnpackBSON

func (va *AccountValue) UnpackBSON(b []byte, enc *bsonenc.Encoder) error

func (*AccountValue) UnpackJSON

func (va *AccountValue) UnpackJSON(b []byte, enc *jsonenc.Encoder) error

type AccountValueBSONUnpacker

type AccountValueBSONUnpacker struct {
	AC bson.Raw            `bson:"ac"`
	BL bson.Raw            `bson:"balance"`
	OW base.AddressDecoder `bson:"owner"`
	IA bool                `bson:"isactivecontractaccount"`
	HT base.Height         `bson:"height"`
	PT base.Height         `bson:"previous_height"`
}

type AccountValueJSONPacker

type AccountValueJSONPacker struct {
	jsonenc.HintedHead
	currency.AccountPackerJSON
	BL []currency.Amount `json:"balance,omitempty"`
	OW base.Address      `json:"owner,omitempty"`
	IA bool              `json:"isactivecontractaccount"`
	HT base.Height       `json:"height"`
	PT base.Height       `json:"previous_height"`
}

type AccountValueJSONUnpacker

type AccountValueJSONUnpacker struct {
	BL json.RawMessage     `json:"balance"`
	OW base.AddressDecoder `json:"owner"`
	IA bool                `json:"isactivecontractaccount"`
	HT base.Height         `json:"height"`
	PT base.Height         `json:"previous_height"`
}

type BalanceDoc

type BalanceDoc struct {
	mongodbstorage.BaseDoc
	// contains filtered or unexported fields
}

func NewBalanceDoc

func NewBalanceDoc(st state.State, enc encoder.Encoder) (BalanceDoc, error)

NewBalanceDoc gets the State of Amount

func (BalanceDoc) MarshalBSON

func (doc BalanceDoc) MarshalBSON() ([]byte, error)

type BaseHal

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

func NewBaseHal

func NewBaseHal(i interface{}, self HalLink) BaseHal

func (BaseHal) AddExtras

func (hal BaseHal) AddExtras(key string, value interface{}) Hal
func (hal BaseHal) AddLink(rel string, link HalLink) Hal

func (BaseHal) Extras

func (hal BaseHal) Extras() map[string]interface{}

func (BaseHal) Hint

func (BaseHal) Hint() hint.Hint

func (BaseHal) Interface

func (hal BaseHal) Interface() interface{}
func (hal BaseHal) Links() map[string]HalLink

func (BaseHal) MarshalJSON

func (hal BaseHal) MarshalJSON() ([]byte, error)

func (BaseHal) RawInterface

func (hal BaseHal) RawInterface() []byte

func (BaseHal) Self

func (hal BaseHal) Self() HalLink

func (BaseHal) SetInterface

func (hal BaseHal) SetInterface(i interface{}) Hal

func (BaseHal) SetSelf

func (hal BaseHal) SetSelf(u HalLink) Hal

func (*BaseHal) UnmarshalJSON

func (hal *BaseHal) UnmarshalJSON(b []byte) error

type BaseHalJSONPacker

type BaseHalJSONPacker struct {
	jsonenc.HintedHead
	HINT hint.Hint              `json:"hint,omitempty"`
	I    interface{}            `json:"_embedded,omitempty"`
	LS   map[string]HalLink     `json:"_links,omitempty"`
	EX   map[string]interface{} `json:"_extra,omitempty"`
}

type BaseHalJSONUnpacker

type BaseHalJSONUnpacker struct {
	R  json.RawMessage        `json:"_embedded,omitempty"`
	LS map[string]HalLink     `json:"_links,omitempty"`
	EX map[string]interface{} `json:"_extra,omitempty"`
}

type BlockSession

type BlockSession struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewBlockSession

func NewBlockSession(st *Database, blk block.Block) (*BlockSession, error)

func (*BlockSession) Close

func (bs *BlockSession) Close() error

func (*BlockSession) Commit

func (bs *BlockSession) Commit(ctx context.Context) error

func (*BlockSession) Prepare

func (bs *BlockSession) Prepare() error

type Builder

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

func NewBuilder

func NewBuilder(enc encoder.Encoder, networkID base.NetworkID) Builder

func (Builder) BuildFact

func (bl Builder) BuildFact(b []byte) (Hal, error)

func (Builder) BuildOperation

func (bl Builder) BuildOperation(b []byte) (Hal, error)

func (Builder) FactTemplate

func (bl Builder) FactTemplate(ht hint.Hint) (Hal, error)

type Cache

type Cache interface {
	Get(string) ([]byte, error)
	Set(string, []byte, time.Duration) error
}

func NewCacheFromURI

func NewCacheFromURI(uri string) (Cache, error)

type CacheResponseWriter

type CacheResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func NewCacheResponseWriter

func NewCacheResponseWriter(cache Cache, w http.ResponseWriter, r *http.Request) *CacheResponseWriter

func (*CacheResponseWriter) Cache

func (cr *CacheResponseWriter) Cache() error

func (*CacheResponseWriter) Expire

func (cr *CacheResponseWriter) Expire() time.Duration

func (*CacheResponseWriter) Key

func (cr *CacheResponseWriter) Key() string

func (*CacheResponseWriter) OK

func (cr *CacheResponseWriter) OK() bool

func (*CacheResponseWriter) SetExpire

func (cr *CacheResponseWriter) SetExpire(expire time.Duration) *CacheResponseWriter

func (*CacheResponseWriter) SetKey

func (*CacheResponseWriter) SkipCache

func (cr *CacheResponseWriter) SkipCache() *CacheResponseWriter

func (*CacheResponseWriter) Write

func (cr *CacheResponseWriter) Write(b []byte) (int, error)

func (*CacheResponseWriter) WriteHeader

func (cr *CacheResponseWriter) WriteHeader(status int)

type CachedHTTPHandler

type CachedHTTPHandler struct {
	*logging.Logging
	// contains filtered or unexported fields
}

func NewCachedHTTPHandler

func NewCachedHTTPHandler(cache Cache, f func(http.ResponseWriter, *http.Request)) CachedHTTPHandler

func (CachedHTTPHandler) ServeHTTP

func (ch CachedHTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ContractAccountStatusDoc

type ContractAccountStatusDoc struct {
	mongodbstorage.BaseDoc
	// contains filtered or unexported fields
}

func NewContractAccountStatusDoc

func NewContractAccountStatusDoc(st state.State, enc encoder.Encoder) (ContractAccountStatusDoc, error)

NewContractAccountStatusDoc gets the State of contract account status

func (ContractAccountStatusDoc) MarshalBSON

func (doc ContractAccountStatusDoc) MarshalBSON() ([]byte, error)

type Database

type Database struct {
	sync.RWMutex
	*logging.Logging
	// contains filtered or unexported fields
}

func NewDatabase

func NewDatabase(mitum *mongodbstorage.Database, st *mongodbstorage.Database) (*Database, error)

func NewReadonlyDatabase

func NewReadonlyDatabase(mitum *mongodbstorage.Database, st *mongodbstorage.Database) (*Database, error)

func (*Database) Account

func (st *Database) Account(a base.Address) (AccountValue, bool, error)

Account returns AccountValue.

func (*Database) AccountsByPublickey

func (st *Database) AccountsByPublickey(
	pub key.Publickey,
	loadBalance bool,
	offsetHeight base.Height,
	offsetAddress string,
	limit int64,
	callback func(AccountValue) (bool, error),
) error

AccountsByPublickey finds Accounts, which are related with the given Publickey. * offset: returns from next of offset, usually it is "<height>,<address>".

func (*Database) Clean

func (st *Database) Clean() error

func (*Database) CleanByHeight

func (st *Database) CleanByHeight(ctx context.Context, height base.Height) error

func (*Database) Close

func (st *Database) Close() error

func (*Database) ContractAccountStatus

func (st *Database) ContractAccountStatus(a base.Address) (base.Address, bool, base.Height, base.Height, error)

ContractAccountStatus return contract account owner by address

func (*Database) Initialize

func (st *Database) Initialize() error

func (*Database) LastBlock

func (st *Database) LastBlock() base.Height

func (*Database) Manifest

func (st *Database) Manifest(h valuehash.Hash) (block.Manifest, bool, error)

func (*Database) ManifestByHeight

func (st *Database) ManifestByHeight(height base.Height) (block.Manifest, bool, error)

func (*Database) Manifests

func (st *Database) Manifests(
	load bool,
	reverse bool,
	offset base.Height,
	limit int64,
	callback func(base.Height, valuehash.Hash, block.Manifest) (bool, error),
) error

Manifests returns block.Manifests by it's order, height.

func (*Database) New

func (st *Database) New() (*Database, error)

func (*Database) Operation

func (st *Database) Operation(
	h valuehash.Hash,
	load bool,
) (OperationValue, bool, error)

Operation returns operation.Operation. If load is false, just returns nil Operation.

func (*Database) Operations

func (st *Database) Operations(
	filter bson.M,
	load bool,
	reverse bool,
	limit int64,
	callback func(valuehash.Hash, OperationValue) (bool, error),
) error

Operations returns operation.Operations by it's order, height and index.

func (*Database) OperationsByAddress

func (st *Database) OperationsByAddress(
	address base.Address,
	load,
	reverse bool,
	offset string,
	limit int64,
	callback func(valuehash.Hash, OperationValue) (bool, error),
) error

OperationsByAddress finds the operation.Operations, which are related with the given Address. The returned valuehash.Hash is the operation.Operation.Fact().Hash(). * load:if true, load operation.Operation and returns it. If not, just hash will be returned * reverse: order by height; if true, higher height will be returned first. * offset: returns from next of offset, usually it is combination of "<height>,<fact>".

func (*Database) Readonly

func (st *Database) Readonly() bool

func (*Database) SetLastBlock

func (st *Database) SetLastBlock(height base.Height) error

type DigestError

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

func NewDigestError

func NewDigestError(err error, height base.Height) DigestError

func (DigestError) Error

func (de DigestError) Error() string

func (DigestError) Height

func (de DigestError) Height() base.Height

func (DigestError) IsError

func (de DigestError) IsError() bool

type Digester

type Digester struct {
	sync.RWMutex
	*util.ContextDaemon
	*logging.Logging
	// contains filtered or unexported fields
}

func NewDigester

func NewDigester(st *Database, errChan chan error) *Digester

func (*Digester) Digest

func (di *Digester) Digest(blocks []block.Block)

type DummyCache

type DummyCache struct{}

func (DummyCache) Get

func (DummyCache) Get(string) ([]byte, error)

func (DummyCache) Set

type HTTP2Server

type HTTP2Server struct {
	sync.RWMutex
	*logging.Logging
	*util.ContextDaemon
	// contains filtered or unexported fields
}

func NewHTTP2Server

func NewHTTP2Server(bind, host string, certs []tls.Certificate) (*HTTP2Server, error)

func (*HTTP2Server) Initialize

func (sv *HTTP2Server) Initialize() error

func (*HTTP2Server) Router

func (sv *HTTP2Server) Router() *mux.Router

func (*HTTP2Server) SetLogging

func (sv *HTTP2Server) SetLogging(l *logging.Logging) *logging.Logging

func (*HTTP2Server) SetRouter

func (sv *HTTP2Server) SetRouter(router *mux.Router)

type Hal

type Hal interface {
	RawInterface() []byte
	Interface() interface{}
	SetInterface(interface{}) Hal
	Self() HalLink
	SetSelf(HalLink) Hal
	Links() map[string]HalLink
	AddLink(rel string, link HalLink) Hal
	Extras() map[string]interface{}
	AddExtras(string, interface{}) Hal
}
type HalLink struct {
	// contains filtered or unexported fields
}
func NewHalLink(href string, properties map[string]interface{}) HalLink

func (HalLink) Href

func (hl HalLink) Href() string

func (HalLink) MarshalJSON

func (hl HalLink) MarshalJSON() ([]byte, error)

func (HalLink) Properties

func (hl HalLink) Properties() map[string]interface{}

func (HalLink) SetProperty

func (hl HalLink) SetProperty(key string, value interface{}) HalLink

func (HalLink) SetTemplated

func (hl HalLink) SetTemplated() HalLink

func (HalLink) URL

func (hl HalLink) URL() (*url.URL, error)

func (*HalLink) UnmarshalJSON

func (hl *HalLink) UnmarshalJSON(b []byte) error

type HalLinkJSONUnpacker

type HalLinkJSONUnpacker struct {
	HR string                 `json:"href"`
	PR map[string]interface{} `json:"properties,omitempty"`
}

type Handlers

type Handlers struct {
	*logging.Logging
	// contains filtered or unexported fields
}

func NewHandlers

func NewHandlers(
	networkID base.NetworkID,
	encs *encoder.Encoders,
	enc encoder.Encoder,
	st *Database,
	cache Cache,
	cp *extensioncurrency.CurrencyPool,
) *Handlers

func (*Handlers) Cache

func (hd *Handlers) Cache() Cache

func (*Handlers) Handler

func (hd *Handlers) Handler() http.Handler

func (*Handlers) Initialize

func (hd *Handlers) Initialize() error

func (*Handlers) Router

func (hd *Handlers) Router() *mux.Router

func (*Handlers) SetLimiter

func (hd *Handlers) SetLimiter(f func(string) int64) *Handlers

func (*Handlers) SetNodeInfoHandler

func (hd *Handlers) SetNodeInfoHandler(handler network.NodeInfoHandler) *Handlers

func (*Handlers) SetRateLimit

func (hd *Handlers) SetRateLimit(rules map[string][]process.RateLimitRule, store limiter.Store) *Handlers

func (*Handlers) SetSend

func (hd *Handlers) SetSend(f func(interface{}) (seal.Seal, error)) *Handlers

type LocalMemCache

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

func NewLocalMemCache

func NewLocalMemCache(size int, expire time.Duration) *LocalMemCache

func (*LocalMemCache) Get

func (ca *LocalMemCache) Get(key string) ([]byte, error)

func (*LocalMemCache) Set

func (ca *LocalMemCache) Set(key string, b []byte, expire time.Duration) error

type Memcached

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

func NewMemcached

func NewMemcached(servers ...string) (*Memcached, error)

func (*Memcached) Get

func (mc *Memcached) Get(key string) ([]byte, error)

func (*Memcached) Set

func (mc *Memcached) Set(key string, b []byte, expire time.Duration) error

type NodeInfo

type NodeInfo struct {
	network.NodeInfoV0
}

func NewNodeInfo

func NewNodeInfo(ni network.NodeInfoV0) NodeInfo

func (NodeInfo) Hint

func (NodeInfo) Hint() hint.Hint

func (NodeInfo) MarshalBSON

func (ni NodeInfo) MarshalBSON() ([]byte, error)

func (NodeInfo) MarshalJSON

func (ni NodeInfo) MarshalJSON() ([]byte, error)

func (NodeInfo) String

func (ni NodeInfo) String() string

func (*NodeInfo) UnpackBSON

func (ni *NodeInfo) UnpackBSON(b []byte, enc *bsonenc.Encoder) error

func (*NodeInfo) UnpackJSON

func (ni *NodeInfo) UnpackJSON(b []byte, enc *jsonenc.Encoder) error

type NodeInfoPackerJSON

type NodeInfoPackerJSON struct {
	jsonenc.HintedHead
	network.NodeInfoV0PackerJSON
}

type OperationDoc

type OperationDoc struct {
	mongodbstorage.BaseDoc
	// contains filtered or unexported fields
}

func NewOperationDoc

func NewOperationDoc(
	op operation.Operation,
	enc encoder.Encoder,
	height base.Height,
	confirmedAt time.Time,
	inState bool,
	reason operation.ReasonError,
	index uint64,
) (OperationDoc, error)

func (OperationDoc) MarshalBSON

func (doc OperationDoc) MarshalBSON() ([]byte, error)

type OperationValue

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

func LoadOperation

func LoadOperation(decoder func(interface{}) error, encs *encoder.Encoders) (OperationValue, error)

func NewOperationValue

func NewOperationValue(
	op operation.Operation,
	height base.Height,
	confirmedAt time.Time,
	inState bool,
	reason operation.ReasonError,
	index uint64,
) OperationValue

func (OperationValue) ConfirmedAt

func (va OperationValue) ConfirmedAt() time.Time

func (OperationValue) Height

func (va OperationValue) Height() base.Height

func (OperationValue) Hint

func (OperationValue) Hint() hint.Hint

func (OperationValue) InState

func (va OperationValue) InState() bool

func (OperationValue) Index

func (va OperationValue) Index() uint64

Index indicates the index number of Operation in OperationTree of block.

func (OperationValue) MarshalBSON

func (va OperationValue) MarshalBSON() ([]byte, error)

func (OperationValue) MarshalJSON

func (va OperationValue) MarshalJSON() ([]byte, error)

func (OperationValue) Operation

func (va OperationValue) Operation() operation.Operation

func (OperationValue) Reason

func (va OperationValue) Reason() operation.ReasonError

func (*OperationValue) UnpackBSON

func (va *OperationValue) UnpackBSON(b []byte, enc *bsonenc.Encoder) error

func (*OperationValue) UnpackJSON

func (va *OperationValue) UnpackJSON(b []byte, enc *jsonenc.Encoder) error

type OperationValueBSONUnpacker

type OperationValueBSONUnpacker struct {
	OP bson.Raw    `bson:"op"`
	HT base.Height `bson:"height"`
	CT time.Time   `bson:"confirmed_at"`
	IN bool        `bson:"in_state"`
	RS bson.Raw    `bson:"reason"`
	ID uint64      `bson:"index"`
}

type OperationValueJSONPacker

type OperationValueJSONPacker struct {
	jsonenc.HintedHead
	HS valuehash.Hash        `json:"hash"`
	OP operation.Operation   `json:"operation"`
	HT base.Height           `json:"height"`
	CF localtime.Time        `json:"confirmed_at"`
	RS operation.ReasonError `json:"reason"`
	IN bool                  `json:"in_state"`
	ID uint64                `json:"index"`
}

type OperationValueJSONUnpacker

type OperationValueJSONUnpacker struct {
	OP json.RawMessage `json:"operation"`
	HT base.Height     `json:"height"`
	CF localtime.Time  `json:"confirmed_at"`
	IN bool            `json:"in_state"`
	RS json.RawMessage `json:"reason"`
	ID uint64          `json:"index"`
}

type Problem

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

Problem implements "Problem Details for HTTP APIs"<https://tools.ietf.org/html/rfc7807>.

func NewProblem

func NewProblem(t, title string) Problem

func NewProblemFromError

func NewProblemFromError(err error) Problem

func (Problem) Error

func (pr Problem) Error() string

func (Problem) Hint

func (Problem) Hint() hint.Hint

func (Problem) MarshalJSON

func (pr Problem) MarshalJSON() ([]byte, error)

func (Problem) SetDetail

func (pr Problem) SetDetail(detail string) Problem

func (Problem) SetExtra

func (pr Problem) SetExtra(key string, value interface{}) Problem

func (Problem) SetTitle

func (pr Problem) SetTitle(title string) Problem

func (*Problem) UnmarshalJSON

func (pr *Problem) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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