github.com/koko1123/flow-go-1@v0.29.6/storage/ledger.go (about)

     1  package storage
     2  
     3  import (
     4  	"github.com/koko1123/flow-go-1/model/flow"
     5  	"github.com/koko1123/flow-go-1/module"
     6  )
     7  
     8  // Ledger takes care of storing registers (key, value pairs) providing proof of correctness
     9  // we aim to store a state of the order of 10^10 registers with up to 1M historic state versions
    10  type Ledger interface {
    11  	module.ReadyDoneAware
    12  	EmptyStateCommitment() flow.StateCommitment
    13  
    14  	// Trusted methods (without proof)
    15  	// Get registers at specific StateCommitment by a list of register ids
    16  	GetRegisters(registerIDs []flow.RegisterID, stateCommitment flow.StateCommitment) (values []flow.RegisterValue, err error)
    17  	// Batched atomic updates of a subset of registers at specific state
    18  	UpdateRegisters(registerIDs []flow.RegisterID, values []flow.RegisterValue, stateCommitment flow.StateCommitment) (newStateCommitment flow.StateCommitment, err error)
    19  
    20  	// Untrusted methods (providing proofs)
    21  	// Get registers at specific StateCommitment by a list of register ids with proofs
    22  	GetRegistersWithProof(registerIDs []flow.RegisterID, stateCommitment flow.StateCommitment) (values []flow.RegisterValue, proofs []flow.StorageProof, err error)
    23  	// Batched atomic updates of a subset of registers at specific state with proofs
    24  	UpdateRegistersWithProof(registerIDs []flow.RegisterID, values []flow.RegisterValue, stateCommitment flow.StateCommitment) (newStateCommitment flow.StateCommitment, proofs []flow.StorageProof, err error)
    25  }
    26  
    27  // LedgerVerifier should be designed as an standalone package to verify proofs of storage
    28  type LedgerVerifier interface {
    29  	// verify if a provided proof for getRegisters is accurate
    30  	VerifyRegistersProof(registerIDs []flow.RegisterID, stateCommitment flow.StateCommitment, values []flow.RegisterValue, proof []flow.StorageProof) (verified bool, err error)
    31  }