예제 #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
}
예제 #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
}