chain

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: BSD-3-Clause Imports: 32 Imported by: 4

Documentation

Overview

Package chain is a generated GoMock package.

Index

Constants

View Source
const (
	Claim    = "claim"
	Lifeline = "lifeline"
	Set      = "set"
	Delete   = "delete"
	Move     = "move"
	Transfer = "transfer"

	// Non-user created event
	Reward = "reward"
)
View Source
const (
	LotteryRewardDivisor = 100
	MinBlockCost         = 0

	DefaultFreeClaimStorage  = 1 * units.MiB
	DefaultValueUnitSize     = 1 * units.KiB
	DefaultFreeClaimUnits    = DefaultFreeClaimStorage / DefaultValueUnitSize
	DefaultFreeClaimDuration = 60 * 60 * 24 * 30 // 30 Days

	DefaultLookbackWindow = 60
)
View Source
const (
	// 0x + hex-encoded hash
	HashLen = 66
)

Variables

View Source
var (
	// Genesis Correctness
	ErrInvalidMagic     = errors.New("invalid magic")
	ErrInvalidBlockRate = errors.New("invalid block rate")

	// Block Correctness
	ErrTimestampTooEarly      = errors.New("block timestamp too early")
	ErrTimestampTooLate       = errors.New("block timestamp too late")
	ErrNoTxs                  = errors.New("no transactions")
	ErrInvalidCost            = errors.New("invalid block cost")
	ErrInvalidPrice           = errors.New("invalid price")
	ErrInsufficientSurplus    = errors.New("insufficient surplus fee")
	ErrParentBlockNotVerified = errors.New("parent block not verified or accepted")

	// Tx Correctness
	ErrInvalidBlockID      = errors.New("invalid blockID")
	ErrInvalidSignature    = errors.New("invalid signature")
	ErrDuplicateTx         = errors.New("duplicate transaction")
	ErrInsufficientPrice   = errors.New("insufficient price")
	ErrInvalidType         = errors.New("invalid tx type")
	ErrTypedDataKeyMissing = errors.New("typed data key missing")

	// Execution Correctness
	ErrValueEmpty      = errors.New("value empty")
	ErrValueTooBig     = errors.New("value too big")
	ErrSpaceExpired    = errors.New("space expired")
	ErrKeyMissing      = errors.New("key missing")
	ErrInvalidKey      = errors.New("key is invalid")
	ErrAddressMismatch = errors.New("address does not match decoded space")
	ErrSpaceNotExpired = errors.New("space not expired")
	ErrSpaceMissing    = errors.New("space missing")
	ErrUnauthorized    = errors.New("sender is not authorized")
	ErrInvalidBalance  = errors.New("invalid balance")
	ErrNonActionable   = errors.New("transaction doesn't do anything")
	ErrBlockTooBig     = errors.New("block too big")
)
View Source
var (
	CompactRanges = []*CompactRange{

		{[]byte{infoPrefix, parser.ByteDelimiter}, []byte{keyPrefix, parser.ByteDelimiter}},
		{[]byte{keyPrefix, parser.ByteDelimiter}, []byte{expiryPrefix, parser.ByteDelimiter}},

		{[]byte{expiryPrefix, parser.ByteDelimiter}, []byte{balancePrefix, parser.ByteDelimiter}},
		{[]byte{balancePrefix, parser.ByteDelimiter}, []byte{ownedPrefix, parser.ByteDelimiter}},
		{[]byte{ownedPrefix, parser.ByteDelimiter}, []byte{ownedPrefix + 1, parser.ByteDelimiter}},
	}
)
View Source
var ErrInvalidKeyFormat = errors.New("invalid key format")

Functions

func ApplyReward

func ApplyReward(
	db database.Database, blkID ids.ID, txID ids.ID, sender common.Address, reward uint64,
) (common.Address, bool, error)

func BuildBlock

func BuildBlock(vm VM, preferred ids.ID) (snowman.Block, error)

func CompactablePrefixKey

func CompactablePrefixKey(pfx byte) []byte

func DeleteSpaceKey

func DeleteSpaceKey(db database.Database, space []byte, key []byte) error

func DeriveSender

func DeriveSender(dh []byte, sig []byte) (*ecdsa.PublicKey, error)

func DigestHash

func DigestHash(utx UnsignedTransaction) ([]byte, error)

func ExpireNext

func ExpireNext(db database.Database, rparent int64, rcurrent int64, bootstrapped bool) (err error)

ExpireNext queries "expiryPrefix" key space to find expiring keys, deletes their spaceInfos, and schedules its key pruning with its raw space.

func ExpiryDataValue

func ExpiryDataValue(address common.Address, space []byte) (v []byte)

func GetAllOwned

func GetAllOwned(db database.Database, owner common.Address) (spaces []string, err error)

func GetBalance

func GetBalance(db database.KeyValueReader, address common.Address) (uint64, error)

func GetLastAccepted

func GetLastAccepted(db database.KeyValueReader) (ids.ID, error)

func GetValue

func GetValue(db database.KeyValueReader, space []byte, key []byte) ([]byte, bool, error)

func HasLastAccepted

func HasLastAccepted(db database.Database) (bool, error)

func HasSpace

func HasSpace(db database.KeyValueReader, space []byte) (bool, error)

DB

func HasSpaceKey

func HasSpaceKey(db database.KeyValueReader, space []byte, key []byte) (bool, error)

func HasTransaction

func HasTransaction(db database.KeyValueReader, txID ids.ID) (bool, error)

func Marshal

func Marshal(source interface{}) ([]byte, error)

func ModifyBalance

func ModifyBalance(db database.KeyValueReaderWriter, address common.Address, add bool, change uint64) (uint64, error)

func MoveSpaceInfo

func MoveSpaceInfo(
	db database.KeyValueWriterDeleter, oldOwner common.Address,
	space []byte, i *SpaceInfo,
) error

MoveSpaceInfo should only be used if the expiry isn't changing and SpaceInfo is already in the database.

func PrefixBalanceKey

func PrefixBalanceKey(address common.Address) (k []byte)

[balancePrefix] + [delimiter] + [address]

func PrefixBlockKey

func PrefixBlockKey(blockID ids.ID) (k []byte)

[blockPrefix] + [delimiter] + [blockID]

func PrefixExpiryKey

func PrefixExpiryKey(expiry uint64, rspace ids.ShortID) (k []byte)

[expiryPrefix] + [delimiter] + [timestamp] + [delimiter] + [rawSpace]

func PrefixOwnedKey

func PrefixOwnedKey(address common.Address, space []byte) (k []byte)

[ownedPrefix] + [delimiter] + [address] + [delimiter] + [space]

func PrefixPruningKey

func PrefixPruningKey(expired uint64, rspace ids.ShortID) (k []byte)

[pruningPrefix] + [delimiter] + [timestamp] + [delimiter] + [rawSpace]

func PrefixTxKey

func PrefixTxKey(txID ids.ID) (k []byte)

[txPrefix] + [delimiter] + [txID]

func PrefixTxValueKey

func PrefixTxValueKey(txID ids.ID) (k []byte)

[txValuePrefix] + [delimiter] + [txID]

func PruneNext

func PruneNext(db database.Database, limit int) (removals int, err error)

PruneNext queries the keys that are currently marked with "pruningPrefix", and clears them from the database.

func PutSpaceInfo

func PutSpaceInfo(db database.KeyValueWriterDeleter, space []byte, i *SpaceInfo, lastExpiry uint64) error

func PutSpaceKey

func PutSpaceKey(db database.KeyValueReaderWriter, space []byte, key []byte, vmeta *ValueMeta) error

func RangeTimeKey

func RangeTimeKey(p byte, t uint64) (k []byte)

expiry/pruningPrefix + [delimiter] + [timestamp] + [delimiter]

func RawSpace

func RawSpace(space []byte, blockTime uint64) (ids.ShortID, error)

func SetBalance

func SetBalance(db database.KeyValueWriter, address common.Address, bal uint64) error

func SetLastAccepted

func SetLastAccepted(db database.KeyValueWriter, block *StatelessBlock) error

func SetTransaction

func SetTransaction(db database.KeyValueWriter, tx *Transaction) error

func Sign

func Sign(dh []byte, priv *ecdsa.PrivateKey) ([]byte, error)

func SpaceInfoKey

func SpaceInfoKey(space []byte) (k []byte)

[infoPrefix] + [delimiter] + [space]

func SpaceValueKey

func SpaceValueKey(rspace ids.ShortID, key []byte) (k []byte)

Assumes [space] and [key] do not contain delimiter [keyPrefix] + [delimiter] + [rawSpace] + [delimiter] + [key]

func Unmarshal

func Unmarshal(source []byte, destination interface{}) (uint16, error)

Types

type Activity

type Activity struct {
	Tmstmp int64  `serialize:"true" json:"timestamp"`
	TxID   ids.ID `serialize:"true" json:"txId"`
	Typ    string `serialize:"true" json:"type"`
	Sender string `serialize:"true" json:"sender,omitempty"` // empty when reward
	Space  string `serialize:"true" json:"space,omitempty"`
	Key    string `serialize:"true" json:"key,omitempty"`
	To     string `serialize:"true" json:"to,omitempty"` // common.Address will be 0x000 when not populated
	Units  uint64 `serialize:"true" json:"units,omitempty"`
}

type Airdrop

type Airdrop struct {
	// Address strings are hex-formatted common.Address
	Address common.Address `serialize:"true" json:"address"`
}

type BaseTx

type BaseTx struct {
	// BlkID is the ID of a block in the [lookbackWindow].
	BlockID ids.ID `serialize:"true" json:"blockId"`

	// Magic is a value defined in genesis to protect against replay attacks on
	// different VMs.
	Magic uint64 `serialize:"true" json:"magic"`

	// Price is the value per unit to spend on this transaction.
	Price uint64 `serialize:"true" json:"price"`
}

func (*BaseTx) Copy

func (b *BaseTx) Copy() *BaseTx

func (*BaseTx) ExecuteBase

func (b *BaseTx) ExecuteBase(g *Genesis) error

func (*BaseTx) FeeUnits

func (b *BaseTx) FeeUnits(g *Genesis) uint64

func (*BaseTx) GetBlockID

func (b *BaseTx) GetBlockID() ids.ID

func (*BaseTx) GetMagic

func (b *BaseTx) GetMagic() uint64

func (*BaseTx) GetPrice

func (b *BaseTx) GetPrice() uint64

func (*BaseTx) LoadUnits

func (b *BaseTx) LoadUnits(g *Genesis) uint64

func (*BaseTx) SetBlockID

func (b *BaseTx) SetBlockID(bid ids.ID)

func (*BaseTx) SetMagic

func (b *BaseTx) SetMagic(magic uint64)

func (*BaseTx) SetPrice

func (b *BaseTx) SetPrice(price uint64)

type ClaimTx

type ClaimTx struct {
	*BaseTx `serialize:"true" json:"baseTx"`

	// Space is the namespace for the "SpaceInfo"
	// whose owner can write and read value for the
	// specific key space.
	// The space must be ^[a-z0-9]{1,256}$.
	Space string `serialize:"true" json:"space"`
}

func (*ClaimTx) Activity

func (c *ClaimTx) Activity() *Activity

func (*ClaimTx) Copy

func (c *ClaimTx) Copy() UnsignedTransaction

func (*ClaimTx) Execute

func (c *ClaimTx) Execute(t *TransactionContext) error

func (*ClaimTx) FeeUnits

func (c *ClaimTx) FeeUnits(g *Genesis) uint64

func (*ClaimTx) LoadUnits

func (c *ClaimTx) LoadUnits(g *Genesis) uint64

func (*ClaimTx) TypedData

func (c *ClaimTx) TypedData() *tdata.TypedData

type CompactRange

type CompactRange struct {
	Start []byte
	Limit []byte
}

type Context

type Context struct {
	RecentBlockIDs  set.Set[ids.ID]
	RecentTxIDs     set.Set[ids.ID]
	RecentLoadUnits uint64

	Prices []uint64
	Costs  []uint64

	NextCost  uint64
	NextPrice uint64
}

type CustomAllocation

type CustomAllocation struct {
	// Address strings are hex-formatted common.Address
	Address common.Address `serialize:"true" json:"address"`
	Balance uint64         `serialize:"true" json:"balance"`
}

type DeleteTx

type DeleteTx struct {
	*BaseTx `serialize:"true" json:"baseTx"`

	// Space is the namespace for the "SpaceInfo"
	// whose owner can write and read value for the
	// specific key space.
	// The space must be ^[a-z0-9]{1,256}$.
	Space string `serialize:"true" json:"space"`

	// Key is parsed from the given input, with its space removed.
	Key string `serialize:"true" json:"key"`
}

func (*DeleteTx) Activity

func (d *DeleteTx) Activity() *Activity

func (*DeleteTx) Copy

func (d *DeleteTx) Copy() UnsignedTransaction

func (*DeleteTx) Execute

func (d *DeleteTx) Execute(t *TransactionContext) error

func (*DeleteTx) TypedData

func (d *DeleteTx) TypedData() *tdata.TypedData

type Genesis

type Genesis struct {
	Magic uint64 `serialize:"true" json:"magic"`

	// Tx params
	BaseTxUnits uint64 `serialize:"true" json:"baseTxUnits"`

	// SetTx params
	ValueUnitSize       uint64 `serialize:"true" json:"valueUnitSize"`
	MaxValueSize        uint64 `serialize:"true" json:"maxValueSize"`
	ValueExpiryDiscount uint64 `serialize:"true" json:"valueExpiryDiscount"`

	// Claim Params
	ClaimLoadMultiplier         uint64 `serialize:"true" json:"claimLoadMultiplier"`
	MinClaimFee                 uint64 `serialize:"true" json:"minClaimFee"`
	SpaceDesirabilityMultiplier uint64 `serialize:"true" json:"spaceDesirabilityMultiplier"`

	// Lifeline Params
	SpaceRenewalDiscount uint64 `serialize:"true" json:"spaceRenewalDiscount"`

	// Reward Params
	ClaimReward      uint64 `serialize:"true" json:"claimReward"`
	ClaimExpiryUnits uint64 `serialize:"true" json:"claimExpiryUnits"`

	// Mining Reward (% of min required fee)
	LotteryRewardMultipler uint64 `serialize:"true" json:"lotteryRewardMultipler"` // divided by 100

	// Fee Mechanism Params
	MinPrice         uint64 `serialize:"true" json:"minPrice"`
	LookbackWindow   int64  `serialize:"true" json:"lookbackWindow"`
	TargetBlockRate  int64  `serialize:"true" json:"targetBlockRate"` // seconds
	TargetBlockSize  uint64 `serialize:"true" json:"targetBlockSize"` // units
	MaxBlockSize     uint64 `serialize:"true" json:"maxBlockSize"`    // units
	BlockCostEnabled bool   `serialize:"true" json:"blockCostEnabled"`

	// Allocations
	CustomAllocation []*CustomAllocation `serialize:"true" json:"customAllocation"`
	AirdropHash      string              `serialize:"true" json:"airdropHash"`
	AirdropUnits     uint64              `serialize:"true" json:"airdropUnits"`
}

func DefaultGenesis

func DefaultGenesis() *Genesis

func (*Genesis) Load

func (g *Genesis) Load(db database.Database, airdropData []byte) error

func (*Genesis) StatefulBlock

func (g *Genesis) StatefulBlock() *StatefulBlock

func (*Genesis) Verify

func (g *Genesis) Verify() error

type Input

type Input struct {
	Typ   string         `json:"type"`
	Space string         `json:"space"`
	Key   string         `json:"key"`
	Value []byte         `json:"value"`
	To    common.Address `json:"to"`
	Units uint64         `json:"units"`
}

func (*Input) Decode

func (i *Input) Decode() (UnsignedTransaction, error)

type KeyValueMeta

type KeyValueMeta struct {
	Key       string     `serialize:"true" json:"key"`
	ValueMeta *ValueMeta `serialize:"true" json:"valueMeta"`
}

func GetAllValueMetas

func GetAllValueMetas(db database.Database, rspace ids.ShortID) (kvs []*KeyValueMeta, err error)

type LifelineTx

type LifelineTx struct {
	*BaseTx `serialize:"true" json:"baseTx"`

	// Space is the namespace for the "SpaceInfo"
	// whose owner can write and read value for the
	// specific key space.
	//
	// The space must be ^[a-z0-9]{1,256}$.
	Space string `serialize:"true" json:"space"`

	// Units is the number of [ClaimReward] to extend
	// the life of the [Space].
	Units uint64 `serialize:"true" json:"units"`
}

func (*LifelineTx) Activity

func (l *LifelineTx) Activity() *Activity

func (*LifelineTx) Copy

func (l *LifelineTx) Copy() UnsignedTransaction

func (*LifelineTx) Execute

func (l *LifelineTx) Execute(t *TransactionContext) error

func (*LifelineTx) FeeUnits

func (l *LifelineTx) FeeUnits(g *Genesis) uint64

func (*LifelineTx) LoadUnits

func (l *LifelineTx) LoadUnits(g *Genesis) uint64

func (*LifelineTx) TypedData

func (l *LifelineTx) TypedData() *tdata.TypedData

type Mempool

type Mempool interface {
	Len() int
	Prune(set.Set[ids.ID])
	PopMax() (*Transaction, uint64)
	Add(*Transaction) bool
	NewTxs(uint64) []*Transaction
}

type MockMempool

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

MockMempool is a mock of Mempool interface.

func NewMockMempool

func NewMockMempool(ctrl *gomock.Controller) *MockMempool

NewMockMempool creates a new mock instance.

func (*MockMempool) Add

func (m *MockMempool) Add(arg0 *Transaction) bool

Add mocks base method.

func (*MockMempool) EXPECT

func (m *MockMempool) EXPECT() *MockMempoolMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMempool) Len

func (m *MockMempool) Len() int

Len mocks base method.

func (*MockMempool) NewTxs

func (m *MockMempool) NewTxs(arg0 uint64) []*Transaction

NewTxs mocks base method.

func (*MockMempool) PopMax

func (m *MockMempool) PopMax() (*Transaction, uint64)

PopMax mocks base method.

func (*MockMempool) Prune

func (m *MockMempool) Prune(arg0 set.Set[ids.ID])

Prune mocks base method.

type MockMempoolMockRecorder

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

MockMempoolMockRecorder is the mock recorder for MockMempool.

func (*MockMempoolMockRecorder) Add

func (mr *MockMempoolMockRecorder) Add(arg0 interface{}) *gomock.Call

Add indicates an expected call of Add.

func (*MockMempoolMockRecorder) Len

func (mr *MockMempoolMockRecorder) Len() *gomock.Call

Len indicates an expected call of Len.

func (*MockMempoolMockRecorder) NewTxs

func (mr *MockMempoolMockRecorder) NewTxs(arg0 interface{}) *gomock.Call

NewTxs indicates an expected call of NewTxs.

func (*MockMempoolMockRecorder) PopMax

func (mr *MockMempoolMockRecorder) PopMax() *gomock.Call

PopMax indicates an expected call of PopMax.

func (*MockMempoolMockRecorder) Prune

func (mr *MockMempoolMockRecorder) Prune(arg0 interface{}) *gomock.Call

Prune indicates an expected call of Prune.

type MockUnsignedTransaction

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

MockUnsignedTransaction is a mock of UnsignedTransaction interface.

func NewMockUnsignedTransaction

func NewMockUnsignedTransaction(ctrl *gomock.Controller) *MockUnsignedTransaction

NewMockUnsignedTransaction creates a new mock instance.

func (*MockUnsignedTransaction) Activity

func (m *MockUnsignedTransaction) Activity() *Activity

Activity mocks base method.

func (*MockUnsignedTransaction) Copy

Copy mocks base method.

func (*MockUnsignedTransaction) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockUnsignedTransaction) Execute

Execute mocks base method.

func (*MockUnsignedTransaction) ExecuteBase

func (m *MockUnsignedTransaction) ExecuteBase(arg0 *Genesis) error

ExecuteBase mocks base method.

func (*MockUnsignedTransaction) FeeUnits

func (m *MockUnsignedTransaction) FeeUnits(arg0 *Genesis) uint64

FeeUnits mocks base method.

func (*MockUnsignedTransaction) GetBlockID

func (m *MockUnsignedTransaction) GetBlockID() ids.ID

GetBlockID mocks base method.

func (*MockUnsignedTransaction) GetMagic

func (m *MockUnsignedTransaction) GetMagic() uint64

GetMagic mocks base method.

func (*MockUnsignedTransaction) GetPrice

func (m *MockUnsignedTransaction) GetPrice() uint64

GetPrice mocks base method.

func (*MockUnsignedTransaction) LoadUnits

func (m *MockUnsignedTransaction) LoadUnits(arg0 *Genesis) uint64

LoadUnits mocks base method.

func (*MockUnsignedTransaction) SetBlockID

func (m *MockUnsignedTransaction) SetBlockID(arg0 ids.ID)

SetBlockID mocks base method.

func (*MockUnsignedTransaction) SetMagic

func (m *MockUnsignedTransaction) SetMagic(arg0 uint64)

SetMagic mocks base method.

func (*MockUnsignedTransaction) SetPrice

func (m *MockUnsignedTransaction) SetPrice(arg0 uint64)

SetPrice mocks base method.

func (*MockUnsignedTransaction) TypedData

func (m *MockUnsignedTransaction) TypedData() *tdata.TypedData

TypedData mocks base method.

type MockUnsignedTransactionMockRecorder

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

MockUnsignedTransactionMockRecorder is the mock recorder for MockUnsignedTransaction.

func (*MockUnsignedTransactionMockRecorder) Activity

Activity indicates an expected call of Activity.

func (*MockUnsignedTransactionMockRecorder) Copy

Copy indicates an expected call of Copy.

func (*MockUnsignedTransactionMockRecorder) Execute

func (mr *MockUnsignedTransactionMockRecorder) Execute(arg0 interface{}) *gomock.Call

Execute indicates an expected call of Execute.

func (*MockUnsignedTransactionMockRecorder) ExecuteBase

func (mr *MockUnsignedTransactionMockRecorder) ExecuteBase(arg0 interface{}) *gomock.Call

ExecuteBase indicates an expected call of ExecuteBase.

func (*MockUnsignedTransactionMockRecorder) FeeUnits

func (mr *MockUnsignedTransactionMockRecorder) FeeUnits(arg0 interface{}) *gomock.Call

FeeUnits indicates an expected call of FeeUnits.

func (*MockUnsignedTransactionMockRecorder) GetBlockID

GetBlockID indicates an expected call of GetBlockID.

func (*MockUnsignedTransactionMockRecorder) GetMagic

GetMagic indicates an expected call of GetMagic.

func (*MockUnsignedTransactionMockRecorder) GetPrice

GetPrice indicates an expected call of GetPrice.

func (*MockUnsignedTransactionMockRecorder) LoadUnits

func (mr *MockUnsignedTransactionMockRecorder) LoadUnits(arg0 interface{}) *gomock.Call

LoadUnits indicates an expected call of LoadUnits.

func (*MockUnsignedTransactionMockRecorder) SetBlockID

func (mr *MockUnsignedTransactionMockRecorder) SetBlockID(arg0 interface{}) *gomock.Call

SetBlockID indicates an expected call of SetBlockID.

func (*MockUnsignedTransactionMockRecorder) SetMagic

func (mr *MockUnsignedTransactionMockRecorder) SetMagic(arg0 interface{}) *gomock.Call

SetMagic indicates an expected call of SetMagic.

func (*MockUnsignedTransactionMockRecorder) SetPrice

func (mr *MockUnsignedTransactionMockRecorder) SetPrice(arg0 interface{}) *gomock.Call

SetPrice indicates an expected call of SetPrice.

func (*MockUnsignedTransactionMockRecorder) TypedData

TypedData indicates an expected call of TypedData.

type MockVM

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

MockVM is a mock of VM interface.

func NewMockVM

func NewMockVM(ctrl *gomock.Controller) *MockVM

NewMockVM creates a new mock instance.

func (*MockVM) Accepted

func (m *MockVM) Accepted(arg0 *StatelessBlock)

Accepted mocks base method.

func (*MockVM) EXPECT

func (m *MockVM) EXPECT() *MockVMMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockVM) ExecutionContext

func (m *MockVM) ExecutionContext(currentTime int64, parent *StatelessBlock) (*Context, error)

ExecutionContext mocks base method.

func (*MockVM) Genesis

func (m *MockVM) Genesis() *Genesis

Genesis mocks base method.

func (*MockVM) GetStatelessBlock

func (m *MockVM) GetStatelessBlock(arg0 ids.ID) (*StatelessBlock, error)

GetStatelessBlock mocks base method.

func (*MockVM) IsBootstrapped

func (m *MockVM) IsBootstrapped() bool

IsBootstrapped mocks base method.

func (*MockVM) Mempool

func (m *MockVM) Mempool() Mempool

Mempool mocks base method.

func (*MockVM) Rejected

func (m *MockVM) Rejected(arg0 *StatelessBlock)

Rejected mocks base method.

func (*MockVM) State

func (m *MockVM) State() database.Database

State mocks base method.

func (*MockVM) Verified

func (m *MockVM) Verified(arg0 *StatelessBlock)

Verified mocks base method.

type MockVMMockRecorder

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

MockVMMockRecorder is the mock recorder for MockVM.

func (*MockVMMockRecorder) Accepted

func (mr *MockVMMockRecorder) Accepted(arg0 interface{}) *gomock.Call

Accepted indicates an expected call of Accepted.

func (*MockVMMockRecorder) ExecutionContext

func (mr *MockVMMockRecorder) ExecutionContext(currentTime, parent interface{}) *gomock.Call

ExecutionContext indicates an expected call of ExecutionContext.

func (*MockVMMockRecorder) Genesis

func (mr *MockVMMockRecorder) Genesis() *gomock.Call

Genesis indicates an expected call of Genesis.

func (*MockVMMockRecorder) GetStatelessBlock

func (mr *MockVMMockRecorder) GetStatelessBlock(arg0 interface{}) *gomock.Call

GetStatelessBlock indicates an expected call of GetStatelessBlock.

func (*MockVMMockRecorder) IsBootstrapped

func (mr *MockVMMockRecorder) IsBootstrapped() *gomock.Call

IsBootstrapped indicates an expected call of IsBootstrapped.

func (*MockVMMockRecorder) Mempool

func (mr *MockVMMockRecorder) Mempool() *gomock.Call

Mempool indicates an expected call of Mempool.

func (*MockVMMockRecorder) Rejected

func (mr *MockVMMockRecorder) Rejected(arg0 interface{}) *gomock.Call

Rejected indicates an expected call of Rejected.

func (*MockVMMockRecorder) State

func (mr *MockVMMockRecorder) State() *gomock.Call

State indicates an expected call of State.

func (*MockVMMockRecorder) Verified

func (mr *MockVMMockRecorder) Verified(arg0 interface{}) *gomock.Call

Verified indicates an expected call of Verified.

type MoveTx

type MoveTx struct {
	*BaseTx `serialize:"true" json:"baseTx"`

	// Space is the namespace for the "SpaceInfo"
	// whose owner can write and read value for the
	// specific key space.
	// The space must be ^[a-z0-9]{1,256}$.
	Space string `serialize:"true" json:"space"`

	// To is the recipient of the Space.
	To common.Address `serialize:"true" json:"to"`
}

func (*MoveTx) Activity

func (m *MoveTx) Activity() *Activity

func (*MoveTx) Copy

func (m *MoveTx) Copy() UnsignedTransaction

func (*MoveTx) Execute

func (m *MoveTx) Execute(c *TransactionContext) error

func (*MoveTx) TypedData

func (m *MoveTx) TypedData() *tdata.TypedData

type SetTx

type SetTx struct {
	*BaseTx `serialize:"true" json:"baseTx"`

	// Space is the namespace for the "SpaceInfo"
	// whose owner can write and read value for the
	// specific key space.
	// The space must be ^[a-z0-9]{1,256}$.
	Space string `serialize:"true" json:"space"`

	// Key is parsed from the given input, with its space removed.
	Key string `serialize:"true" json:"key"`

	// Value is written as the key-value pair to the storage. If a previous value
	// exists, it is overwritten.
	Value []byte `serialize:"true" json:"value"`
}

func (*SetTx) Activity

func (s *SetTx) Activity() *Activity

func (*SetTx) Copy

func (s *SetTx) Copy() UnsignedTransaction

func (*SetTx) Execute

func (s *SetTx) Execute(t *TransactionContext) error

func (*SetTx) FeeUnits

func (s *SetTx) FeeUnits(g *Genesis) uint64

func (*SetTx) LoadUnits

func (s *SetTx) LoadUnits(g *Genesis) uint64

func (*SetTx) TypedData

func (s *SetTx) TypedData() *tdata.TypedData

type SpaceInfo

type SpaceInfo struct {
	Owner   common.Address `serialize:"true" json:"owner"`
	Created uint64         `serialize:"true" json:"created"`
	Updated uint64         `serialize:"true" json:"updated"`
	Expiry  uint64         `serialize:"true" json:"expiry"`
	Units   uint64         `serialize:"true" json:"units"` // decays faster the more units you have

	RawSpace ids.ShortID `serialize:"true" json:"rawSpace"`
}

func GetSpaceInfo

func GetSpaceInfo(db database.KeyValueReader, space []byte) (*SpaceInfo, bool, error)

type StatefulBlock

type StatefulBlock struct {
	Prnt   ids.ID         `serialize:"true" json:"parent"`
	Tmstmp int64          `serialize:"true" json:"timestamp"`
	Hght   uint64         `serialize:"true" json:"height"`
	Price  uint64         `serialize:"true" json:"price"`
	Cost   uint64         `serialize:"true" json:"cost"`
	Txs    []*Transaction `serialize:"true" json:"txs"`
}

func GetBlock

func GetBlock(db database.KeyValueReader, bid ids.ID) (*StatefulBlock, error)

func (*StatefulBlock) Dummy

func (b *StatefulBlock) Dummy() bool

type StatelessBlock

type StatelessBlock struct {
	*StatefulBlock `serialize:"true" json:"block"`

	Winners map[ids.ID]*Activity
	// contains filtered or unexported fields
}

Stateless is defined separately from "Block" in case external packages needs use the stateful block without mocking VM or parent block

func DummyBlock

func DummyBlock(tmstp int64, tx *Transaction) *StatelessBlock

DummyBlock is used for validating new txs and some tests

func NewBlock

func NewBlock(vm VM, parent snowman.Block, tmstp int64, context *Context) *StatelessBlock

func ParseBlock

func ParseBlock(
	source []byte,
	status choices.Status,
	vm VM,
) (*StatelessBlock, error)

func ParseStatefulBlock

func ParseStatefulBlock(
	blk *StatefulBlock,
	source []byte,
	status choices.Status,
	vm VM,
) (*StatelessBlock, error)

func (*StatelessBlock) Accept

func (b *StatelessBlock) Accept(ctx context.Context) error

implements "snowman.Block.choices.Decidable"

func (*StatelessBlock) Bytes

func (b *StatelessBlock) Bytes() []byte

implements "snowman.Block"

func (*StatelessBlock) Height

func (b *StatelessBlock) Height() uint64

implements "snowman.Block"

func (*StatelessBlock) ID

func (b *StatelessBlock) ID() ids.ID

implements "snowman.Block.choices.Decidable"

func (*StatelessBlock) Parent

func (b *StatelessBlock) Parent() ids.ID

implements "snowman.Block"

func (*StatelessBlock) Reject

func (b *StatelessBlock) Reject(ctx context.Context) error

implements "snowman.Block.choices.Decidable"

func (*StatelessBlock) SetChildrenDB

func (b *StatelessBlock) SetChildrenDB(db database.Database) error

func (*StatelessBlock) Status

func (b *StatelessBlock) Status() choices.Status

implements "snowman.Block.choices.Decidable"

func (*StatelessBlock) Timestamp

func (b *StatelessBlock) Timestamp() time.Time

implements "snowman.Block"

func (*StatelessBlock) Verify

func (b *StatelessBlock) Verify(ctx context.Context) error

implements "snowman.Block"

type Transaction

type Transaction struct {
	UnsignedTransaction `serialize:"true" json:"unsignedTransaction"`
	Signature           []byte `serialize:"true" json:"signature"`
	// contains filtered or unexported fields
}

func NewTx

func NewTx(utx UnsignedTransaction, sig []byte) *Transaction

func (*Transaction) Activity

func (t *Transaction) Activity() *Activity

func (*Transaction) Bytes

func (t *Transaction) Bytes() []byte

func (*Transaction) Copy

func (t *Transaction) Copy() *Transaction

func (*Transaction) DigestHash

func (t *Transaction) DigestHash() []byte

func (*Transaction) Execute

func (t *Transaction) Execute(g *Genesis, db database.Database, blk *StatelessBlock, context *Context) error

func (*Transaction) ID

func (t *Transaction) ID() ids.ID

func (*Transaction) Init

func (t *Transaction) Init(g *Genesis) error

func (*Transaction) Sender

func (t *Transaction) Sender() common.Address

func (*Transaction) Size

func (t *Transaction) Size() uint64

type TransactionContext

type TransactionContext struct {
	Genesis   *Genesis
	Database  database.Database
	BlockTime uint64
	TxID      ids.ID
	Sender    common.Address
}

type TransferTx

type TransferTx struct {
	*BaseTx `serialize:"true" json:"baseTx"`

	// To is the recipient of the [Units].
	To common.Address `serialize:"true" json:"to"`

	// Units are transferred to [To].
	Units uint64 `serialize:"true" json:"units"`
}

func (*TransferTx) Activity

func (t *TransferTx) Activity() *Activity

func (*TransferTx) Copy

func (t *TransferTx) Copy() UnsignedTransaction

func (*TransferTx) Execute

func (t *TransferTx) Execute(c *TransactionContext) error

func (*TransferTx) TypedData

func (t *TransferTx) TypedData() *tdata.TypedData

type UnsignedTransaction

type UnsignedTransaction interface {
	Copy() UnsignedTransaction
	GetBlockID() ids.ID
	GetMagic() uint64
	GetPrice() uint64
	SetBlockID(ids.ID)
	SetMagic(uint64)
	SetPrice(uint64)
	FeeUnits(*Genesis) uint64  // number of units to mine tx
	LoadUnits(*Genesis) uint64 // units that should impact fee rate

	ExecuteBase(*Genesis) error
	Execute(*TransactionContext) error
	TypedData() *tdata.TypedData
	Activity() *Activity
}

func ParseTypedData

func ParseTypedData(td *tdata.TypedData) (UnsignedTransaction, error)

type VM

type VM interface {
	Genesis() *Genesis
	IsBootstrapped() bool
	State() database.Database
	Mempool() Mempool
	GetStatelessBlock(ids.ID) (*StatelessBlock, error)
	ExecutionContext(currentTime int64, parent *StatelessBlock) (*Context, error)
	Verified(*StatelessBlock)
	Rejected(*StatelessBlock)
	Accepted(*StatelessBlock)
}

type ValueMeta

type ValueMeta struct {
	Size uint64 `serialize:"true" json:"size"`
	TxID ids.ID `serialize:"true" json:"txId"`

	Created uint64 `serialize:"true" json:"created"`
	Updated uint64 `serialize:"true" json:"updated"`
}

func GetValueMeta

func GetValueMeta(db database.KeyValueReader, space []byte, key []byte) (*ValueMeta, bool, error)

Jump to

Keyboard shortcuts

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