From d71030183372d0f3a3110da6f80d6e444d224242 Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Thu, 10 Nov 2016 16:02:47 -0800 Subject: [PATCH] Missing consensus file. --- core/src/consensus.rs | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 core/src/consensus.rs diff --git a/core/src/consensus.rs b/core/src/consensus.rs new file mode 100644 index 000000000..cb21b2834 --- /dev/null +++ b/core/src/consensus.rs @@ -0,0 +1,48 @@ +// Copyright 2016 The Grin Developers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! All the rules required for a cryptocurrency to have reach consensus across +//! the whole network are complex and hard to completely isolate. Some can be +//! simple parameters (like block reward), others complex algorithms (like +//! Merkle sum trees or reorg rules). However, as long as they're simple +//! emough, consensus-relevant constants and short functions should be kept +//! here. + +/// The block subsidy amount +pub const REWARD: u64 = 1_000_000_000; + +/// Block interval, in seconds +pub const BLOCK_TIME_SEC: u8 = 15; + +/// Cuckoo-cycle proof size (cycle length) +pub const PROOFSIZE: usize = 42; + +/// Default Cuckoo Cycle size shift used is 28. We may decide to increase it. +/// when difficuty increases. +pub const SIZESHIFT: u32 = 28; + +/// Default Cuckoo Cycle easiness, high enough to have good likeliness to find +/// a solution. +pub const EASINESS: u32 = 50; + +/// Max target hash, lowest difficulty +pub const MAX_TARGET: [u32; PROOFSIZE] = + [0xfff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff]; + +/// The maximum number of inputs or outputs a transaction may have +/// and be deserializable. Only for DoS protection. +pub const MAX_IN_OUT_LEN: u64 = 50000;