Documentation
¶
Overview ¶
Package store provides ability to store anchors and related data, that brings an abstraction layer between the Gateway (package gw) and databases.
Index ¶
- Variables
- type AnchorEntity
- type Docstore
- func (d *Docstore) Close() error
- func (d *Docstore) Get(ctx context.Context, bbc1dom, bbc1tx []byte) (*model.AnchorRecord, error)
- func (d *Docstore) GetEntity(ctx context.Context, e *AnchorEntity) error
- func (d *Docstore) Open() error
- func (d *Docstore) Put(ctx context.Context, r *model.AnchorRecord) error
- func (d *Docstore) PutEntity(ctx context.Context, e *AnchorEntity) error
- func (d *Docstore) UpdateBBc1DomainName(ctx context.Context, bbc1dom, bbc1tx []byte, bbc1domName string) error
- func (d *Docstore) UpdateConfirmations(ctx context.Context, bbc1dom, bbc1tx []byte, confirmations uint) error
- func (d *Docstore) UpdateEntity(ctx context.Context, e *AnchorEntity, ...) error
- func (d *Docstore) UpdateNote(ctx context.Context, bbc1dom, bbc1tx []byte, note string) error
- type Store
Constants ¶
This section is empty.
Variables ¶
var ( ErrFailedToOpen = errors.New("ErrFailedToOpen") ErrFailedToClose = errors.New("ErrFailedToClose") ErrFailedToGet = errors.New("ErrFailedToGet") ErrFailedToPut = errors.New("ErrFailedToPut") ErrFailedToUpdate = errors.New("ErrFailedToUpdate") )
Errors
Functions ¶
This section is empty.
Types ¶
type AnchorEntity ¶
type AnchorEntity struct {
CID string `docstore:"cid"`
BBc1DomainID []byte `docstore:"bbc1domid"`
BBc1TransactionID []byte `docstore:"bbc1txid"`
AnchorVersion uint8 `docstore:"anchorver"`
BTCNet uint8 `docstore:"btcnet"`
AnchorTime time.Time `docstore:"anchortime"`
BTCTransactionID []byte `docstore:"btctxid"`
TransactionTime time.Time `docstore:"txtime"`
Confirmations uint `docstore:"confirmations"`
BBc1DomainName string `docstore:"bbc1dom"`
Note string `docstore:"note"`
}
AnchorEntity contains data equivalent to AnchorRecord, but focuses on placing data in the datastore. In particular, CID is a key field that contains a combined string that starts with BBc-1 domain ID, followed by transaction ID.
func NewAnchorEntity ¶
func NewAnchorEntity(r *model.AnchorRecord) *AnchorEntity
NewAnchorEntity initializes an AnchorEntity from the given AnchorRecord.
func (*AnchorEntity) AnchorRecord ¶
func (e *AnchorEntity) AnchorRecord() *model.AnchorRecord
AnchorRecord returns an AnchorRecord from the AnchorEntity.
type Docstore ¶
type Docstore struct {
// contains filtered or unexported fields
}
func NewDocstore ¶
func (*Docstore) GetEntity ¶
func (d *Docstore) GetEntity(ctx context.Context, e *AnchorEntity) error
func (*Docstore) PutEntity ¶
func (d *Docstore) PutEntity(ctx context.Context, e *AnchorEntity) error
func (*Docstore) UpdateBBc1DomainName ¶
func (*Docstore) UpdateConfirmations ¶
func (*Docstore) UpdateEntity ¶
func (d *Docstore) UpdateEntity(ctx context.Context, e *AnchorEntity, updateConfirmations, updateBBc1Dom, updateNote bool) error
UpdateEntity updates the AnchorEntity specified by e.CID. It updates Confirmations, BBc1DomainName, and Note only, as other data must not be changed.
type Store ¶
type Store interface {
// Put adds or replaces an AnchorRecord in O(1) time.
Put(ctx context.Context, r *model.AnchorRecord) error
// Get returns the AnchorRecord specified by bbc1dom and bbc1tx in O(1) time.
Get(ctx context.Context, bbc1dom, bbc1tx []byte) (*model.AnchorRecord, error)
// UpdateConfirmations updates Confirmations
// in the AnchorRecord specified by bbc1dom and bbc1tx.
UpdateConfirmations(ctx context.Context, bbc1dom, bbc1tx []byte, confirmations uint) error
// UpdateBBc1DomainName updates BBc1DomainName
// in the AnchorRecord specified by bbc1dom and bbc1tx.
UpdateBBc1DomainName(ctx context.Context, bbc1dom, bbc1tx []byte, bbc1domName string) error
// UpdateNote updates Note
// in the AnchorRecord specified by bbc1dom and bbc1tx.
UpdateNote(ctx context.Context, bbc1dom, bbc1tx []byte, note string) error
io.Closer
}
Store provides features to store anchor data in a datastore. Anchor data (especially the Bitcoin transaction IDs) should be stored, as finding an Anchor needs walking through all Bitcoin blockchains and is time consuming.