Пример #1
0
func createGenesisSignature(master wallet.WalletEntry) coin.Sig {
	c := visor.NewVisorConfig()
	bc := coin.NewBlockchain()
	gb := bc.CreateGenesisBlock(master.Address, c.GenesisTimestamp,
		c.GenesisCoinVolume)
	return coin.SignHash(gb.HashHeader(), master.Secret)
}
Пример #2
0
func NewVisorConfig() VisorConfig {
	return VisorConfig{
		Config:              visor.NewVisorConfig(),
		Disabled:            false,
		MasterKeysFile:      "",
		BlocksRequestRate:   time.Minute * 5,
		BlocksAnnounceRate:  time.Minute * 15,
		BlocksResponseCount: 20,
	}
}
Пример #3
0
func NewVisorConfig() VisorConfig {
	return VisorConfig{
		Config:               visor.NewVisorConfig(),
		Disabled:             false,
		BlocksRequestRate:    time.Second * 60, //backup, could be disabled
		BlocksAnnounceRate:   time.Second * 60, //backup, could be disabled
		BlocksResponseCount:  20,
		BlockchainBackupRate: time.Second * 30,
	}
}
Пример #4
0
// Creates a new blockchain with a single genesis block.
// Returns the visor and signed genesis block
func createGenesisVisor(masterKeys, bcFile,
	bsFile string) (*visor.Visor, visor.SignedBlock, error) {
	we := visor.MustLoadWalletEntry(masterKeys)
	c := visor.NewVisorConfig()
	c.MasterKeys = we
	c.IsMaster = true
	c.BlockSigsFile = bsFile
	c.BlockchainFile = bcFile
	c.CoinHourBurnFactor = 0
	v := visor.NewMinimalVisor(c)
	v.Wallet = visor.CreateMasterWallet(c.MasterKeys)
	return v, v.CreateGenesisBlock(), nil
}
Пример #5
0
// Returns an appropriate VisorConfig and a master visor
func setupVisor() (VisorConfig, *visor.Visor) {
	coin.SetAddressVersion("test")

	// Make a new master visor + blockchain
	// Get the signed genesis block,
	mw := visor.NewWalletEntry()
	mvc := visor.NewVisorConfig()
	mvc.IsMaster = true
	mvc.MasterKeys = mw
	mvc.CoinHourBurnFactor = 0
	mv := visor.NewVisor(mvc)
	sb := mv.GetGenesisBlock()

	// Use the master values for a client configuration
	c := NewVisorConfig()
	c.Config.IsMaster = false
	c.Config.MasterKeys = mw
	c.Config.MasterKeys.Secret = coin.SecKey{}
	c.Config.GenesisTimestamp = sb.Block.Head.Time
	c.Config.GenesisSignature = sb.Sig
	return c, mv
}
Пример #6
0
// Returns an appropriate VisorConfig and a master visor
func setupVisor() (VisorConfig, *visor.Visor) {
	coin.SetAddressVersion("test")

	// Make a new master visor + blockchain
	// Get the signed genesis block,
	mw := wallet.NewWalletEntry()
	mvc := visor.NewVisorConfig()
	mvc.IsMaster = true
	mvc.MasterKeys = mw
	mvc.CoinHourBurnFactor = 0
	mvc.GenesisSignature = createGenesisSignature(mw)
	mv := visor.NewVisor(mvc)

	// Use the master values for a client configuration
	c := NewVisorConfig()
	c.Config.WalletDirectory = testWalletDir
	c.Config.IsMaster = false
	c.Config.MasterKeys = mw
	c.Config.MasterKeys.Secret = coin.SecKey{}
	c.Config.GenesisSignature = mvc.GenesisSignature
	c.Config.GenesisTimestamp = mvc.GenesisTimestamp
	return c, mv
}