provenance

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Copyright IBM Corp. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Copyright IBM Corp. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	// SUBMITTED edge from userID to txID
	// denotes that the txID was submitted by the userID
	SUBMITTED = "s"
	// INCLUDES edge from blockNum to txID
	// denotes that the block includes the txID
	INCLUDES = "i"
	// WRITES edge from txID to value
	// denotes that the txID written the value
	WRITES = "w"
	// READS edge from txID to value
	// denotes that the txID read the value
	READS = "r"
	// DELETES edge from txID to the value
	// denotes that the txID deleted the value
	// including the key
	DELETES = "d"
	// NEXT edge from one value to another
	// denotes that the next version of the value
	NEXT = "n"
	// PREVIOUS edge from one to another
	// denotes that the previous version of the value
	PREVIOUS = "p"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	StoreDir string
	Disabled bool
	Logger   *logger.SugarLogger
}

Config holds the configuration parameter of the provenance store

type KeyWithVersion

type KeyWithVersion struct {
	Key     string
	Version *types.Version
}

KeyWithVersion holds a key and a version

type Store

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

Store holds information about the provenance store, i.e., a graph database

func Open

func Open(conf *Config) (*Store, error)

Open opens a provenance store to maintain historical values of each state.

If the provenance store is Config.Disabled is set, the disabled-flag file is created and nil is returned. If the disabled-flag file exists, the store cannot be re-enabled, and passing Config.Disabled=false results in an error.

func (*Store) Close

func (s *Store) Close() error

Close closes the database instance by closing all leveldb databases

func (*Store) Commit

func (s *Store) Commit(blockNum uint64, txsData []*TxDataForProvenance) error

Commit commits the txsData to a graph database. The following relationships are stored

  1. userID--(submitted)-->txID
  2. blockNum--(includes)->txID
  3. txID--(reads)-->value
  4. txID--(write)-->value
  5. txID--(delete)-->value
  6. key--(version)-->value
  7. value<--(previous)--value
  8. value--(next)-->value

func (*Store) GetDeletedValues

func (s *Store) GetDeletedValues(dbName, key string) ([]*types.ValueWithMetadata, error)

GetDeletedValues returns all deleted values associated with a given key present in the given database name

func (*Store) GetMostRecentValueAtOrBelow

func (s *Store) GetMostRecentValueAtOrBelow(dbName, key string, version *types.Version) (*types.ValueWithMetadata, error)

GetMostRecentValueAtOrBelow returns the most recent value hold by the given key at or below a given version

func (*Store) GetNextValues

func (s *Store) GetNextValues(dbName, key string, version *types.Version, limit int) ([]*types.ValueWithMetadata, error)

GetNextValues returns next values of a given key and a version. The number of records returned would be limited by the limit parameters.

func (*Store) GetPreviousValues

func (s *Store) GetPreviousValues(dbName, key string, version *types.Version, limit int) ([]*types.ValueWithMetadata, error)

GetPreviousValues returns previous values of a given key and a version. The number of records returned would be limited by the limit parameters.

func (*Store) GetReaders

func (s *Store) GetReaders(dbName, key string) (map[string]uint32, error)

GetReaders returns all userIDs who have accessed a given key as well as the access frequency

func (*Store) GetTxIDLocation

func (s *Store) GetTxIDLocation(txID string) (*TxIDLocation, error)

GetTxIDLocation returns the location, i.e, block number and the tx index, of a given txID

func (*Store) GetTxIDsSubmittedByUser

func (s *Store) GetTxIDsSubmittedByUser(userID string) ([]string, error)

GetTxIDsSubmittedByUser returns all ids of all transactions submitted by a given user

func (*Store) GetValueAt

func (s *Store) GetValueAt(dbName, key string, version *types.Version) (*types.ValueWithMetadata, error)

GetValueAt returns the value of a given key at a particular version

func (*Store) GetValues

func (s *Store) GetValues(dbName, key string) ([]*types.ValueWithMetadata, error)

GetValues returns all values associated with a given key

func (*Store) GetValuesDeletedByUser

func (s *Store) GetValuesDeletedByUser(userID string) (map[string]*types.KVsWithMetadata, error)

GetValuesDeletedByUser returns all values deleted by a given user

func (*Store) GetValuesReadByUser

func (s *Store) GetValuesReadByUser(userID string) (map[string]*types.KVsWithMetadata, error)

GetValuesReadByUser returns all values read by a given user

func (*Store) GetValuesWrittenByUser

func (s *Store) GetValuesWrittenByUser(userID string) (map[string]*types.KVsWithMetadata, error)

GetValuesWrittenByUser returns all values written by a given user

func (*Store) GetWriters

func (s *Store) GetWriters(dbName, key string) (map[string]uint32, error)

GetWriters returns all userIDs who have modified a given key as well as the modifcation frequency

type TxDataForProvenance

type TxDataForProvenance struct {
	IsValid            bool
	DBName             string
	UserID             string
	TxID               string
	Reads              []*KeyWithVersion
	Writes             []*types.KVWithMetadata
	Deletes            map[string]*types.Version
	OldVersionOfWrites map[string]*types.Version
}

TxDataForProvenance holds the transaction data that is needed for the provenance store

type TxIDLocation

type TxIDLocation struct {
	BlockNum uint64 `json:"block_num"`
	TxIndex  int    `json:"tx_index"`
}

TxIDLocation refers to the location of a TxID in the block

Jump to

Keyboard shortcuts

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