Example #1
0
func GetDatabase() database.IFDatabase {

	var bucketList [][]byte
	var instances map[[fct.ADDRESS_LENGTH]byte]fct.IBlock
	var addinstance = func(b fct.IBlock) {
		key := new([32]byte)
		copy(key[:], b.GetDBHash().Bytes())
		instances[*key] = b
	}

	bucketList = make([][]byte, 5, 5)

	bucketList[0] = []byte("factoidAddress_balances")
	bucketList[0] = []byte("factoidOrphans_balances")
	bucketList[0] = []byte("factomAddress_balances")

	instances = make(map[[fct.ADDRESS_LENGTH]byte]fct.IBlock)

	addinstance(new(fct.Address))
	addinstance(new(fct.Hash))
	addinstance(new(fct.InAddress))
	addinstance(new(fct.OutAddress))
	addinstance(new(fct.OutECAddress))
	addinstance(new(fct.RCD_1))
	addinstance(new(fct.RCD_2))
	addinstance(new(fct.Signature))
	addinstance(new(fct.Transaction))
	addinstance(new(FSbalance))

	db := new(database.BoltDB)

	db.Init(bucketList, instances, "/tmp/fs_test.db")

	return db
}
Example #2
0
func GetDatabase(filename string) database.IFDatabase {

	var bucketList [][]byte
	var instances map[[fct.ADDRESS_LENGTH]byte]fct.IBlock

	bucketList = make([][]byte, 0, 5)

	bucketList = append(bucketList, []byte(fct.DB_FACTOID_BLOCKS))
	bucketList = append(bucketList, []byte(fct.DB_BAD_TRANS))
	bucketList = append(bucketList, []byte(fct.DB_F_BALANCES))
	bucketList = append(bucketList, []byte(fct.DB_EC_BALANCES))

	bucketList = append(bucketList, []byte(fct.DB_BUILD_TRANS))
	bucketList = append(bucketList, []byte(fct.DB_TRANSACTIONS))
	bucketList = append(bucketList, []byte(fct.W_RCD_ADDRESS_HASH))
	bucketList = append(bucketList, []byte(fct.W_ADDRESS_PUB_KEY))
	bucketList = append(bucketList, []byte(fct.W_NAME))
	bucketList = append(bucketList, []byte(fct.W_SEEDS))
	bucketList = append(bucketList, []byte(fct.W_SEED_HEADS))

	instances = make(map[[fct.ADDRESS_LENGTH]byte]fct.IBlock)

	var addinstance = func(b fct.IBlock) {
		key := new([32]byte)
		copy(key[:], b.GetDBHash().Bytes())
		instances[*key] = b
	}
	addinstance(new(database.ByteStore))
	addinstance(new(fct.Address))
	addinstance(new(fct.Hash))
	addinstance(new(fct.InAddress))
	addinstance(new(fct.OutAddress))
	addinstance(new(fct.OutECAddress))
	addinstance(new(fct.RCD_1))
	addinstance(new(fct.RCD_2))
	addinstance(new(fct.Signature))
	addinstance(new(fct.Transaction))
	addinstance(new(block.FBlock))
	addinstance(new(state.FSbalance))
	addinstance(new(wallet.WalletEntry))

	db := new(database.BoltDB)
	db.Init(bucketList, instances, filename)
	return db
}