genesis

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: 13 Imported by: 0

README

To update shard lists, run script.py. Usage:

python script.py <prefix_length>

e.g.
python script.py 7

It will generate 2<<7 = 128 shards.

This script also generates private keys and public keys for each shard. So
the more shards, the longer it will take.

Maximum prefix length is 32.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GenesisBlocks map[shard.Index]*wire.MsgBlock

GenesisBlocks contains all shards' genesis blocks In each genesis blocks, there is NumberOfOutsInEachGenesisBlock outs. However they have none transaction. Outs are directly added into merkle trees, and the roots of the merkle trees are added into genesis blocks. GenesisBlockOutsMerkleTrees are the merkle trees that contains outs in genesis blocks. When building ledger merkle tree, don't directly use outs merkle tree. Outs merkle trees are second layer tree. Create a merkle tree with the OutsMerkleRoot in blockheader, then hook a outs merkle tree. For example:

block := GenesisBlocks[shard]
tree := merkle.NewFullMerkleTree(&block.Header.OutsMerkleRoot)
outsMerkleTree := GenesisBlocksOutsMerkleTrees[shard]
tree.HookSecondLayerTree(outsMerkleTree)
View Source
var GenesisBlocksOutsMerkleTrees map[shard.Index]*merkle.FullMerkleTree

GenesisBlocksOutsMerkleTrees contains all shards' out merkle tree

View Source
var GenesisPrivateKeys = privateKeys()

GenesisPrivateKeys returns the privateKeys()'s return.

View Source
var GenesisPublicKeys = publicKeys()

GenesisPublicKeys contains all genesis public keys

View Source
var NumberOfOutsInEachGenesisBlock = 1000

NumberOfOutsInEachGenesisBlock indicats how many outs are there in each genesis block.

View Source
var TestNetToolsPrvs = []string{} /* 300 elements not displayed */

TestNetToolsPrvs is private key array for testnet.

View Source
var TestNetToolsPubs = []string{} /* 300 elements not displayed */

TestNetToolsPubs is public key array for testnet.

View Source
var TotalAmountOfEachShard *big.Int

TotalAmountOfEachShard represents number of crypto coins are there in each genesis block.

Functions

func ConvertByteToPkHash

func ConvertByteToPkHash(pk []byte) chainhash.Hash

ConvertByteToPkHash coverts pk bytes to chainhash.Hash

func ConvertStringToPkHash

func ConvertStringToPkHash(pkString string) (chainhash.Hash, error)

ConvertStringToPkHash coverts pk string to chainhash.Hash

func CreateGenesisOutState

func CreateGenesisOutState(shard shard.Index, index int, txHash *chainhash.Hash) *wire.OutState

CreateGenesisOutState makes it easier to create an out state corresponding to a outpoint in genesis block.

func GenerateGenesisTx

func GenerateGenesisTx(shard shard.Index) *wire.MsgTx

GenerateGenesisTx returns a empty tx with the given shard.

Types

type Pool

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

Pool is the pk pool for the first batch of miners. All of the pks in pool will store in all miners' genesis block.

Notion: Pool should be used by a scheduler, the scheduler should ensure that each miner gets a different pk.

func NewPool

func NewPool() *Pool

NewPool returns a new instance of Pool, it will read config file from the given path. TODO: should not hard coee.

func (*Pool) GetSkFromAddress

func (pool *Pool) GetSkFromAddress(address multivacaddress.Address) ([]byte, error)

GetSkFromAddress returns the pk of the given address

func (*Pool) IsEmpty

func (pool *Pool) IsEmpty() bool

IsEmpty retunrs if has pks to provide.

func (*Pool) Pks

func (pool *Pool) Pks() []string

Pks returns all publicKeys from the pool.

func (*Pool) Pop

func (pool *Pool) Pop() (string, string, error)

Pop returns a new pk from the pool.

func (*Pool) Reset

func (pool *Pool) Reset()

Reset set the cur pointer to the initial position.

Jump to

Keyboard shortcuts

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