rccache

package
v0.0.0-...-d0e3281 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ACCBucket = "ACC"

ACCBucket is the bucket of UTXO

View Source
const FBBucket = "FBTxBlock"

FBBucket is the bucket of Final Blocks

View Source
const TBBucket = "TxBlock"

TBBucket is the bucket of ACC

View Source
const TXBucket = "TxBucket"

TXBucket is the txbucket

View Source
const UTXOBucket = "UTXO"

UTXOBucket is the bucket of UTXO

Variables

This section is empty.

Functions

func GenerateTx

func GenerateTx(x int, y int, z uint32, seed int64, k uint32) *basic.Transaction

GenerateTx is to generate a new tx

func SendingChan

func SendingChan(tmp *chan bool)

SendingChan is to send the signal on channel

Types

type CrossShardDec

type CrossShardDec struct {
	Data     *basic.Transaction
	Decision [gVar.ShardSize]byte
	InCheck  []int //-1: Output related
	//0: unknown, Not-related; 1: Yes; 2: No; 3: Related-noresult
	ShardRelated []uint32
	Res          int8 //0: unknown; 1: Yes; -1: No; -2: Can be deleted
	InCheckSum   int
	Total        int
	Value        uint32
	Visible      bool
}

CrossShardDec is the database of cache

func (*CrossShardDec) New

func (t *CrossShardDec) New(a *basic.Transaction)

New initiate the TxDB struct

func (*CrossShardDec) NewFromOther

func (t *CrossShardDec) NewFromOther(index uint32, res bool)

NewFromOther initiate the TxDB struct by cross-shard data

func (*CrossShardDec) Print

func (c *CrossShardDec) Print()

Print output the crossshard information

func (*CrossShardDec) Update

func (t *CrossShardDec) Update(a *basic.Transaction)

Update from the transaction

func (*CrossShardDec) UpdateFromOther

func (t *CrossShardDec) UpdateFromOther(index uint32, res bool)

UpdateFromOther initiate the TxDB struct by cross-shard data

type DbRef

type DbRef struct {
	//const value
	Mu           sync.RWMutex
	ID           uint32
	DB           TxBlockChain
	HistoryShard []uint32

	BandCnt uint32
	Badness bool

	TXCache       map[[32]byte]*CrossShardDec
	HashCache     map[[basic.SHash]byte][][32]byte
	WaitHashCache map[[basic.SHash]byte]WaitProcess

	ShardNum uint32

	//Leader
	TLSCacheMiner map[[32]byte]*basic.TxList
	TLIndex       map[[32]byte]*TLGroup
	Now           *TLGroup
	Ready         []basic.Transaction
	TxB           *basic.TxBlock
	FB            [gVar.ShardCnt]*basic.TxBlock

	TDSCnt      []int
	TDSNotReady int

	//Miner
	TLNow *basic.TxDecision

	TLRound    uint32
	PrevHeight uint32

	TBCache  *[][32]byte
	RepCache [gVar.NumTxListPerEpoch][gVar.ShardSize]int64

	Leader uint32
	//Statistic function
	TxCnt uint32
	// contains filtered or unexported fields
}

DbRef is the structure stores the cache of a miner for the database

func (*DbRef) AddCache

func (d *DbRef) AddCache(HashID [32]byte) error

AddCache is to handle the TxCache of hash

func (*DbRef) BuildTDS

func (d *DbRef) BuildTDS()

BuildTDS is to build all txDecSet Must after SignTXL

func (*DbRef) Clear

func (d *DbRef) Clear()

Clear refresh the data for next epoch

func (*DbRef) ClearCache

func (d *DbRef) ClearCache(HashID [32]byte) error

ClearCache is to handle the TxCache of hash

func (*DbRef) GenerateFinalBlock

func (d *DbRef) GenerateFinalBlock() error

GenerateFinalBlock generate final block

func (*DbRef) GenerateStartBlock

func (d *DbRef) GenerateStartBlock() error

GenerateStartBlock generate Start block

func (*DbRef) GenerateTxBlock

func (d *DbRef) GenerateTxBlock(good int) error

GenerateTxBlock makes the TxBlock

func (*DbRef) GetFinalTxBlock

func (d *DbRef) GetFinalTxBlock(a *basic.TxBlock) error

GetFinalTxBlock handle the txblock sent by the leader

func (*DbRef) GetStartTxBlock

func (d *DbRef) GetStartTxBlock(a *basic.TxBlock) error

GetStartTxBlock handle the txblock sent by the leader

func (*DbRef) GetTDS

func (d *DbRef) GetTDS(b *basic.TxDecSet, res *[gVar.ShardSize]int64) error

GetTDS and ready to verify txblock

func (*DbRef) GetTx

func (d *DbRef) GetTx(a *basic.Transaction) error

GetTx update the transaction

func (*DbRef) GetTxBlock

func (d *DbRef) GetTxBlock(a *basic.TxBlock) error

GetTxBlock handle the txblock sent by the leader

func (*DbRef) LockTx

func (d *DbRef) LockTx(a *basic.Transaction) error

LockTx locks all utxos related to transction a

func (*DbRef) MakeTXList

func (d *DbRef) MakeTXList(b *basic.Transaction) error

MakeTXList is to create TxList given transaction

func (*DbRef) New

func (d *DbRef) New(x uint32, prk ecdsa.PrivateKey)

New is the initilization of DbRef

func (*DbRef) NewTxList

func (d *DbRef) NewTxList() error

NewTxList initialize the txList Must after BuildTDS

func (*DbRef) PreTxBlock

func (d *DbRef) PreTxBlock(b *basic.TxBlock, s *PreStat) error

PreTxBlock is to process the TxListX

func (*DbRef) PreTxDecSet

func (d *DbRef) PreTxDecSet(b *basic.TxDecSet, s *PreStat) error

PreTxDecSet is to process the TxListX

func (*DbRef) PreTxDecision

func (d *DbRef) PreTxDecision(b *basic.TxDecision, hash [32]byte) error

PreTxDecision is verify the txdecision

func (*DbRef) PreTxList

func (d *DbRef) PreTxList(b *basic.TxList, s *PreStat) error

PreTxList is to process the TxListX

func (*DbRef) ProcessTDS

func (d *DbRef) ProcessTDS(b *basic.TxDecSet, res *[gVar.ShardSize]int64)

ProcessTDS deal with the TDS

func (*DbRef) ProcessTL

func (d *DbRef) ProcessTL(a *basic.TxList, tmpBatch *[]basic.TransactionBatch) error

ProcessTL verify the transactions in the txlist

func (*DbRef) Release

func (d *DbRef) Release(x *TLGroup)

Release delete the first element of the cache

func (*DbRef) SignTDS

func (d *DbRef) SignTDS(x *TLGroup)

SignTDS is to sign all txDecSet

func (*DbRef) UnlockTx

func (d *DbRef) UnlockTx(a *basic.Transaction) error

UnlockTx locks all utxos related to transction a

func (*DbRef) UpdateTXCache

func (d *DbRef) UpdateTXCache(a *basic.TxDecision, index *uint32) error

UpdateTXCache is to pick the transactions into ready slice given txdecision

func (*DbRef) VerifyTx

func (d *DbRef) VerifyTx(a *basic.Transaction) bool

VerifyTx verify the utxos related to transaction a

type PreStat

type PreStat struct {
	Stat    int
	Valid   []int
	Channel chan bool
}

PreStat is used in pre-defined request

type TLGroup

type TLGroup struct {
	TLS [gVar.ShardCnt]basic.TxList
	TDS [gVar.ShardCnt]basic.TxDecSet
}

TLGroup is the group of TL

type TxBlockChain

type TxBlockChain struct {
	LastTB  [32]byte
	Height  uint32
	LastFB  [gVar.ShardCnt][32]byte
	USet    map[[32]byte]UTXOSet
	TXCache map[[32]byte]int
	//AccData  *gtreap.Treap
	AccData  map[[32]byte]uint32
	FileName string
	// contains filtered or unexported fields
}

TxBlockChain is the blockchain database

func (*TxBlockChain) AddAccount

func (a *TxBlockChain) AddAccount(x *basic.AccCache) error

AddAccount is adding a new account or update

func (*TxBlockChain) AddBlock

func (a *TxBlockChain) AddBlock(x *basic.TxBlock) error

AddBlock is adding a new txblock

func (*TxBlockChain) AddFinalBlock

func (a *TxBlockChain) AddFinalBlock(x *basic.TxBlock) error

AddFinalBlock is adding a new txblock

func (*TxBlockChain) AddStartBlock

func (a *TxBlockChain) AddStartBlock(x *basic.TxBlock) error

AddStartBlock is adding a new txblock

func (*TxBlockChain) AddTx

func (a *TxBlockChain) AddTx(x *basic.Transaction) error

AddTx is adding a new transaction

func (*TxBlockChain) CheckUTXO

func (a *TxBlockChain) CheckUTXO(x *basic.InType, h [32]byte) bool

CheckUTXO is to check whether the utxo is available

func (*TxBlockChain) ClearTx

func (a *TxBlockChain) ClearTx() error

ClearTx request a transaction

func (*TxBlockChain) CreateNewBlockchain

func (a *TxBlockChain) CreateNewBlockchain(dbFile string) error

CreateNewBlockchain is to init the total chain

func (*TxBlockChain) LatestFinalTxBlock

func (a *TxBlockChain) LatestFinalTxBlock(x uint32) *basic.TxBlock

LatestFinalTxBlock return the highest txblock

func (*TxBlockChain) LatestTxBlock

func (a *TxBlockChain) LatestTxBlock() *basic.TxBlock

LatestTxBlock return the highest txblock

func (*TxBlockChain) LockUTXO

func (a *TxBlockChain) LockUTXO(x *basic.InType) error

LockUTXO is to lock the value

func (*TxBlockChain) MakeFinalTx

func (a *TxBlockChain) MakeFinalTx(shard uint32) *[]basic.Transaction

MakeFinalTx generates the final blocks transactions

func (*TxBlockChain) NewBlockchain

func (a *TxBlockChain) NewBlockchain(dbFile string) error

NewBlockchain is to init the total chain

func (*TxBlockChain) RecentBlock

func (a *TxBlockChain) RecentBlock(height uint32) *[]basic.TxBlock

RecentBlock is get the recent blocks data

func (*TxBlockChain) ReqTx

func (a *TxBlockChain) ReqTx(hash [32]byte) *basic.Transaction

ReqTx request a transaction

func (*TxBlockChain) ShowAccount

func (a *TxBlockChain) ShowAccount() error

ShowAccount prints all account information

func (*TxBlockChain) UnlockUTXO

func (a *TxBlockChain) UnlockUTXO(x *basic.InType) error

UnlockUTXO is to lock the value

func (*TxBlockChain) UpdateAccount

func (a *TxBlockChain) UpdateAccount() error

UpdateAccount save the current account data into database

func (*TxBlockChain) UpdateFinal

func (a *TxBlockChain) UpdateFinal(x *basic.TxBlock) error

UpdateFinal is to update the final block

func (*TxBlockChain) UpdateUTXO

func (a *TxBlockChain) UpdateUTXO(x *basic.TxBlock, shardindex uint32) error

UpdateUTXO is to update utxo set

func (*TxBlockChain) UploadAcc

func (a *TxBlockChain) UploadAcc(shardID uint32) error

UploadAcc is to upload the account data from database

type UTXOSet

type UTXOSet struct {
	Cnt    uint32
	Data   []basic.OutType
	Stat   []uint32
	Remain uint32
	// contains filtered or unexported fields
}

UTXOSet is the set of utxo in database

func (*UTXOSet) Decode

func (u *UTXOSet) Decode(tmp *[]byte) error

Decode is to deserial

func (*UTXOSet) Encode

func (u *UTXOSet) Encode() []byte

Encode is to serial

type WaitProcess

type WaitProcess struct {
	DataTB  []*basic.TxBlock
	StatTB  []*PreStat
	IDTB    []int
	DataTL  []*basic.TxList
	StatTL  []*PreStat
	IDTL    []int
	DataTDS []*basic.TxDecSet
	StatTDS []*PreStat
	IDTDS   []int
}

WaitProcess is the current wait process

Jump to

Keyboard shortcuts

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