ram

package
v0.0.0-...-c6effd4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyInitialized     = errors.New("memory account already initalized")
	ErrNoFreeMemory           = errors.New("no available free memory")
	ErrNotReserved            = errors.New("memory is not reserved")
	ErrAddressAlreadyReserved = errors.New("virtual account address already in memory")
)

Functions

func GetActualCapcity

func GetActualCapcity(record *Record) uint16

Types

type Record

type Record struct {
	Id uint64

	Vm string

	Address string

	Capacity   uint16
	NumSectors uint16
	NumPages   uint16
	PageSize   uint8

	StoredAccountType cvm.VirtualAccountType

	CreatedAt time.Time
}

func (*Record) Clone

func (r *Record) Clone() Record

func (*Record) CopyTo

func (r *Record) CopyTo(dst *Record)

func (*Record) Validate

func (r *Record) Validate() error

type Store

type Store interface {
	// Initializes a memory account for management
	InitializeMemory(ctx context.Context, record *Record) error

	// FreeMemoryByIndex frees a piece of memory from a memory account at a particual index
	FreeMemoryByIndex(ctx context.Context, memoryAccount string, index uint16) error

	// FreeMemoryByAddress frees a piece of memory assigned to the virtual account address
	FreeMemoryByAddress(ctx context.Context, address string) error

	// ReserveMemory reserves a piece of memory in a VM for the virtual account address
	ReserveMemory(ctx context.Context, vm string, accountType cvm.VirtualAccountType, address string) (string, uint16, error)
}

Store implements a basic construct for managing RAM memory. For simplicity, it is assumed that each memory account will store a single account type, which eliminates any complexities with parallel transaction execution resulting in allocation errors due to free pages across sectors.

Note: A lock outside this implementation is required to resolve any races.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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