func (handler *TransactionStore) AddIncludedTransaction(tx *protocol.Transaction, topology *koinos.BlockTopology) error {
	handler.rwmutex.Lock()
	defer handler.rwmutex.Unlock()

	itemBytes, err := handler.backend.Get(tx.Id)
	if err != nil {
		return fmt.Errorf("%w, %v", ErrBackend, err)
	}

	if len(itemBytes) == 0 {
		item := transaction_store.TransactionItem{
			Transaction:      tx,
			ContainingBlocks: [][]byte{topology.Id},
		}

		itemBytes, err = proto.Marshal(&item)
		if err != nil {
			return fmt.Errorf("%w, %v", ErrSerialization, err)
		}

		err = handler.backend.Put(tx.Id, itemBytes)
		if err != nil {
			return fmt.Errorf("%w, %v", ErrBackend, err)
		}
	} else {
		item := &transaction_store.TransactionItem{}
		if err := proto.Unmarshal(itemBytes, item); err != nil {
			return fmt.Errorf("%w, %v", ErrDeserialization, err)
		}

		for _, blockID := range item.ContainingBlocks {
			if bytes.Equal(blockID, topology.Id) {
				return nil
			}
		}

		item.ContainingBlocks = append(item.ContainingBlocks, topology.Id)
		itemBytes, err = proto.Marshal(item)
		if err != nil {
			return fmt.Errorf("%w, %v", ErrSerialization, err)
		}

		err = handler.backend.Put(tx.Id, itemBytes)
		if err != nil {
			return fmt.Errorf("%w, %v", ErrBackend, err)
		}
	}

	return nil
}
// AddIncludedTransaction adds a transaction to with the associated block topology
AddIncludedTransaction adds a transaction to with the associated block topology
// AddIncludedTransaction adds a transaction to with the associated block topology
func (handler *TransactionStore) AddIncludedTransaction(tx *protocol.Transaction, topology *koinos.BlockTopology) error {
	handler.rwmutex.Lock()
	defer handler.rwmutex.Unlock()
	itemBytes, err := handler.backend.Get(tx.Id)
	if err != nil {
		return fmt.Errorf("%w, %v", ErrBackend, err)
	}
	if len(itemBytes) == 0 {
		item := transaction_store.TransactionItem{
			Transaction:      tx,
			ContainingBlocks: [][]byte{topology.Id},
		}
		itemBytes, err = proto.Marshal(&item)
		if err != nil {
			return fmt.Errorf("%w, %v", ErrSerialization, err)
		}
		err = handler.backend.Put(tx.Id, itemBytes)
		if err != nil {
			return fmt.Errorf("%w, %v", ErrBackend, err)
		}
	} else {
		item := &transaction_store.TransactionItem{}
		if err := proto.Unmarshal(itemBytes, item); err != nil {
			return fmt.Errorf("%w, %v", ErrDeserialization, err)
		}
		for _, blockID := range item.ContainingBlocks {
			if bytes.Equal(blockID, topology.Id) {
				return nil
			}
		}
		item.ContainingBlocks = append(item.ContainingBlocks, topology.Id)
		itemBytes, err = proto.Marshal(item)
		if err != nil {
			return fmt.Errorf("%w, %v", ErrSerialization, err)
		}
		err = handler.backend.Put(tx.Id, itemBytes)
		if err != nil {
			return fmt.Errorf("%w, %v", ErrBackend, err)
		}
	}
	return nil
}
func ( handler * TransactionStore ) AddIncludedTransaction ( tx * protocol . Transaction , topology * koinos . BlockTopology ) error { handler . rwmutex . Lock ( ) defer handler . rwmutex . Unlock ( ) itemBytes , err := handler . backend . Get ( tx . Id ) if err != nil { return fmt . Errorf ( " " , ErrBackend , err ) } if len ( itemBytes ) == 0 { item := transaction_store . TransactionItem { Transaction : tx , ContainingBlocks : [ ] [ ] byte { topology . Id } , } itemBytes , err = proto . Marshal ( & item ) if err != nil { return fmt . Errorf ( " " , ErrSerialization , err ) } err = handler . backend . Put ( tx . Id , itemBytes ) if err != nil { return fmt . Errorf ( " " , ErrBackend , err ) } } else { item := & transaction_store . TransactionItem { } if err := proto . Unmarshal ( itemBytes , item ) ; err != nil { return fmt . Errorf ( " " , ErrDeserialization , err ) } for _ , blockID := range item . ContainingBlocks { if bytes . Equal ( blockID , topology . Id ) { return nil } } item . ContainingBlocks = append ( item . ContainingBlocks , topology . Id ) itemBytes , err = proto . Marshal ( item ) if err != nil { return fmt . Errorf ( " " , ErrSerialization , err ) } err = handler . backend . Put ( tx . Id , itemBytes ) if err != nil { return fmt . Errorf ( " " , ErrBackend , err ) } } return nil }
AddIncludedTransaction adds a transaction to with the associated block topology
AddIncludedTransaction adds a transaction to with the associated block topology