예제 #1
0
func prepareBAT() transaction.T {
	key, err := env.DB.GetMainKey()
	if err != nil {
		log.Printf("Error while attempting to retrieve main key: %v", err)
	}
	if key != nil {
		bat, err := transaction.NewBlockAttribution(key)
		if err != nil {
			log.Printf("Error while creating a BAT: %v", err)
		} else {
			return bat
		}
	}
	return nil

}
예제 #2
0
func prepareBAT(srv *context.T, log log15.Logger) *transaction.Envelope {
	key, err := srv.DB.GetMainKey()
	if err != nil {
		log.Error("error while attempting to retrieve main key", "err", err)
	}
	if key != nil {
		bat, err := transaction.NewBlockAttribution()
		if err != nil {
			log.Error("error while creating a BAT", "err", err)
		} else {
			hash, err := srv.DB.GetPreviousEnvelopeHashForPublicKey(&key.PublicKey)
			if err != nil {
				log.Error("error while creating a BAT", "err", err)
			}
			bate := transaction.NewEnvelope(hash, bat)
			bate.Sign(key)
			return bate
		}
	}
	return nil

}