mainchain

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GENESIS_BLOCK_REWARD uint64 = 50000000000000 // 50 000 000 globals * 1 000 000
	BLOCK_TIME           uint32 = 600            //in seconds// ten minutes

	DIFFICULTY_TUNING_INTERVAL   uint32 = 2016   //about two weeks
	BLOCK_REWARD_TUNING_INTERVAL uint32 = 210000 //blocks
	//BLOCK_CONFIRMATION_INTERVAL uint32=100//6//blocks
	ENGAGEMENT_REWARD_FINALIZATION_INTERVAL uint32 = 144         //24*6//about one day
	BLOCK_MAX_SEIZE                         uint32 = 1024 * 1024 //1 MO
	BLOCKTRANSACTIONS_MAX_SEIZE             uint32 = BLOCK_MAX_SEIZE - 200
	OBSTRUCTED_MINING_TIME                  int64  = 60 * 600 //10 hours

)
View Source
const (
	StateKeyIdentifierTxOutput         = 1
	StateKeyIdentifierTx               = 3
	StateKeyIdentifierNameRegistration = 4
	StateKeyIdentifierMainblock        = 6
)
View Source
const (
	StateValueIdentifierNotFound                = 0
	StateValueIdentifierUnspentTxOutput         = 1
	StateValueIdentifierSpentTxOutput           = 2
	StateValueIdentifierTx                      = 3
	StateValueIdentifierActifNameRegistration   = 4
	StateValueIdentifierInactifNameRegistration = 5
	StateValueIdentifierValidMainblock          = 6
	StateValueIdentifierUnvalidMainblock        = 7
)

Variables

This section is empty.

Functions

func CheckMainblockTransactions

func CheckMainblockTransactions(pointertxs *[]utility.Transaction, root utility.Hash) bool

func CheckNameBytes

func CheckNameBytes(name []byte) bool

func GetMainblockReward

func GetMainblockReward(i uint32) uint64

Types

type Mainblock

type Mainblock struct {
	//
	Height       uint32
	Header       Mainheader
	Transactions []utility.Transaction
}

func GenesisBlock

func GenesisBlock() *Mainblock

func NewMainblock

func NewMainblock() *Mainblock

func UnserializeMainblock

func UnserializeMainblock(bytes []byte) (*Mainblock, error)

func (*Mainblock) CheckHash

func (mb *Mainblock) CheckHash() bool

func (*Mainblock) ComputeHash

func (mb *Mainblock) ComputeHash()

func (*Mainblock) ComputeRoot

func (mb *Mainblock) ComputeRoot()

func (*Mainblock) Mine

func (mb *Mainblock) Mine(prevtime int64, prevblockhash utility.Hash, bits uint32) bool

func (*Mainblock) Serialize

func (mb *Mainblock) Serialize() []byte

type Maincore

type Maincore struct {
	MissingDataHashArray     []utility.Hash
	MissingDataFileHashArray []utility.Hash
	// contains filtered or unexported fields
}

func NewMaincore

func NewMaincore() *Maincore

func (*Maincore) AddBlockChunck

func (mn *Maincore) AddBlockChunck(bytes []byte)

func (*Maincore) AddInMemoryBlock

func (mn *Maincore) AddInMemoryBlock(mb *Mainblock)

func (*Maincore) AddTransactionToTxsPool

func (mn *Maincore) AddTransactionToTxsPool(tx *utility.Transaction, fee uint64, priority uint64)

func (*Maincore) AutoCheckMainblocks

func (mn *Maincore) AutoCheckMainblocks() bool

func (*Maincore) AutoCheckMainheaders

func (mn *Maincore) AutoCheckMainheaders() bool

func (*Maincore) CheckHeaderChain

func (mn *Maincore) CheckHeaderChain(pointerheaders *[]Mainheader) bool

func (*Maincore) CheckPropagatingMainheader

func (mn *Maincore) CheckPropagatingMainheader(header *Mainheader, height uint32) bool

func (*Maincore) CleanMainblocks

func (mn *Maincore) CleanMainblocks()

func (*Maincore) CleanMainstate

func (mn *Maincore) CleanMainstate()

func (*Maincore) ConfirmBlocks

func (mn *Maincore) ConfirmBlocks()

func (*Maincore) ConfirmMainblock

func (mn *Maincore) ConfirmMainblock(mb *Mainblock)

func (*Maincore) GetConfirmationLayer

func (mn *Maincore) GetConfirmationLayer() uint32

func (*Maincore) GetConfirmedMainblock

func (mn *Maincore) GetConfirmedMainblock(i int) *Mainblock

func (*Maincore) GetConfirmedMainchainLength

func (mn *Maincore) GetConfirmedMainchainLength() uint32

func (*Maincore) GetLastConfirmedMainblockTimestamp

func (mn *Maincore) GetLastConfirmedMainblockTimestamp() int64

func (*Maincore) GetLastMainheader

func (mn *Maincore) GetLastMainheader() *Mainheader

func (*Maincore) GetMainblock

func (mn *Maincore) GetMainblock(i int) *Mainblock

func (*Maincore) GetMainblockState

func (mn *Maincore) GetMainblockState(height uint32) uint32

func (*Maincore) GetMainchainLength

func (mn *Maincore) GetMainchainLength() uint32

func (*Maincore) GetMainheader

func (mn *Maincore) GetMainheader(i int) *Mainheader

func (*Maincore) GetNameState

func (mn *Maincore) GetNameState(name []byte) uint32

func (*Maincore) GetPath

func (mn *Maincore) GetPath() string

func (*Maincore) GetSerializedMainblockTransactions

func (mn *Maincore) GetSerializedMainblockTransactions(requestedblockheight uint32) []byte

func (*Maincore) GetSerializedMainchainLength

func (mn *Maincore) GetSerializedMainchainLength() []byte

func (*Maincore) GetSerializedMainheaders

func (mn *Maincore) GetSerializedMainheaders(first uint32, last uint32) []byte

func (*Maincore) GetTargetBits

func (mn *Maincore) GetTargetBits() uint32

func (*Maincore) GetTxOutputState

func (mn *Maincore) GetTxOutputState(txhash utility.Hash, index uint32) uint32

func (*Maincore) GetTxState

func (mn *Maincore) GetTxState(txhash utility.Hash) (uint32, uint32, uint32)

func (*Maincore) LoadMaincore

func (mn *Maincore) LoadMaincore()

func (*Maincore) LoadUnconfirmedBroadcastedTxs

func (mn *Maincore) LoadUnconfirmedBroadcastedTxs(wlt *wallet.Wallet)

func (*Maincore) Lock

func (mn *Maincore) Lock()

func (*Maincore) Mine

func (mn *Maincore) Mine(miningaddress utility.Hash) (bool, *Mainblock)

//////////////////////////////////////////////////////////////////

func (*Maincore) PutMainblockState

func (mn *Maincore) PutMainblockState(height uint32, state uint32) error

func (*Maincore) PutNameState

func (mn *Maincore) PutNameState(name []byte, stateidentifier uint32) error

func (*Maincore) PutPath

func (mn *Maincore) PutPath(path string)

func (*Maincore) PutTxOutputState

func (mn *Maincore) PutTxOutputState(txhash utility.Hash, index uint32, stateidentifier uint32) error

func (*Maincore) PutTxState

func (mn *Maincore) PutTxState(txhash utility.Hash, height uint32, number uint32) error

func (*Maincore) RebuildMainstate

func (mn *Maincore) RebuildMainstate()

func (*Maincore) SyncWallet

func (mn *Maincore) SyncWallet(wlt *wallet.Wallet)

func (*Maincore) UnloadMaincore

func (mn *Maincore) UnloadMaincore()

func (*Maincore) Unlock

func (mn *Maincore) Unlock()

func (*Maincore) UnserializeMainblockTransactions

func (mn *Maincore) UnserializeMainblockTransactions(bytes []byte) (*[]utility.Transaction, error)

func (*Maincore) UnserializeMainheaders

func (mn *Maincore) UnserializeMainheaders(bytes []byte) (*[]Mainheader, error)

func (*Maincore) UpdateMainstate

func (mn *Maincore) UpdateMainstate(tx utility.Transaction, blockheight uint32)

func (*Maincore) ValidateMainblockTransactions

func (mn *Maincore) ValidateMainblockTransactions(height uint32, pointertxs *[]utility.Transaction) bool

func (*Maincore) ValidateNameRegistration

func (mn *Maincore) ValidateNameRegistration(name []byte) error

func (*Maincore) ValidatePropagatingMainblock

func (mn *Maincore) ValidatePropagatingMainblock(mb *Mainblock) bool

func (*Maincore) ValidateTransaction

func (mn *Maincore) ValidateTransaction(tx *utility.Transaction) (bool, uint64)

func (*Maincore) ValidateTxIn

func (mn *Maincore) ValidateTxIn(signinghash utility.Hash, tmptxin utility.TxIn) (uint64, error)

func (*Maincore) ValidateTxOut

func (mn *Maincore) ValidateTxOut(tmptxout utility.TxOut) (uint64, error)

type Mainheader

type Mainheader struct {
	//
	Version       int32
	Prevblockhash utility.Hash
	Roothash      utility.Hash //
	Timestamp     int64
	Bits          uint32
	Nonce         uint32
	Hash          utility.Hash
}

func JSONUnserializeMainheader

func JSONUnserializeMainheader(bytes []byte) (*Mainheader, error)

func UnserializeMainheader

func UnserializeMainheader(bytes []byte) (*Mainheader, error)

func (*Mainheader) JSONSerialize

func (mh *Mainheader) JSONSerialize() []byte

func (*Mainheader) Serialize

func (mh *Mainheader) Serialize() []byte

type TxsPool

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

func NewTxsPool

func NewTxsPool() *TxsPool

func (*TxsPool) AddTransaction

func (txsp *TxsPool) AddTransaction(tx *utility.Transaction, txfee uint64, priority uint64)

func (*TxsPool) DeleteTransaction

func (txsp *TxsPool) DeleteTransaction(txhash *utility.Hash)

func (*TxsPool) DisplayTxs

func (txsp *TxsPool) DisplayTxs()

func (*TxsPool) GetHighestPriorityTxs

func (txsp *TxsPool) GetHighestPriorityTxs(mainchainlength uint32) (*[]utility.Transaction, uint64)

func (*TxsPool) GetTransaction

func (txsp *TxsPool) GetTransaction(txhash *utility.Hash) (utility.Transaction, bool)

func (*TxsPool) GetTransactionPriority

func (txsp *TxsPool) GetTransactionPriority(txhash *utility.Hash) uint64

func (*TxsPool) SetTxInclusionHeight

func (txsp *TxsPool) SetTxInclusionHeight(txhash *utility.Hash, inclusionheight uint32)

Jump to

Keyboard shortcuts

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