miner

package
v0.0.0-...-c6cf726 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2020 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	//How many blocks can we verify dynamically (e.g. proper time check) until we are too far behind
	//that this dynamic check is not possible anymore?!
	DELAYED_BLOCKS = 10

	TXFETCH_TIMEOUT    = 2  //Sec
	BLOCKFETCH_TIMEOUT = 40 //Sec

	//Some prominent programming languages (e.g., Java) have not unsigned integer types
	//Neglecting MSB simplifies compatibility
	MAX_MONEY = 9223372036854775807 //(2^63)-1

	//Default Block params
	BLOCKHASH_SIZE       = 32   //Byte
	FEE_MINIMUM          = 1    //Coins
	BLOCK_SIZE           = 5000 //Byte
	DIFF_INTERVAL        = 25   //Blocks
	BLOCK_INTERVAL       = 15   //Sec
	BLOCK_REWARD         = 0    //Coins
	STAKING_MINIMUM      = 1000 //Coins
	WAITING_MINIMUM      = 0    //Blocks
	ACCEPTED_TIME_DIFF   = 60   //Sec
	SLASHING_WINDOW_SIZE = 100  //Blocks
	SLASH_REWARD         = 2    //Coins
	NUM_INCL_PREV_PROOFS = 5    //Number of previous proofs included in the PoS condition
	NO_EMPTYING_LENGTH   = 100  //Number of blocks after the newest block which are not moved to the empty block bucket
	FIXED_SPACE          = 650
	BLOOM_FILTER_SIZE    = 8
)

Variables

View Source
var SameChainMutex = sync.Mutex{}

Functions

func AggregateTransactions

func AggregateTransactions(SortedAndSelectedFundsTx []protocol.Transaction, block *protocol.Block) error

func CheckAndChangeParameters

func CheckAndChangeParameters(parameters *Parameters, configTxSlice *[]*protocol.ConfigTx) (change bool)

Separate function to reuse mechanism in client implementation

func GetLatestProofs

func GetLatestProofs(n int, block *protocol.Block) (prevProofs [][crypto.COMM_PROOF_LENGTH]byte)

func Init

func Init(
	validatorWallet *ecdsa.PublicKey,
	multisigWallet,
	rootWallet *ecdsa.PublicKey,
	validatorCommitment,
	rootCommitment *rsa.PrivateKey,
	rootChamHashParams *crypto.ChameleonHashParameters,
)

Miner entry point

func InvertBlockArray

func InvertBlockArray(array []*protocol.Block) []*protocol.Block

func IsInSameChain

func IsInSameChain(b1, b2 *protocol.Block) bool

Check if two blocks are part of the same chain or if they appear in two competing chains

func IsSigned

func IsSigned(hash [32]byte, signature [64]byte, address [64]byte) bool

Checks if the hash is signed by the provided signature and address

func OrderedBy

func OrderedBy(less ...lessFunc) *multiSorter

Types

type ByHash

type ByHash [][32]byte

func (ByHash) Len

func (a ByHash) Len() int

func (ByHash) Less

func (a ByHash) Less(i, j int) bool

func (ByHash) Swap

func (a ByHash) Swap(i, j int)

type ByTxCount

type ByTxCount []*protocol.FundsTx

func (ByTxCount) Len

func (a ByTxCount) Len() int

func (ByTxCount) Less

func (a ByTxCount) Less(i, j int) bool

func (ByTxCount) Swap

func (a ByTxCount) Swap(i, j int)

type Parameters

type Parameters struct {
	BlockHash          [BLOCKHASH_SIZE]byte
	FeeMinimum         uint64 //Paid minimum fee for sending a tx.
	BlockSize          uint64 //Block size in bytes.
	DiffInterval       uint64
	BlockInterval      uint64
	BlockReward        uint64 //Reward for delivering the correct PoS.
	StakingMinimum     uint64 //Minimum amount a validator must own for staking.
	WaitingMinimum     uint64 //Number of blocks that must a new validator must wait before it can start validating.
	AcceptedTimeDiff   uint64 //Number of seconds that a block can be received in the future.
	SlashingWindowSize uint64 //Number of blocks that a validator cannot vote on two competing chains.
	SlashReward        uint64 //Reward for providing the correct slashing proof.

	FixedSpace      int
	BloomFilterSize int
	// contains filtered or unexported fields
}

An instance of this datastructure is created whenever system parameters change. The blockhash is additionally recorded to know which blocks the parameter change belongs to. This is necessary, because the system records ALL config txs (even those who have no corresponding code to execute [e.g., when they're running an older version of the code]).

func NewDefaultParameters

func NewDefaultParameters() Parameters

func (Parameters) String

func (param Parameters) String() string

type SlashingProof

type SlashingProof struct {
	ConflictingBlockHash1          [32]byte
	ConflictingBlockHash2          [32]byte
	ConflictingBlockHashWithoutTx1 [32]byte
	ConflictingBlockHashWithoutTx2 [32]byte
}

Jump to

Keyboard shortcuts

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