Ejemplo n.º 1
0
func (txn *Txn) TxnRootBytes() []byte {
	txn.RLock()
	trb := txn.txnRootBytes
	txn.RUnlock()
	if trb == nil {
		txn.Lock()
		if txn.txnRootBytes == nil {
			txn.txnRootBytes = db.TxnToRootBytes(txn.TxnCap)
			trb = txn.txnRootBytes
		}
		txn.Unlock()
	}
	return trb
}
Ejemplo n.º 2
0
func (txn *Txn) TxnRootBytes() []byte {
	trb := &txn.txnRootBytes
	trb.RLock()
	bites := trb.bites
	trb.RUnlock()
	if bites == nil {
		trb.Lock()
		if trb.bites == nil {
			trb.bites = db.TxnToRootBytes(txn.TxnCap)
		}
		bites = trb.bites
		trb.Unlock()
	}
	return bites
}