depositpool

package
v0.0.0-...-4f0ab6e Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: MIT Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewThreadedDepositPool

func NewThreadedDepositPool(blockChain iblockchain.BlockChain, storageMode StorageMode) idepositpool.DepositPool

NewThreadedDepositPool returns the thread-safe instance of depositpool.

Types

type DepositInfo

type DepositInfo struct {
	OutPoint    *wire.OutPoint
	Proof       *merkle.MerklePath
	BlockHeight wire.BlockHeight
	Locked      bool
}

DepositInfo represents the information that is used for vetifying the deposit tx.

type DepositPool

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

DepositPool is to store the information about the deposits and their owners.

func NewDepositPool

func NewDepositPool(blockChain iblockchain.BlockChain, isUsedDB bool) (*DepositPool, error)

NewDepositPool returns a depositpool need blockchain and isuseddb to init.

func (*DepositPool) Act

func (dPool *DepositPool) Act(e *message.Event, callback func(m interface{}))

Act is the implementation of actor pattern.

func (*DepositPool) Add

func (dPool *DepositPool) Add(out *wire.OutPoint, height wire.BlockHeight, proof *merkle.MerklePath) error

Add adds a deposit to the deposit pool. func (dPool *DepositPool) Add(d *DepositInfo) error {

func (*DepositPool) GetAll

func (dPool *DepositPool) GetAll(shardIndex shard.Index, address multivacaddress.Address) ([]*wire.OutWithProof, error)

GetAll returns all deposit proofs of the given address.

func (*DepositPool) GetBiggest

func (dPool *DepositPool) GetBiggest(address multivacaddress.Address) ([]byte, error)

GetBiggest return the biggest deposit of the given node hash. The return value is a byte array encoded by a DepositInfo pointer.

func (*DepositPool) Lock

func (dPool *DepositPool) Lock(o *wire.OutPoint) error

Lock locks the specific depoist and this deposit will not update anymore.

func (*DepositPool) Remove

func (dPool *DepositPool) Remove(o *wire.OutPoint) error

Remove removes the corresponding deposit from the pool.

func (*DepositPool) Update

func (dPool *DepositPool) Update(update *state.Update, shard shard.Index, height wire.BlockHeight) error

Update updates the outpoints in pool based on the given update instance.

func (*DepositPool) Verify

func (dPool *DepositPool) Verify(address multivacaddress.Address, d []byte) bool

Verify with given blockHeight and outpoint proof the param []byte is encoded by a DepositInfo pointer.

type StorageMode

type StorageMode bool

StorageMode is used to indicate whether is a storagenode

const (
	// MemoryMode -> use memory deposit pool
	MemoryMode StorageMode = false
	// DatabaseMode -> use db deposit pool
	DatabaseMode StorageMode = true
)

type ThreadedDepositPool

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

ThreadedDepositPool used to wrap DepositPool

func (*ThreadedDepositPool) Add

func (tdp *ThreadedDepositPool) Add(out *wire.OutPoint, height wire.BlockHeight, proof *merkle.MerklePath) error

Add adds a new proof of deposit in pool.

func (*ThreadedDepositPool) GetAll

func (tdp *ThreadedDepositPool) GetAll(shardIndex shard.Index, address multivacaddress.Address) ([]*wire.OutWithProof, error)

GetAll returns all deposits of the given address.

func (*ThreadedDepositPool) GetBiggest

func (tdp *ThreadedDepositPool) GetBiggest(address multivacaddress.Address) ([]byte, error)

GetBiggest returns a biggest proof.

func (*ThreadedDepositPool) Lock

func (tdp *ThreadedDepositPool) Lock(o *wire.OutPoint) error

Lock locks a proof, it means the deposit will not update anymore.

func (*ThreadedDepositPool) Remove

func (tdp *ThreadedDepositPool) Remove(o *wire.OutPoint) error

Remove removes a proof in pool.

func (*ThreadedDepositPool) Update

func (tdp *ThreadedDepositPool) Update(update *state.Update, shard shard.Index, height wire.BlockHeight) error

Update udaptes all proof's path in the pool.

func (*ThreadedDepositPool) Verify

func (tdp *ThreadedDepositPool) Verify(address multivacaddress.Address, d []byte) bool

Verify verifies the correction of the given proof.

Jump to

Keyboard shortcuts

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