Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Chiguireitor
addrindexrs
Commits
c0959277
Commit
c0959277
authored
Nov 06, 2019
by
kenshin-samourai
Browse files
delete rust examples
parent
586563cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
119 deletions
+0
-119
examples/compact.rs
examples/compact.rs
+0
-29
examples/index.rs
examples/index.rs
+0
-41
examples/txid_collisions.rs
examples/txid_collisions.rs
+0
-49
No files found.
examples/compact.rs
deleted
100644 → 0
View file @
586563cc
/// Benchmark full compaction.
extern
crate
electrs
;
#[macro_use]
extern
crate
log
;
extern
crate
error_chain
;
use
electrs
::{
config
::
Config
,
errors
::
*
,
store
::
DBStore
};
use
error_chain
::
ChainedError
;
fn
run
(
config
:
Config
)
->
Result
<
()
>
{
if
!
config
.db_path
.exists
()
{
panic!
(
"DB {:?} must exist when running this benchmark!"
,
config
.db_path
);
}
let
store
=
DBStore
::
open
(
&
config
.db_path
,
/*low_memory=*/
true
);
store
.compact
();
Ok
(())
}
fn
main
()
{
if
let
Err
(
e
)
=
run
(
Config
::
from_args
())
{
error!
(
"{}"
,
e
.display_chain
());
}
}
examples/index.rs
deleted
100644 → 0
View file @
586563cc
/// Benchmark regular indexing flow (using JSONRPC), don't persist the resulting index.
extern
crate
electrs
;
extern
crate
error_chain
;
#[macro_use]
extern
crate
log
;
use
electrs
::{
cache
::
BlockTxIDsCache
,
config
::
Config
,
daemon
::
Daemon
,
errors
::
*
,
fake
::
FakeStore
,
index
::
Index
,
metrics
::
Metrics
,
signal
::
Waiter
,
};
use
error_chain
::
ChainedError
;
use
std
::
sync
::
Arc
;
fn
run
()
->
Result
<
()
>
{
let
signal
=
Waiter
::
start
();
let
config
=
Config
::
from_args
();
let
metrics
=
Metrics
::
new
(
config
.monitoring_addr
);
metrics
.start
();
let
cache
=
Arc
::
new
(
BlockTxIDsCache
::
new
(
0
,
&
metrics
));
let
daemon
=
Daemon
::
new
(
&
config
.daemon_dir
,
config
.daemon_rpc_addr
,
config
.cookie_getter
(),
config
.network_type
,
signal
.clone
(),
cache
,
&
metrics
,
)
?
;
let
fake_store
=
FakeStore
{};
let
index
=
Index
::
load
(
&
fake_store
,
&
daemon
,
&
metrics
,
config
.index_batch_size
)
?
;
index
.update
(
&
fake_store
,
&
signal
)
?
;
Ok
(())
}
fn
main
()
{
if
let
Err
(
e
)
=
run
()
{
error!
(
"{}"
,
e
.display_chain
());
}
}
examples/txid_collisions.rs
deleted
100644 → 0
View file @
586563cc
extern
crate
electrs
;
extern
crate
hex
;
extern
crate
log
;
use
electrs
::{
config
::
Config
,
store
::
DBStore
};
fn
max_collision
(
store
:
DBStore
,
prefix
:
&
[
u8
])
{
let
prefix_len
=
prefix
.len
();
let
mut
prev
:
Option
<
Vec
<
u8
>>
=
None
;
let
mut
collision_max
=
0
;
for
row
in
store
.iter_scan
(
prefix
)
{
assert
!
(
row
.key
.starts_with
(
prefix
));
if
let
Some
(
prev
)
=
prev
{
let
collision_len
=
prev
.iter
()
.zip
(
row
.key
.iter
())
.take_while
(|(
a
,
b
)|
a
==
b
)
.count
();
if
collision_len
>
collision_max
{
eprintln!
(
"{} bytes collision found:
\n
{:?}
\n
{:?}
\n
"
,
collision_len
-
prefix_len
,
revhex
(
&
prev
[
prefix_len
..
]),
revhex
(
&
row
.key
[
prefix_len
..
]),
);
collision_max
=
collision_len
;
}
}
prev
=
Some
(
row
.key
.to_vec
());
}
}
fn
revhex
(
value
:
&
[
u8
])
->
String
{
hex
::
encode
(
&
value
.iter
()
.cloned
()
.rev
()
.collect
::
<
Vec
<
u8
>>
())
}
fn
run
(
config
:
Config
)
{
if
!
config
.db_path
.exists
()
{
panic!
(
"DB {:?} must exist when running this tool!"
,
config
.db_path
);
}
let
store
=
DBStore
::
open
(
&
config
.db_path
,
/*low_memory=*/
false
);
max_collision
(
store
,
b
"T"
);
}
fn
main
()
{
run
(
Config
::
from_args
());
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment