mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-13 10:45:51 +00:00
WalletProtobufSerializer: Allow to specify buffer size for saving wallet file via OutputStream.
This commit is contained in:
parent
01cff428d3
commit
14ef3c0052
@ -31,6 +31,7 @@ import org.bitcoinj.wallet.Protos.Wallet.EncryptionType;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.CodedInputStream;
|
import com.google.protobuf.CodedInputStream;
|
||||||
|
import com.google.protobuf.CodedOutputStream;
|
||||||
import com.google.protobuf.TextFormat;
|
import com.google.protobuf.TextFormat;
|
||||||
import com.google.protobuf.WireFormat;
|
import com.google.protobuf.WireFormat;
|
||||||
|
|
||||||
@ -78,6 +79,7 @@ public class WalletProtobufSerializer {
|
|||||||
protected Map<ByteString, Transaction> txMap;
|
protected Map<ByteString, Transaction> txMap;
|
||||||
|
|
||||||
private boolean requireMandatoryExtensions = true;
|
private boolean requireMandatoryExtensions = true;
|
||||||
|
private int walletWriteBufferSize = CodedOutputStream.DEFAULT_BUFFER_SIZE;
|
||||||
|
|
||||||
public interface WalletFactory {
|
public interface WalletFactory {
|
||||||
Wallet create(NetworkParameters params, KeyChainGroup keyChainGroup);
|
Wallet create(NetworkParameters params, KeyChainGroup keyChainGroup);
|
||||||
@ -114,6 +116,14 @@ public class WalletProtobufSerializer {
|
|||||||
requireMandatoryExtensions = value;
|
requireMandatoryExtensions = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change buffer size for writing wallet to output stream. Default is {@link com.google.protobuf.CodedOutputStream.DEFAULT_BUFFER_SIZE}
|
||||||
|
* @param walletWriteBufferSize - buffer size in bytes
|
||||||
|
*/
|
||||||
|
public void setWalletWriteBufferSize(int walletWriteBufferSize) {
|
||||||
|
this.walletWriteBufferSize = walletWriteBufferSize;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats the given wallet (transactions and keys) to the given output stream in protocol buffer format.<p>
|
* Formats the given wallet (transactions and keys) to the given output stream in protocol buffer format.<p>
|
||||||
*
|
*
|
||||||
@ -121,7 +131,9 @@ public class WalletProtobufSerializer {
|
|||||||
*/
|
*/
|
||||||
public void writeWallet(Wallet wallet, OutputStream output) throws IOException {
|
public void writeWallet(Wallet wallet, OutputStream output) throws IOException {
|
||||||
Protos.Wallet walletProto = walletToProto(wallet);
|
Protos.Wallet walletProto = walletToProto(wallet);
|
||||||
walletProto.writeTo(output);
|
final CodedOutputStream codedOutput = CodedOutputStream.newInstance(output, this.walletWriteBufferSize);
|
||||||
|
walletProto.writeTo(codedOutput);
|
||||||
|
codedOutput.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user