|
|
@ -25,72 +25,49 @@ public class RlpProvider { |
|
|
|
private RlpProvider() {} |
|
|
|
private RlpProvider() {} |
|
|
|
|
|
|
|
|
|
|
|
public static TransactionHandler transaction() { |
|
|
|
public static TransactionHandler transaction() { |
|
|
|
return new TransactionHandler(); |
|
|
|
return new TransactionHandler( |
|
|
|
|
|
|
|
RlpRegistry.getInstance().getTransactionDecoder(), |
|
|
|
|
|
|
|
RlpRegistry.getInstance().getTransactionEncoder()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static PooledTransactionHandler pooledTransaction() { |
|
|
|
public static TransactionHandler pooledTransaction() { |
|
|
|
return new PooledTransactionHandler(); |
|
|
|
return new TransactionHandler( |
|
|
|
|
|
|
|
RlpRegistry.getInstance().getPooledTransactionDecoder(), |
|
|
|
|
|
|
|
RlpRegistry.getInstance().getPooledTransactionEncoder()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static class TransactionHandler { |
|
|
|
public static class TransactionHandler implements TransactionEncoder, TransactionDecoder { |
|
|
|
|
|
|
|
private final TransactionDecoder decoder; |
|
|
|
|
|
|
|
private final TransactionEncoder encoder; |
|
|
|
|
|
|
|
|
|
|
|
public Transaction readFrom(final RLPInput rlpInput) { |
|
|
|
public TransactionHandler(final TransactionDecoder decoder, final TransactionEncoder encoder) { |
|
|
|
return getDecoder().readFrom(rlpInput); |
|
|
|
this.decoder = decoder; |
|
|
|
} |
|
|
|
this.encoder = encoder; |
|
|
|
|
|
|
|
|
|
|
|
public Transaction readFrom(final Bytes bytes) { |
|
|
|
|
|
|
|
return getDecoder().readFrom(bytes); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Transaction decodeOpaqueBytes(final Bytes bytes) { |
|
|
|
|
|
|
|
return getDecoder().decodeOpaqueBytes(bytes); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void writeTo(final Transaction transaction, final RLPOutput output) { |
|
|
|
|
|
|
|
getEncoder().writeTo(transaction, output); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Bytes encodeOpaqueBytes(final Transaction transaction) { |
|
|
|
@Override |
|
|
|
return getEncoder().encodeOpaqueBytes(transaction); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private TransactionDecoder getDecoder() { |
|
|
|
|
|
|
|
return RlpRegistry.getInstance().getTransactionDecoder(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private TransactionEncoder getEncoder() { |
|
|
|
|
|
|
|
return RlpRegistry.getInstance().getTransactionEncoder(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class PooledTransactionHandler { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Transaction readFrom(final RLPInput rlpInput) { |
|
|
|
public Transaction readFrom(final RLPInput rlpInput) { |
|
|
|
return getDecoder().readFrom(rlpInput); |
|
|
|
return decoder.readFrom(rlpInput); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Transaction readFrom(final Bytes bytes) { |
|
|
|
public Transaction readFrom(final Bytes bytes) { |
|
|
|
return getDecoder().readFrom(bytes); |
|
|
|
return decoder.readFrom(bytes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Transaction decodeOpaqueBytes(final Bytes bytes) { |
|
|
|
public Transaction decodeOpaqueBytes(final Bytes bytes) { |
|
|
|
return getDecoder().decodeOpaqueBytes(bytes); |
|
|
|
return decoder.decodeOpaqueBytes(bytes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void writeTo(final Transaction transaction, final RLPOutput output) { |
|
|
|
public void writeTo(final Transaction transaction, final RLPOutput output) { |
|
|
|
getEncoder().writeTo(transaction, output); |
|
|
|
encoder.writeTo(transaction, output); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Bytes encodeOpaqueBytes(final Transaction transaction) { |
|
|
|
public Bytes encodeOpaqueBytes(final Transaction transaction) { |
|
|
|
return getEncoder().encodeOpaqueBytes(transaction); |
|
|
|
return encoder.encodeOpaqueBytes(transaction); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private TransactionDecoder getDecoder() { |
|
|
|
|
|
|
|
return RlpRegistry.getInstance().getPooledTransactionDecoder(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private TransactionEncoder getEncoder() { |
|
|
|
|
|
|
|
return RlpRegistry.getInstance().getPooledTransactionEncoder(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|