mirror of
https://github.com/LBRYFoundation/lbry-database-java.git
synced 2025-08-23 09:27:22 +00:00
Fix constructor of rows
This commit is contained in:
parent
90ed8b23b0
commit
26f7b360a2
45 changed files with 374 additions and 139 deletions
|
@ -118,45 +118,45 @@ public class PrefixDB{
|
|||
|
||||
this.maxUndoDepth = maxUndoDepth;
|
||||
|
||||
this.claim_to_support = new ClaimToSupportPrefixRow(this);
|
||||
this.support_to_claim = new SupportToClaimPrefixRow(this);
|
||||
this.claim_to_txo = new ClaimToTXOPrefixRow(this);
|
||||
this.txo_to_claim = new TXOToClaimPrefixRow(this);
|
||||
this.claim_to_channel = new ClaimToChannelPrefixRow(this);
|
||||
this.channel_to_claim = new ChannelToClaimPrefixRow(this);
|
||||
this.claim_short_id = new ClaimShortIDPrefixRow(this);
|
||||
this.claim_expiration = new ClaimExpirationPrefixRow(this);
|
||||
this.claim_takeover = new ClaimTakeoverPrefixRow(this);
|
||||
this.pending_activation = new PendingActivationPrefixRow(this);
|
||||
this.activated = new ActivatedPrefixRow(this);
|
||||
this.active_amount = new ActiveAmountPrefixRow(this);
|
||||
this.bid_order = new BidOrderPrefixRow(this);
|
||||
this.repost = new RepostPrefixRow(this);
|
||||
this.reposted_claim = new RepostedPrefixRow(this);
|
||||
this.reposted_count = new RepostedCountPrefixRow(this);
|
||||
this.undo = new UndoPrefixRow(this);
|
||||
this.utxo = new UTXOPrefixRow(this);
|
||||
this.hashX_utxo = new HashXUTXOPrefixRow(this);
|
||||
this.hashX_history = new HashXHistoryPrefixRow(this);
|
||||
this.block_hash = new BlockHashPrefixRow(this);
|
||||
this.tx_count = new TxCountPrefixRow(this);
|
||||
this.tx_hash = new TXHashPrefixRow(this);
|
||||
this.tx_num = new TXNumPrefixRow(this);
|
||||
this.tx = new TXPrefixRow(this);
|
||||
this.header = new BlockHeaderPrefixRow(this);
|
||||
this.touched_or_deleted = new TouchedOrDeletedPrefixRow(this);
|
||||
this.channel_count = new ChannelCountPrefixRow(this);
|
||||
this.db_state = new DBStatePrefixRow(this);
|
||||
this.support_amount = new SupportAmountPrefixRow(this);
|
||||
this.block_txs = new BlockTxsPrefixRow(this);
|
||||
this.mempool_tx = new MempoolTXPrefixRow(this);
|
||||
this.trending_notification = new TrendingNotificationPrefixRow(this);
|
||||
this.touched_hashX = new TouchedHashXPrefixRow(this);
|
||||
this.hashX_status = new HashXStatusPrefixRow(this);
|
||||
this.hashX_mempool_status = new HashXMempoolStatusPrefixRow(this);
|
||||
this.effective_amount = new EffectiveAmountPrefixRow(this);
|
||||
this.future_effective_amount = new FutureEffectiveAmountPrefixRow(this);
|
||||
this.hashX_history_hasher = new HashXHistoryHasherPrefixRow(this);
|
||||
this.claim_to_support = new ClaimToSupportPrefixRow(this,this.operationStack);
|
||||
this.support_to_claim = new SupportToClaimPrefixRow(this,this.operationStack);
|
||||
this.claim_to_txo = new ClaimToTXOPrefixRow(this,this.operationStack);
|
||||
this.txo_to_claim = new TXOToClaimPrefixRow(this,this.operationStack);
|
||||
this.claim_to_channel = new ClaimToChannelPrefixRow(this,this.operationStack);
|
||||
this.channel_to_claim = new ChannelToClaimPrefixRow(this,this.operationStack);
|
||||
this.claim_short_id = new ClaimShortIDPrefixRow(this,this.operationStack);
|
||||
this.claim_expiration = new ClaimExpirationPrefixRow(this,this.operationStack);
|
||||
this.claim_takeover = new ClaimTakeoverPrefixRow(this,this.operationStack);
|
||||
this.pending_activation = new PendingActivationPrefixRow(this,this.operationStack);
|
||||
this.activated = new ActivatedPrefixRow(this,this.operationStack);
|
||||
this.active_amount = new ActiveAmountPrefixRow(this,this.operationStack);
|
||||
this.bid_order = new BidOrderPrefixRow(this,this.operationStack);
|
||||
this.repost = new RepostPrefixRow(this,this.operationStack);
|
||||
this.reposted_claim = new RepostedPrefixRow(this,this.operationStack);
|
||||
this.reposted_count = new RepostedCountPrefixRow(this,this.operationStack);
|
||||
this.undo = new UndoPrefixRow(this,this.operationStack);
|
||||
this.utxo = new UTXOPrefixRow(this,this.operationStack);
|
||||
this.hashX_utxo = new HashXUTXOPrefixRow(this,this.operationStack);
|
||||
this.hashX_history = new HashXHistoryPrefixRow(this,this.operationStack);
|
||||
this.block_hash = new BlockHashPrefixRow(this,this.operationStack);
|
||||
this.tx_count = new TxCountPrefixRow(this,this.operationStack);
|
||||
this.tx_hash = new TXHashPrefixRow(this,this.operationStack);
|
||||
this.tx_num = new TXNumPrefixRow(this,this.operationStack);
|
||||
this.tx = new TXPrefixRow(this,this.operationStack);
|
||||
this.header = new BlockHeaderPrefixRow(this,this.operationStack);
|
||||
this.touched_or_deleted = new TouchedOrDeletedPrefixRow(this,this.operationStack);
|
||||
this.channel_count = new ChannelCountPrefixRow(this,this.operationStack);
|
||||
this.db_state = new DBStatePrefixRow(this,this.operationStack);
|
||||
this.support_amount = new SupportAmountPrefixRow(this,this.operationStack);
|
||||
this.block_txs = new BlockTxsPrefixRow(this,this.operationStack);
|
||||
this.mempool_tx = new MempoolTXPrefixRow(this,this.operationStack);
|
||||
this.trending_notification = new TrendingNotificationPrefixRow(this,this.operationStack);
|
||||
this.touched_hashX = new TouchedHashXPrefixRow(this,this.operationStack);
|
||||
this.hashX_status = new HashXStatusPrefixRow(this,this.operationStack);
|
||||
this.hashX_mempool_status = new HashXMempoolStatusPrefixRow(this,this.operationStack);
|
||||
this.effective_amount = new EffectiveAmountPrefixRow(this,this.operationStack);
|
||||
this.future_effective_amount = new FutureEffectiveAmountPrefixRow(this,this.operationStack);
|
||||
this.hashX_history_hasher = new HashXHistoryHasherPrefixRow(this,this.operationStack);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -85,7 +85,7 @@ public class RevertibleOperationStack{
|
|||
if(this.enforceIntegrity && !uniqueKeys.isEmpty()){
|
||||
List<byte[]> uniqueKeysList = new ArrayList<>(uniqueKeys);
|
||||
for(int idx=0;idx<uniqueKeys.size();idx+=10000){
|
||||
List<byte[]> batch = uniqueKeysList.subList(idx,idx+10000);
|
||||
List<byte[]> batch = uniqueKeysList.subList(idx,Math.min(uniqueKeysList.size(),idx+10000));
|
||||
Iterator<Optional<byte[]>> iterator = this.multiGet.apply(batch).iterator();
|
||||
for(byte[] k : batch){
|
||||
byte[] v = iterator.next().get();
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.ActivationKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.ActivationValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class ActivatedPrefixRow extends PrefixRow<ActivationKey,ActivationValue>{
|
||||
|
||||
public ActivatedPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public ActivatedPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.ActiveAmountKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.ActiveAmountValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class ActiveAmountPrefixRow extends PrefixRow<ActiveAmountKey,ActiveAmountValue>{
|
||||
|
||||
public ActiveAmountPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public ActiveAmountPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.BidOrderKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.BidOrderValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class BidOrderPrefixRow extends PrefixRow<BidOrderKey,BidOrderValue>{
|
||||
|
||||
public BidOrderPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public BidOrderPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.BlockHashKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.BlockHashValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class BlockHashPrefixRow extends PrefixRow<BlockHashKey,BlockHashValue>{
|
||||
|
||||
public BlockHashPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public BlockHashPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.BlockHeaderKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.BlockHeaderValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class BlockHeaderPrefixRow extends PrefixRow<BlockHeaderKey,BlockHeaderValue>{
|
||||
|
||||
public BlockHeaderPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public BlockHeaderPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.BlockTxsKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.BlockTxsValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -11,8 +12,8 @@ import java.util.ArrayList;
|
|||
|
||||
public class BlockTxsPrefixRow extends PrefixRow<BlockTxsKey,BlockTxsValue>{
|
||||
|
||||
public BlockTxsPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public BlockTxsPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.ChannelCountKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.ChannelCountValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class ChannelCountPrefixRow extends PrefixRow<ChannelCountKey,ChannelCountValue>{
|
||||
|
||||
public ChannelCountPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public ChannelCountPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.ChannelToClaimKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.ChannelToClaimValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class ChannelToClaimPrefixRow extends PrefixRow<ChannelToClaimKey,ChannelToClaimValue>{
|
||||
|
||||
public ChannelToClaimPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public ChannelToClaimPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.ClaimExpirationKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.ClaimExpirationValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class ClaimExpirationPrefixRow extends PrefixRow<ClaimExpirationKey,ClaimExpirationValue>{
|
||||
|
||||
public ClaimExpirationPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public ClaimExpirationPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.ClaimShortIDKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.ClaimShortIDValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class ClaimShortIDPrefixRow extends PrefixRow<ClaimShortIDKey,ClaimShortIDValue>{
|
||||
|
||||
public ClaimShortIDPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public ClaimShortIDPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.ClaimTakeoverKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.ClaimTakeoverValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class ClaimTakeoverPrefixRow extends PrefixRow<ClaimTakeoverKey,ClaimTakeoverValue>{
|
||||
|
||||
public ClaimTakeoverPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public ClaimTakeoverPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.ClaimToChannelKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.ClaimToChannelValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class ClaimToChannelPrefixRow extends PrefixRow<ClaimToChannelKey,ClaimToChannelValue>{
|
||||
|
||||
public ClaimToChannelPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public ClaimToChannelPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.ClaimToSupportKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.ClaimToSupportValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class ClaimToSupportPrefixRow extends PrefixRow<ClaimToSupportKey,ClaimToSupportValue>{
|
||||
|
||||
public ClaimToSupportPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public ClaimToSupportPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.ClaimToTXOKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.ClaimToTXOValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class ClaimToTXOPrefixRow extends PrefixRow<ClaimToTXOKey,ClaimToTXOValue>{
|
||||
|
||||
public ClaimToTXOPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public ClaimToTXOPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.KeyInterface;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.DBState;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class DBStatePrefixRow extends PrefixRow<KeyInterface,DBState>{
|
||||
|
||||
public DBStatePrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public DBStatePrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.EffectiveAmountKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.EffectiveAmountValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class EffectiveAmountPrefixRow extends PrefixRow<EffectiveAmountKey,EffectiveAmountValue>{
|
||||
|
||||
public EffectiveAmountPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public EffectiveAmountPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.FutureEffectiveAmountKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.FutureEffectiveAmountValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class FutureEffectiveAmountPrefixRow extends PrefixRow<FutureEffectiveAmountKey,FutureEffectiveAmountValue>{
|
||||
|
||||
public FutureEffectiveAmountPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public FutureEffectiveAmountPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.HashXHistoryHasherKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.HashXHistoryHasherValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class HashXHistoryHasherPrefixRow extends PrefixRow<HashXHistoryHasherKey,HashXHistoryHasherValue>{
|
||||
|
||||
public HashXHistoryHasherPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public HashXHistoryHasherPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.HashXHistoryKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.HashXHistoryValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -11,8 +12,8 @@ import java.util.ArrayList;
|
|||
|
||||
public class HashXHistoryPrefixRow extends PrefixRow<HashXHistoryKey,HashXHistoryValue>{
|
||||
|
||||
public HashXHistoryPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public HashXHistoryPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.HashXStatusKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.HashXStatusValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class HashXMempoolStatusPrefixRow extends PrefixRow<HashXStatusKey,HashXStatusValue>{
|
||||
|
||||
public HashXMempoolStatusPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public HashXMempoolStatusPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.HashXStatusKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.HashXStatusValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class HashXStatusPrefixRow extends PrefixRow<HashXStatusKey,HashXStatusValue>{
|
||||
|
||||
public HashXStatusPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public HashXStatusPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.HashXUTXOKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.HashXUTXOValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class HashXUTXOPrefixRow extends PrefixRow<HashXUTXOKey,HashXUTXOValue>{
|
||||
|
||||
public HashXUTXOPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public HashXUTXOPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.MempoolTxKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.MempoolTxValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class MempoolTXPrefixRow extends PrefixRow<MempoolTxKey,MempoolTxValue>{
|
||||
|
||||
public MempoolTXPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public MempoolTXPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.PendingActivationKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.PendingActivationValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class PendingActivationPrefixRow extends PrefixRow<PendingActivationKey,PendingActivationValue>{
|
||||
|
||||
public PendingActivationPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public PendingActivationPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,12 +3,11 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.KeyInterface;
|
||||
import com.lbry.database.revert.RevertibleOperation;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.ValueInterface;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.rocksdb.ColumnFamilyHandle;
|
||||
|
@ -21,9 +20,11 @@ public abstract class PrefixRow<K extends KeyInterface,V extends ValueInterface>
|
|||
public static final Map<Prefix,PrefixRow<?,?>> TYPES = new HashMap<>();
|
||||
|
||||
private final PrefixDB database;
|
||||
private final RevertibleOperationStack operationStack;
|
||||
|
||||
public PrefixRow(PrefixDB database){
|
||||
public PrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
this.database = database;
|
||||
this.operationStack = operationStack;
|
||||
PrefixRow.TYPES.put(this.prefix(),this);
|
||||
}
|
||||
|
||||
|
@ -75,13 +76,7 @@ public abstract class PrefixRow<K extends KeyInterface,V extends ValueInterface>
|
|||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void stashMultiDelete(Map<K,V> items){
|
||||
Map<byte[],byte[]> map = new LinkedHashMap<>();
|
||||
for(Map.Entry<K,V> entry : items.entrySet()){
|
||||
map.put(this.packKey(entry.getKey()),this.packValue(entry.getValue()));
|
||||
}
|
||||
this.database.multiDelete(map);
|
||||
}
|
||||
//TODO multiGetAsyncGen
|
||||
|
||||
public void stashMultiPut(Map<K,V> items){
|
||||
Map<byte[],byte[]> map = new LinkedHashMap<>();
|
||||
|
@ -91,14 +86,48 @@ public abstract class PrefixRow<K extends KeyInterface,V extends ValueInterface>
|
|||
this.database.multiPut(map);
|
||||
}
|
||||
|
||||
public void stashDelete(K key,V value){
|
||||
this.database.stashRawDelete(this.packKey(key),this.packValue(value));
|
||||
public void stashMultiDelete(Map<K,V> items){
|
||||
Map<byte[],byte[]> map = new LinkedHashMap<>();
|
||||
for(Map.Entry<K,V> entry : items.entrySet()){
|
||||
map.put(this.packKey(entry.getKey()),this.packValue(entry.getValue()));
|
||||
}
|
||||
this.database.multiDelete(map);
|
||||
}
|
||||
|
||||
public V getPending(K key){
|
||||
return this.getPending(key,true);
|
||||
}
|
||||
|
||||
public V getPending(K key,boolean fillCache){
|
||||
return this.getPending(key,fillCache,true);
|
||||
}
|
||||
|
||||
public V getPending(K key,boolean fillCache,boolean deserializeValue){
|
||||
// byte[] packedKey = this.packKey(key);
|
||||
// Optional<RevertibleOperation> pendingOperation = this.operationStack.getPendingOperation(packedKey);
|
||||
// if(pendingOperation.isPresent() && pendingOperation.get().isDelete()){
|
||||
// return null;
|
||||
// }
|
||||
// byte[] v;
|
||||
// if(pendingOperation.isPresent()){
|
||||
// v = pendingOperation.get().getValue();
|
||||
// }else{
|
||||
// v = this.database.get(this.getColumnFamily(),fillCache);
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
//TODO getPending
|
||||
|
||||
public void stashPut(K key,V value){
|
||||
this.database.stashRawPut(this.packKey(key),this.packValue(value));
|
||||
}
|
||||
|
||||
|
||||
public void stashDelete(K key,V value){
|
||||
this.database.stashRawDelete(this.packKey(key),this.packValue(value));
|
||||
}
|
||||
|
||||
public ColumnFamilyHandle getColumnFamily() throws RocksDBException{
|
||||
return this.database.getColumnFamilyByPrefix(this.prefix());
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.RepostKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.RepostValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class RepostPrefixRow extends PrefixRow<RepostKey,RepostValue>{
|
||||
|
||||
public RepostPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public RepostPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.RepostedCountKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.RepostedCountValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class RepostedCountPrefixRow extends PrefixRow<RepostedCountKey,RepostedCountValue>{
|
||||
|
||||
public RepostedCountPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public RepostedCountPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.RepostedKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.RepostedValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class RepostedPrefixRow extends PrefixRow<RepostedKey,RepostedValue>{
|
||||
|
||||
public RepostedPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public RepostedPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.SupportAmountKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.SupportAmountValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class SupportAmountPrefixRow extends PrefixRow<SupportAmountKey,SupportAmountValue>{
|
||||
|
||||
public SupportAmountPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public SupportAmountPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.SupportToClaimKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.SupportToClaimValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class SupportToClaimPrefixRow extends PrefixRow<SupportToClaimKey,SupportToClaimValue>{
|
||||
|
||||
public SupportToClaimPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public SupportToClaimPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.TxHashKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.TxHashValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class TXHashPrefixRow extends PrefixRow<TxHashKey, TxHashValue>{
|
||||
|
||||
public TXHashPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public TXHashPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.TxNumKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.TxNumValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class TXNumPrefixRow extends PrefixRow<TxNumKey,TxNumValue>{
|
||||
|
||||
public TXNumPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public TXNumPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.TXOToClaimKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.TXOToClaimValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class TXOToClaimPrefixRow extends PrefixRow<TXOToClaimKey, TXOToClaimValue>{
|
||||
|
||||
public TXOToClaimPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public TXOToClaimPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.TxKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.TxValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class TXPrefixRow extends PrefixRow<TxKey,TxValue>{
|
||||
|
||||
public TXPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public TXPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.TouchedHashXKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.TouchedHashXValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -11,8 +12,8 @@ import java.util.ArrayList;
|
|||
|
||||
public class TouchedHashXPrefixRow extends PrefixRow<TouchedHashXKey,TouchedHashXValue>{
|
||||
|
||||
public TouchedHashXPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public TouchedHashXPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.TouchedOrDeletedClaimKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.TouchedOrDeletedClaimValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -11,8 +12,8 @@ import java.util.LinkedHashSet;
|
|||
|
||||
public class TouchedOrDeletedPrefixRow extends PrefixRow<TouchedOrDeletedClaimKey,TouchedOrDeletedClaimValue>{
|
||||
|
||||
public TouchedOrDeletedPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public TouchedOrDeletedPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.TrendingNotificationKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.TrendingNotificationValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class TrendingNotificationPrefixRow extends PrefixRow<TrendingNotificationKey,TrendingNotificationValue>{
|
||||
|
||||
public TrendingNotificationPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public TrendingNotificationPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.TxCountKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.TxCountValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class TxCountPrefixRow extends PrefixRow<TxCountKey, TxCountValue>{
|
||||
|
||||
public TxCountPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public TxCountPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.UTXOKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.UTXOValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class UTXOPrefixRow extends PrefixRow<UTXOKey,UTXOValue>{
|
||||
|
||||
public UTXOPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public UTXOPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lbry.database.rows;
|
|||
import com.lbry.database.Prefix;
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.UndoKey;
|
||||
import com.lbry.database.revert.RevertibleOperationStack;
|
||||
import com.lbry.database.values.UndoValue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -10,8 +11,8 @@ import java.nio.ByteOrder;
|
|||
|
||||
public class UndoPrefixRow extends PrefixRow<UndoKey,UndoValue>{
|
||||
|
||||
public UndoPrefixRow(PrefixDB database){
|
||||
super(database);
|
||||
public UndoPrefixRow(PrefixDB database,RevertibleOperationStack operationStack){
|
||||
super(database,operationStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
14
src/main/java/com/lbry/database/util/ArrayHelper.java
Normal file
14
src/main/java/com/lbry/database/util/ArrayHelper.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package com.lbry.database.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ArrayHelper{
|
||||
|
||||
public static byte[] fill(byte[] arr,byte val){
|
||||
if(arr!=null){
|
||||
Arrays.fill(arr,val);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
package com.lbry.database.tests;
|
||||
|
||||
import com.lbry.database.PrefixDB;
|
||||
import com.lbry.database.keys.ClaimTakeoverKey;
|
||||
import com.lbry.database.util.ArrayHelper;
|
||||
import com.lbry.database.values.ClaimTakeoverValue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.rocksdb.RocksDBException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class RevertablePrefixDBTest{
|
||||
|
||||
private File tmpDir;
|
||||
private PrefixDB database;
|
||||
|
||||
@BeforeAll
|
||||
public void setUp() throws IOException,RocksDBException{
|
||||
this.tmpDir = Files.createTempDirectory("tmp").toFile();
|
||||
System.err.println(this.tmpDir);
|
||||
this.database = new PrefixDB(this.tmpDir.getAbsolutePath(),32);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public void tearDown(){}
|
||||
|
||||
@Test
|
||||
public void testRollback() throws RocksDBException{
|
||||
String name = "derp";
|
||||
byte[] claim_hash1 = new byte[20];
|
||||
Arrays.fill(claim_hash1, (byte) 0x00);
|
||||
byte[] claim_hash2 = new byte[20];
|
||||
Arrays.fill(claim_hash2, (byte) 0x01);
|
||||
byte[] claim_hash3 = new byte[20];
|
||||
Arrays.fill(claim_hash3, (byte) 0x02);
|
||||
|
||||
int takeoverHeight = 10000000;
|
||||
|
||||
assertNull(this.database.claim_takeover.get(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}}));
|
||||
this.database.claim_takeover.stashPut(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}},new ClaimTakeoverValue(){{
|
||||
this.claim_hash = claim_hash1;
|
||||
this.height = takeoverHeight;
|
||||
}});
|
||||
assertNull(this.database.claim_takeover.get(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}}));
|
||||
assertEquals(10000000,this.database.claim_takeover.getPending(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}}).height);
|
||||
|
||||
/////////////////////
|
||||
|
||||
this.database.commit(10000000,ArrayHelper.fill(new byte[32],(byte) 0x00));
|
||||
assertEquals(10000000,((ClaimTakeoverValue)this.database.claim_takeover.get(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}})).height);
|
||||
|
||||
/////////////////////
|
||||
|
||||
this.database.claim_takeover.stashDelete(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}},new ClaimTakeoverValue(){{
|
||||
this.claim_hash = claim_hash1;
|
||||
this.height = takeoverHeight;
|
||||
}});
|
||||
this.database.claim_takeover.stashPut(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}},new ClaimTakeoverValue(){{
|
||||
this.claim_hash = claim_hash2;
|
||||
this.height = takeoverHeight + 1;
|
||||
}});
|
||||
this.database.claim_takeover.stashDelete(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}},new ClaimTakeoverValue(){{
|
||||
this.claim_hash = claim_hash2;
|
||||
this.height = takeoverHeight + 1;
|
||||
}});
|
||||
this.database.commit(10000001,ArrayHelper.fill(new byte[32],(byte) 0x01));
|
||||
assertNull(this.database.claim_takeover.get(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}}));
|
||||
this.database.claim_takeover.stashPut(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}},new ClaimTakeoverValue(){{
|
||||
this.claim_hash = claim_hash3;
|
||||
this.height = takeoverHeight + 2;
|
||||
}});
|
||||
this.database.commit(10000002,ArrayHelper.fill(new byte[32],(byte) 0x02));
|
||||
assertEquals(10000002,((ClaimTakeoverValue)this.database.claim_takeover.get(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}})).height);
|
||||
|
||||
/////////////////////
|
||||
|
||||
this.database.claim_takeover.stashDelete(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}},new ClaimTakeoverValue(){{
|
||||
this.claim_hash = claim_hash3;
|
||||
this.height = takeoverHeight + 2;
|
||||
}});
|
||||
this.database.claim_takeover.stashPut(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}},new ClaimTakeoverValue(){{
|
||||
this.claim_hash = claim_hash2;
|
||||
this.height = takeoverHeight + 3;
|
||||
}});
|
||||
this.database.commit(10000003,ArrayHelper.fill(new byte[32],(byte) 0x03));
|
||||
assertEquals(10000003,((ClaimTakeoverValue)this.database.claim_takeover.get(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}})).height);
|
||||
|
||||
/////////////////////
|
||||
|
||||
this.database.rollback(10000003,ArrayHelper.fill(new byte[32],(byte) 0x03));
|
||||
assertEquals(10000002,((ClaimTakeoverValue)this.database.claim_takeover.get(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}})).height);
|
||||
this.database.rollback(10000002,ArrayHelper.fill(new byte[32],(byte) 0x02));
|
||||
assertNull(this.database.claim_takeover.get(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}}));
|
||||
this.database.rollback(10000001,ArrayHelper.fill(new byte[32],(byte) 0x01));
|
||||
assertEquals(10000000,((ClaimTakeoverValue)this.database.claim_takeover.get(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}})).height);
|
||||
this.database.rollback(10000000,ArrayHelper.fill(new byte[32],(byte) 0x00));
|
||||
assertNull(this.database.claim_takeover.get(new ClaimTakeoverKey(){{
|
||||
this.normalized_name = name;
|
||||
}}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHubDatabaseIterator(){}
|
||||
|
||||
@Test
|
||||
public void testHubDatabaseIteratorStartStop(){}
|
||||
|
||||
}
|
|
@ -78,19 +78,19 @@ public class RevertibleOperationStackTest {
|
|||
ClaimToTXOKey k1 = new ClaimToTXOKey();
|
||||
k1.claim_hash = new byte[20];
|
||||
Arrays.fill(k1.claim_hash,(byte) 0x01);
|
||||
byte[] key1 = new ClaimToTXOPrefixRow(null).packKey(k1);
|
||||
byte[] key1 = new ClaimToTXOPrefixRow(null,null).packKey(k1);
|
||||
ClaimToTXOKey k2 = new ClaimToTXOKey();
|
||||
k2.claim_hash = new byte[20];
|
||||
Arrays.fill(k2.claim_hash,(byte) 0x02);
|
||||
byte[] key2 = new ClaimToTXOPrefixRow(null).packKey(k2);
|
||||
byte[] key2 = new ClaimToTXOPrefixRow(null,null).packKey(k2);
|
||||
// ClaimToTXOKey k3 = new ClaimToTXOKey();
|
||||
// k3.claim_hash = new byte[20];
|
||||
// Arrays.fill(k3.claim_hash,(byte) 0x03);
|
||||
// byte[] key3 = new ClaimToTXOPrefixRow(null).packKey(k3);
|
||||
// byte[] key3 = new ClaimToTXOPrefixRow(null,null).packKey(k3);
|
||||
// ClaimToTXOKey k4 = new ClaimToTXOKey();
|
||||
// k4.claim_hash = new byte[20];
|
||||
// Arrays.fill(k4.claim_hash,(byte) 0x04);
|
||||
// byte[] key4 = new ClaimToTXOPrefixRow(null).packKey(k4);
|
||||
// byte[] key4 = new ClaimToTXOPrefixRow(null,null).packKey(k4);
|
||||
|
||||
ClaimToTXOValue v1 = new ClaimToTXOValue();
|
||||
v1.tx_num = 1;
|
||||
|
@ -100,7 +100,7 @@ public class RevertibleOperationStackTest {
|
|||
v1.amount = 1;
|
||||
v1.channel_signature_is_valid = false;
|
||||
v1.name = "derp";
|
||||
byte[] val1 = new ClaimToTXOPrefixRow(null).packValue(v1);
|
||||
byte[] val1 = new ClaimToTXOPrefixRow(null,null).packValue(v1);
|
||||
ClaimToTXOValue v2 = new ClaimToTXOValue();
|
||||
v2.tx_num = 1;
|
||||
v2.position = 0;
|
||||
|
@ -109,7 +109,7 @@ public class RevertibleOperationStackTest {
|
|||
v2.amount = 1;
|
||||
v2.channel_signature_is_valid = false;
|
||||
v2.name = "oops";
|
||||
byte[] val2 = new ClaimToTXOPrefixRow(null).packValue(v2);
|
||||
byte[] val2 = new ClaimToTXOPrefixRow(null,null).packValue(v2);
|
||||
ClaimToTXOValue v3 = new ClaimToTXOValue();
|
||||
v3.tx_num = 1;
|
||||
v3.position = 0;
|
||||
|
@ -118,7 +118,7 @@ public class RevertibleOperationStackTest {
|
|||
v3.amount = 1;
|
||||
v3.channel_signature_is_valid = false;
|
||||
v3.name = "other";
|
||||
byte[] val3 = new ClaimToTXOPrefixRow(null).packValue(v3);
|
||||
byte[] val3 = new ClaimToTXOPrefixRow(null,null).packValue(v3);
|
||||
|
||||
// Check that we can't delete a non-existent value.
|
||||
assertThrows(OperationStackIntegrityException.class,() -> this.stack.appendOperation(new RevertibleDelete(key1,val1)));
|
||||
|
|
Loading…
Add table
Reference in a new issue