Documentation
¶
Index ¶
- Constants
- Variables
- type DepositoryContract
- func (bc *DepositoryContract) BatchPutUntrustValue(ctx context.ContextInterface, batchVals string) (string, error)
- func (bc *DepositoryContract) BatchPutValue(ctx context.ContextInterface, msg context.Message, batchVals string) (string, error)
- func (bc *DepositoryContract) DisableACL(ctx context.ContextInterface) error
- func (bc *DepositoryContract) EnableACL(ctx context.ContextInterface) error
- func (bc *DepositoryContract) GetValueByIndex(ctx context.ContextInterface, index string) (string, error)
- func (bc *DepositoryContract) GetValueByKID(ctx context.ContextInterface, kid string) (string, error)
- func (bc *DepositoryContract) Initialize(ctx context.ContextInterface) error
- func (bc *DepositoryContract) PutUntrustValue(ctx context.ContextInterface, val string) (string, error)
- func (bc *DepositoryContract) PutValue(ctx context.ContextInterface, msg context.Message, val string) (string, error)
- func (bc *DepositoryContract) Total(ctx context.ContextInterface) (uint64, error)
- type EventBatchPutValue
- type EventPutValue
- type IDepository
Constants ¶
const ( IndexerKey = "depository~index" DepositoryKey = "depository~index~kid" DepositoryValKey = "depository~kid-val" EnableACLKey = "enable~acl" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type DepositoryContract ¶
type DepositoryContract struct {
contractapi.Contract
nonce.INonce
access.IAccessControl
}
DepositoryContract implements IDepository interface
func NewDepositoryContract ¶
func NewDepositoryContract(nonceContract nonce.INonce, aclContract access.IAccessControl) *DepositoryContract
NewDepositoryContract creates a new DepositoryContract instance with the given nonce and access control contracts.
func (*DepositoryContract) BatchPutUntrustValue ¶
func (bc *DepositoryContract) BatchPutUntrustValue(ctx context.ContextInterface, batchVals string) (string, error)
BatchPutUntrustValue puts multiple untrusted values into the DepositoryContract. It receives a comma-separated string of values and returns a comma-separated string of corresponding KIDs (keys). If the batchVals string is empty, it returns an error.
func (*DepositoryContract) BatchPutValue ¶
func (bc *DepositoryContract) BatchPutValue(ctx context.ContextInterface, msg context.Message, batchVals string) (string, error)
BatchPutValue puts multiple values into the DepositoryContract's state. It takes a batchVals string, which is a comma-separated list of values to be inserted. It returns a string representing the KIDs (Key IDs) of the inserted values and any error encountered.
func (*DepositoryContract) DisableACL ¶
func (bc *DepositoryContract) DisableACL(ctx context.ContextInterface) error
DisableACL disables the access control list
func (*DepositoryContract) EnableACL ¶
func (bc *DepositoryContract) EnableACL(ctx context.ContextInterface) error
EnableACL enables the access control list
func (*DepositoryContract) GetValueByIndex ¶
func (bc *DepositoryContract) GetValueByIndex(ctx context.ContextInterface, index string) (string, error)
GetValueByIndex retrieves the value at the index provided from the DepositoryContract. The index is expected to be a string representation of a byte slice that can be converted to a counter. If the value is found, it is returned as a string. If an error is encountered, it is returned with additional context.
func (*DepositoryContract) GetValueByKID ¶
func (bc *DepositoryContract) GetValueByKID(ctx context.ContextInterface, kid string) (string, error)
GetValueByKID returns the value associated with the given key ID. It first retrieves the value from the context using the getValByKID helper function. If the value is found, it is returned as a string. Otherwise, an error is returned.
func (*DepositoryContract) Initialize ¶
func (bc *DepositoryContract) Initialize(ctx context.ContextInterface) error
Initialize initializes the DepositoryContract and returns an error if there is one.
func (*DepositoryContract) PutUntrustValue ¶
func (bc *DepositoryContract) PutUntrustValue(ctx context.ContextInterface, val string) (string, error)
PutUntrustValue adds an untrusted value to the DepositoryContract. It takes a context and a string value to add, and returns the resulting KID (key ID) and an error (if any).
func (*DepositoryContract) PutValue ¶
func (bc *DepositoryContract) PutValue(ctx context.ContextInterface, msg context.Message, val string) (string, error)
PutValue adds a new value to the DepositoryContract and returns its KID. It checks ACL if enabled, increases the nonce, gets the current counter, puts the value into the ledger, increases the counter, and emits an event.
func (*DepositoryContract) Total ¶
func (bc *DepositoryContract) Total(ctx context.ContextInterface) (uint64, error)
Total returns the total count
type EventBatchPutValue ¶
type EventBatchPutValue struct {
Total uint64
Items []EventPutValue
}
type EventPutValue ¶
type IDepository ¶
type IDepository interface {
nonce.INonce
access.IAccessControl
// Initialize the contract
Initialize(ctx context.ContextInterface) error
// EnableACL enable acl in Depository
EnableACL(ctx context.ContextInterface) error
// DisableACL disable acl in Depository
DisableACL(ctx context.ContextInterface) error
// Total k/v paris stored
Total(ctx context.ContextInterface) (uint64, error)
// BatchPutValue stores key-value in a batch
BatchPutUntrustValue(ctx context.ContextInterface, batchVals string) (string, error)
// PutUntrustValue stores kval which do not have real owner's signature
PutUntrustValue(ctx context.ContextInterface, val string) (string, error)
// PutValue stores kval with pre-defined key calculation
PutValue(ctx context.ContextInterface, msg context.Message, val string) (string, error)
// GetValueByIndex get kval with index
GetValueByIndex(ctx context.ContextInterface, index string) (string, error)
// GetValueByKID get kval with key id
GetValueByKID(ctx context.ContextInterface, kid string) (string, error)
}
IDepository provides digital depository interfaces