Documentation ¶
Overview ¶
此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
Index ¶
- Constants
- Variables
- func NewError(code int, s string) error
- func NewErrorf(code int, format string, args ...interface{}) error
- type DefaultTimestampProvider
- type Error
- type GenericSigner
- type Handler
- func (h *Handler) GetContent(rootAddr storage.Address) (storage.Address, []byte, error)
- func (h *Handler) GetLastPeriod(rootAddr storage.Address) (uint32, error)
- func (h *Handler) GetVersion(rootAddr storage.Address) (uint32, error)
- func (h *Handler) Load(ctx context.Context, rootAddr storage.Address) (*resource, error)
- func (h *Handler) Lookup(ctx context.Context, params *LookupParams) (*resource, error)
- func (h *Handler) LookupPrevious(ctx context.Context, params *LookupParams) (*resource, error)
- func (h *Handler) New(ctx context.Context, request *Request) error
- func (h *Handler) NewUpdateRequest(ctx context.Context, rootAddr storage.Address) (updateRequest *Request, err error)
- func (h *Handler) SetStore(store *storage.NetStore)
- func (h *Handler) Update(ctx context.Context, r *SignedResourceUpdate) (storage.Address, error)
- func (h *Handler) Validate(chunkAddr storage.Address, data []byte) bool
- type HandlerParams
- type LookupParams
- func LookupLatest(rootAddr storage.Address) *LookupParams
- func LookupLatestVersionInPeriod(rootAddr storage.Address, period uint32) *LookupParams
- func LookupVersion(rootAddr storage.Address, period, version uint32) *LookupParams
- func NewLookupParams(rootAddr storage.Address, period, version uint32, limit uint32) *LookupParams
- type Request
- func (r *Request) Frequency() uint64
- func (r *Request) IsNew() bool
- func (r *Request) IsUpdate() bool
- func (r *Request) MarshalJSON() (rawData []byte, err error)
- func (r *Request) Multihash() bool
- func (r *Request) Name() string
- func (r *Request) Owner() common.Address
- func (r *Request) Period() uint32
- func (r *Request) RootAddr() storage.Address
- func (r *Request) SetData(data []byte, multihash bool)
- func (r *Request) Sign(signer Signer) error
- func (r *Request) StartTime() Timestamp
- func (r *Request) UnmarshalJSON(rawData []byte) error
- func (r *Request) Version() uint32
- type ResourceMetadata
- type Signature
- type SignedResourceUpdate
- type Signer
- type TestHandler
- type Timestamp
- type UpdateLookup
Constants ¶
View Source
const ( ErrInit = iota ErrNotFound ErrIO ErrInvalidValue ErrDataOverflow ErrNothingToReturn ErrCorruptData ErrInvalidSignature ErrNotSynced ErrPeriodDepth ErrCnt )
Variables ¶
View Source
var TimestampProvider timestampProvider = NewDefaultTimestampProvider()
Functions ¶
Types ¶
type DefaultTimestampProvider ¶
type DefaultTimestampProvider struct { }
func NewDefaultTimestampProvider ¶
func NewDefaultTimestampProvider() *DefaultTimestampProvider
func (*DefaultTimestampProvider) Now ¶
func (dtp *DefaultTimestampProvider) Now() Timestamp
type GenericSigner ¶
type GenericSigner struct { PrivKey *ecdsa.PrivateKey // contains filtered or unexported fields }
func NewGenericSigner ¶
func NewGenericSigner(privKey *ecdsa.PrivateKey) *GenericSigner
func (*GenericSigner) Address ¶
func (s *GenericSigner) Address() common.Address
type Handler ¶
type Handler struct { HashSize int // contains filtered or unexported fields }
func NewHandler ¶
func NewHandler(params *HandlerParams) *Handler
func (*Handler) GetContent ¶
func (*Handler) GetLastPeriod ¶
func (*Handler) Lookup ¶
func (h *Handler) Lookup(ctx context.Context, params *LookupParams) (*resource, error)
func (*Handler) LookupPrevious ¶
func (h *Handler) LookupPrevious(ctx context.Context, params *LookupParams) (*resource, error)
func (*Handler) NewUpdateRequest ¶
type HandlerParams ¶
type HandlerParams struct {
QueryMaxPeriods uint32
}
type LookupParams ¶
type LookupParams struct { UpdateLookup Limit uint32 }
func LookupLatest ¶
func LookupLatest(rootAddr storage.Address) *LookupParams
func LookupLatestVersionInPeriod ¶
func LookupLatestVersionInPeriod(rootAddr storage.Address, period uint32) *LookupParams
func LookupVersion ¶
func LookupVersion(rootAddr storage.Address, period, version uint32) *LookupParams
func NewLookupParams ¶
func NewLookupParams(rootAddr storage.Address, period, version uint32, limit uint32) *LookupParams
func (*LookupParams) RootAddr ¶
func (r *LookupParams) RootAddr() storage.Address
type Request ¶
type Request struct { SignedResourceUpdate // contains filtered or unexported fields }
func NewCreateRequest ¶
func NewCreateRequest(metadata *ResourceMetadata) (request *Request, err error)
func NewCreateUpdateRequest ¶
func NewCreateUpdateRequest(metadata *ResourceMetadata) (*Request, error)
func (*Request) MarshalJSON ¶
func (*Request) UnmarshalJSON ¶
type ResourceMetadata ¶
type SignedResourceUpdate ¶
type SignedResourceUpdate struct {
// contains filtered or unexported fields
}
func (*SignedResourceUpdate) GetDigest ¶
func (r *SignedResourceUpdate) GetDigest() (result common.Hash, err error)
func (*SignedResourceUpdate) Sign ¶
func (r *SignedResourceUpdate) Sign(signer Signer) error
func (*SignedResourceUpdate) Verify ¶
func (r *SignedResourceUpdate) Verify() (err error)
type TestHandler ¶
type TestHandler struct {
*Handler
}
func NewTestHandler ¶
func NewTestHandler(datadir string, params *HandlerParams) (*TestHandler, error)
func (*TestHandler) Close ¶
func (t *TestHandler) Close()
type UpdateLookup ¶
type UpdateLookup struct {
// contains filtered or unexported fields
}
func (*UpdateLookup) UpdateAddr ¶
func (u *UpdateLookup) UpdateAddr() (updateAddr storage.Address)
Click to show internal directories.
Click to hide internal directories.