Skip to content

Commit efa46ac

Browse files
committed
Remove order
1 parent cf4ca47 commit efa46ac

28 files changed

+52
-8382
lines changed

core/src/codechain_machine.rs

+2-32
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use ckey::Address;
1919
use cstate::{StateError, TopState, TopStateView};
2020
use ctypes::errors::{HistoryError, SyntaxError};
21-
use ctypes::transaction::{Action, AssetTransferInput, OrderOnTransfer, Timelock};
21+
use ctypes::transaction::{Action, AssetTransferInput, Timelock};
2222
use ctypes::{CommonParams, Header};
2323

2424
use crate::block::{ExecutedBlock, IsBlock};
@@ -28,14 +28,12 @@ use crate::transaction::{SignedTransaction, UnverifiedTransaction};
2828

2929
pub struct CodeChainMachine {
3030
params: CommonParams,
31-
is_order_disabled: bool,
3231
}
3332

3433
impl CodeChainMachine {
3534
pub fn new(params: CommonParams) -> Self {
3635
CodeChainMachine {
3736
params,
38-
is_order_disabled: is_order_disabled(),
3937
}
4038
}
4139

@@ -58,7 +56,7 @@ impl CodeChainMachine {
5856
}
5957
.into())
6058
}
61-
tx.verify_with_params(common_params, self.is_order_disabled)?;
59+
tx.verify_with_params(common_params)?;
6260

6361
Ok(())
6462
}
@@ -79,7 +77,6 @@ impl CodeChainMachine {
7977
) -> Result<(), Error> {
8078
if let Action::TransferAsset {
8179
inputs,
82-
orders,
8380
expiration,
8481
..
8582
} = &tx.action
@@ -88,7 +85,6 @@ impl CodeChainMachine {
8885
if verify_timelock {
8986
Self::verify_transfer_timelock(inputs, header, client)?;
9087
}
91-
Self::verify_transfer_order_expired(orders, header)?;
9288
}
9389
// FIXME: Filter transactions.
9490
Ok(())
@@ -176,19 +172,6 @@ impl CodeChainMachine {
176172
Ok(())
177173
}
178174

179-
fn verify_transfer_order_expired(orders: &[OrderOnTransfer], header: &Header) -> Result<(), Error> {
180-
for order_tx in orders {
181-
if order_tx.order.expiration < header.timestamp() {
182-
return Err(HistoryError::OrderExpired {
183-
expiration: order_tx.order.expiration,
184-
timestamp: header.timestamp(),
185-
}
186-
.into())
187-
}
188-
}
189-
Ok(())
190-
}
191-
192175
pub fn min_cost(params: &CommonParams, action: &Action) -> u64 {
193176
match action {
194177
Action::MintAsset {
@@ -250,16 +233,3 @@ impl CodeChainMachine {
250233
Ok(())
251234
}
252235
}
253-
254-
fn is_order_disabled() -> bool {
255-
#[cfg(test)]
256-
const DEFAULT_ORDER_DISABLED: bool = false;
257-
#[cfg(not(test))]
258-
const DEFAULT_ORDER_DISABLED: bool = true;
259-
let var = std::env::var("ENABLE_ORDER");
260-
match var.as_ref().map(|x| x.trim()) {
261-
Ok(value) => !value.parse::<bool>().unwrap(),
262-
Err(std::env::VarError::NotPresent) => DEFAULT_ORDER_DISABLED,
263-
Err(err) => unreachable!("{:?}", err),
264-
}
265-
}

core/src/miner/mem_pool.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,6 @@ pub mod test {
12731273
burns: vec![],
12741274
inputs: vec![],
12751275
outputs: vec![],
1276-
orders: vec![],
12771276
metadata: "".into(),
12781277
approvals: vec![],
12791278
expiration: None,

core/src/transaction.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ impl UnverifiedTransaction {
137137
}
138138

139139
/// Verify transactiosn with the common params. Does not attempt signer recovery.
140-
pub fn verify_with_params(&self, params: &CommonParams, is_order_disabled: bool) -> Result<(), SyntaxError> {
140+
pub fn verify_with_params(&self, params: &CommonParams) -> Result<(), SyntaxError> {
141141
if self.network_id != params.network_id() {
142142
return Err(SyntaxError::InvalidNetworkId(self.network_id))
143143
}
144144
let byte_size = rlp::encode(self).to_vec().len();
145145
if byte_size >= params.max_body_size() {
146146
return Err(SyntaxError::TransactionIsTooBig)
147147
}
148-
self.action.verify_with_params(params, is_order_disabled)
148+
self.action.verify_with_params(params)
149149
}
150150
}
151151

rpc/src/v1/impls/devel.rs

-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ where
174174
burns: vec![],
175175
inputs: $inputs,
176176
outputs: $outputs,
177-
orders: vec![],
178177
metadata: "".to_string(),
179178
approvals: vec![],
180179
expiration: None,

rpc/src/v1/types/action.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use primitives::{Bytes, H160, H256};
2424
use rustc_serialize::hex::{FromHex, ToHex};
2525

2626
use super::super::errors::ConversionError;
27-
use super::{AssetMintOutput, AssetTransferInput, AssetTransferOutput, OrderOnTransfer};
27+
use super::{AssetMintOutput, AssetTransferInput, AssetTransferOutput};
2828

2929
#[derive(Debug, Deserialize, PartialEq)]
3030
#[serde(rename_all = "camelCase", tag = "type")]
@@ -48,7 +48,6 @@ pub enum Action {
4848
burns: Vec<AssetTransferInput>,
4949
inputs: Vec<AssetTransferInput>,
5050
outputs: Vec<AssetTransferOutput>,
51-
orders: Vec<OrderOnTransfer>,
5251

5352
metadata: String,
5453
approvals: Vec<Signature>,
@@ -151,7 +150,9 @@ pub enum ActionWithTracker {
151150
burns: Vec<AssetTransferInput>,
152151
inputs: Vec<AssetTransferInput>,
153152
outputs: Vec<AssetTransferOutput>,
154-
orders: Vec<OrderOnTransfer>,
153+
// NOTE: The orders field is removed in the core but it remains to
154+
// support the old version of the SDK
155+
orders: Vec<()>,
155156

156157
metadata: String,
157158
approvals: Vec<Signature>,
@@ -269,7 +270,6 @@ impl ActionWithTracker {
269270
burns,
270271
inputs,
271272
outputs,
272-
orders,
273273
metadata,
274274
approvals,
275275
expiration,
@@ -278,7 +278,7 @@ impl ActionWithTracker {
278278
burns: burns.into_iter().map(From::from).collect(),
279279
inputs: inputs.into_iter().map(From::from).collect(),
280280
outputs: outputs.into_iter().map(From::from).collect(),
281-
orders: orders.into_iter().map(From::from).collect(),
281+
orders: vec![],
282282
metadata,
283283
approvals,
284284
expiration: expiration.map(From::from),
@@ -449,20 +449,17 @@ impl TryFrom<Action> for ActionType {
449449
burns,
450450
inputs,
451451
outputs,
452-
orders,
453452

454453
metadata,
455454
approvals,
456455
expiration,
457456
} => {
458457
let outputs = outputs.into_iter().map(TryFrom::try_from).collect::<Result<_, _>>()?;
459-
let orders = orders.into_iter().map(TryFrom::try_from).collect::<Result<_, _>>()?;
460458
ActionType::TransferAsset {
461459
network_id,
462460
burns: burns.into_iter().map(From::from).collect(),
463461
inputs: inputs.into_iter().map(From::from).collect(),
464462
outputs,
465-
orders,
466463
metadata,
467464
approvals,
468465
expiration: expiration.map(From::from),

rpc/src/v1/types/asset.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::ops::Deref;
1818

1919
use cjson::uint::Uint;
2020
use cstate::{Asset as AssetType, OwnedAsset as OwnedAssetType};
21-
use primitives::{H160, H256};
21+
use primitives::H160;
2222
use rustc_serialize::hex::ToHex;
2323

2424
#[derive(Clone, Debug, PartialEq, Serialize)]
@@ -35,7 +35,6 @@ pub struct OwnedAsset {
3535
asset: Asset,
3636
lock_script_hash: H160,
3737
parameters: Vec<String>,
38-
order_hash: Option<H256>,
3938
}
4039

4140
impl From<AssetType> for Asset {
@@ -55,7 +54,6 @@ impl From<OwnedAssetType> for OwnedAsset {
5554
quantity: asset.quantity().into(),
5655
},
5756
lock_script_hash: *asset.lock_script_hash(),
58-
order_hash: *asset.order_hash(),
5957
parameters: asset.parameters().iter().map(Deref::deref).map(<[u8]>::to_hex).collect(),
6058
}
6159
}

rpc/src/v1/types/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ mod asset_input;
2020
mod asset_output;
2121
mod asset_scheme;
2222
mod block;
23-
mod order;
2423
mod text;
2524
mod transaction;
2625
mod unsigned_transaction;
@@ -29,9 +28,8 @@ mod work;
2928
use primitives::H256;
3029

3130
use self::asset::Asset;
32-
use self::asset_input::{AssetOutPoint, AssetTransferInput};
31+
use self::asset_input::AssetTransferInput;
3332
use self::asset_output::{AssetMintOutput, AssetTransferOutput};
34-
use self::order::OrderOnTransfer;
3533

3634
pub use self::action::{Action, ActionWithTracker};
3735
pub use self::asset::OwnedAsset;

rpc/src/v1/types/order.rs

-144
This file was deleted.

0 commit comments

Comments
 (0)