当前位置:网站首页>Weekly snapshot of substrate technology 20220411
Weekly snapshot of substrate technology 20220411
2022-06-27 15:38:00 【InfoQ】
ECDSA Public key translation Ethereum address
pub trait ECDSAExt {
/// Returns Ethereum address calculated from this ECDSA public key.
fn to_eth_address(&self) -> Result<[u8; 20], ()>;
}impl ECDSAExt for Public {
fn to_eth_address(&self) -> Result<[u8; 20], ()> {
use k256::{elliptic_curve::sec1::ToEncodedPoint, PublicKey}; PublicKey::from_sec1_bytes(self.as_slice()).map_err(drop).and_then(|pub_key| {
// uncompress the key
let uncompressed = pub_key.to_encoded_point(false);
// convert to ETH address
<[u8; 20]>::try_from(
sp_io::hashing::keccak_256(&uncompressed.as_bytes()[1..])[12..].as_ref(),
)
.map_err(drop)
})
}
}
pub fn displaced_by_finalize_height(&self, number: N) -> FinalizationDisplaced<H, N> {
let boundary = if number == N::zero() {
return FinalizationDisplaced { leaves: BTreeMap::new() }
} else {
number - N::one()
}; let below_boundary = self.storage.range(&Reverse(boundary)..);
FinalizationDisplaced {
leaves: below_boundary.map(|(k, v)| (k.clone(), v.clone())).collect(),
}
}fn displaced_leaves_after_finalizing(
&self,
block_number: NumberFor<Block>,
) -> sp_blockchain::Result<Vec<Block::Hash>> {
Ok(self
.storage
.read()
.leaves
.displaced_by_finalize_height(block_number)
.leaves()
.cloned()
.collect::<Vec<_>>())
}边栏推荐
- Design of direct spread spectrum communication system based on FPGA (with main code)
- élégant pool de threadpoolexecutor personnalisé
- substrate 技术每周速览 20220411
- 洛谷入门1【顺序结构】题单题解
- How is the London Silver point difference calculated
- 16 -- 删除无效的括号
- Go error collection | when a function uses a return value with a parameter name
- Fundamentals of software engineering (I)
- 2022-2-16 learning the imitated Niuke project - Section 6 adding comments
- R language error
猜你喜欢

Professor huangxutao, a great master in CV field, was born at the age of 86. UIUC specially set up a doctoral scholarship to encourage cutting-edge students

SQL injection principle

AQS Abstract queue synchronizer

Lei Jun lost another great general, and liweixing, the founding employee of Xiaomi No. 12, left his post. He once had porridge to create Xiaomi; Intel's $5.4 billion acquisition of tower semiconductor

Fundamentals of software engineering (I)

All you want to know about large screen visualization is here

What is the London Silver code
![[kotlin] the next day](/img/13/9040e72de1243e827045b4572b0cd9.png)
[kotlin] the next day

Creation and use of static library (win10+vs2022

ICML 2022 | 阿⾥达摩院最新FEDformer,⻓程时序预测全⾯超越SOTA
随机推荐
Professor huangxutao, a great master in CV field, was born at the age of 86. UIUC specially set up a doctoral scholarship to encourage cutting-edge students
漏洞复现----34、yapi 远程命令执行漏洞
Typescript learning materials
Lei Jun lost another great general, and liweixing, the founding employee of Xiaomi No. 12, left his post. He once had porridge to create Xiaomi; Intel's $5.4 billion acquisition of tower semiconductor
Volatile and JMM
ICML 2022 | 阿⾥达摩院最新FEDformer,⻓程时序预测全⾯超越SOTA
16 -- 删除无效的括号
设计原则和思想:设计原则
Is flutter easy to learn? How to learn? The most complete introduction and actual combat of flutter in history. Take it away without thanks~
ThreadLocal之强、弱、软、虚引用
关于TensorFlow使用GPU加速
洛谷入门2【分支结构】题单题解
Handling methods for NVIDIA deepstream running delay, jamming and crash
What is the London Silver code
机械硬盘和ssd固态硬盘的原理对比分析
#27ES6的数值扩展
AQS抽象队列同步器
Centos8 PostgreSQL initialization error: initdb: error: invalid locale settings; check LANG and LC_* environment
Design of digital video signal processor based on FPGA (with main code)
Admixture usage document Cookbook