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
182b4468
Commit
182b4468
authored
Oct 18, 2020
by
Chiguireitor
Browse files
Merge branch 'master' of code.samourai.io:dojo/addrindexrs
parents
76700cc5
ade631cd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
4 deletions
+45
-4
Cargo.lock
Cargo.lock
+1
-1
Cargo.toml
Cargo.toml
+1
-1
RELEASE-NOTES.md
RELEASE-NOTES.md
+16
-1
src/index.rs
src/index.rs
+5
-0
src/query.rs
src/query.rs
+6
-1
src/rpc.rs
src/rpc.rs
+16
-0
No files found.
Cargo.lock
View file @
182b4468
...
...
@@ -2,7 +2,7 @@
# It is not intended for manual editing.
[[package]]
name = "addrindexrs"
version = "0.
3
.0"
version = "0.
4
.0"
dependencies = [
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
...
...
Cargo.toml
View file @
182b4468
[package]
name
=
"addrindexrs"
version
=
"0.
3
.0"
version
=
"0.
4
.0"
authors
=
[
"Roman Zeyde <me@romanzey.de>"
,
"kenshin-samourai <kenshin_samourai@tutanota.com>"
]
description
=
"An efficient address indexer in Rust"
license
=
"MIT"
...
...
RELEASE-NOTES.md
View file @
182b4468
...
...
@@ -3,18 +3,33 @@
## Releases ##
-
[
v0.4.0
](
#0_4_0
)
-
[
v0.3.0
](
#0_3_0
)
-
[
v0.2.0
](
#0_2_0
)
-
[
v0.1.0
](
#0_1_0
)
<a
name=
"0_4_0"
/>
## addrindexrs v0.4.0 ##
### Change log ###
-
[
#mr7
](
https://code.samourai.io/dojo/addrindexrs/-/merge_requests/7
)
reactivate api endpoints
#### Credits ###
-
kenshin-samourai
<a
name=
"0_3_0"
/>
## addrindexrs v0.3.0 ##
### Change log ###
-
[
#9
](
https://github.com/Samourai-Wallet/addrindexrs/pull/9
)
s
rewrite wriestore::flush()
-
[
#9
](
https://github.com/Samourai-Wallet/addrindexrs/pull/9
)
rewrite wri
t
estore::flush()
#### Credits ###
...
...
src/index.rs
View file @
182b4468
...
...
@@ -342,6 +342,11 @@ impl Index {
*
headers
=
read_indexed_headers
(
store
);
}
pub
fn
best_header
(
&
self
)
->
Option
<
HeaderEntry
>
{
let
headers
=
self
.headers
.read
()
.unwrap
();
headers
.header_by_blockhash
(
&
headers
.tip
())
.cloned
()
}
pub
fn
get_header
(
&
self
,
height
:
usize
)
->
Option
<
HeaderEntry
>
{
self
.headers
.read
()
...
...
src/query.rs
View file @
182b4468
...
...
@@ -7,7 +7,7 @@ use crate::errors::*;
use
crate
::
index
::{
TxInRow
,
TxOutRow
,
TxRow
};
use
crate
::
mempool
::
Tracker
;
use
crate
::
store
::
ReadStore
;
use
crate
::
util
::
HashPrefix
;
use
crate
::
util
::
{
HashPrefix
,
HeaderEntry
}
;
//
// Output of a Transaction
...
...
@@ -246,6 +246,11 @@ impl Query {
Ok
(
Status
{
confirmed
,
mempool
})
}
pub
fn
get_best_header
(
&
self
)
->
Result
<
HeaderEntry
>
{
let
last_header
=
self
.app
.index
()
.best_header
();
Ok
(
last_header
.chain_err
(||
"no headers indexed"
)
?
)
}
pub
fn
update_mempool
(
&
self
)
->
Result
<
()
>
{
self
.tracker
.write
()
.unwrap
()
.update
(
self
.app
.daemon
())
}
...
...
src/rpc.rs
View file @
182b4468
use
bitcoin
::
consensus
::
encode
::
serialize
;
use
bitcoin_hashes
::
hex
::{
FromHex
,
ToHex
};
use
bitcoin_hashes
::
sha256d
::
Hash
as
Sha256dHash
;
use
error_chain
::
ChainedError
;
...
...
@@ -60,6 +61,19 @@ impl Connection {
]))
}
fn
blockchain_headers_subscribe
(
&
mut
self
)
->
Result
<
Value
>
{
let
entry
=
self
.query
.get_best_header
()
?
;
let
hex_header
=
hex
::
encode
(
serialize
(
entry
.header
()));
let
result
=
json!
({
"hex"
:
hex_header
,
"height"
:
entry
.height
()});
Ok
(
result
)
}
fn
blockchain_scripthash_get_balance
(
&
self
,
_
params
:
&
[
Value
])
->
Result
<
Value
>
{
Ok
(
json!
({
"confirmed"
:
null
,
"unconfirmed"
:
null
}),
)
}
fn
blockchain_scripthash_get_history
(
&
self
,
params
:
&
[
Value
])
->
Result
<
Value
>
{
let
script_hash
=
hash_from_value
(
params
.get
(
0
))
.chain_err
(||
"bad script_hash"
)
?
;
let
status
=
self
.query
.status
(
&
script_hash
[
..
])
?
;
...
...
@@ -95,6 +109,8 @@ impl Connection {
fn
handle_command
(
&
mut
self
,
method
:
&
str
,
params
:
&
[
Value
],
id
:
&
Value
)
->
Result
<
Value
>
{
let
result
=
match
method
{
"blockchain.headers.subscribe"
=>
self
.blockchain_headers_subscribe
(),
"blockchain.scripthash.get_balance"
=>
self
.blockchain_scripthash_get_balance
(
&
params
),
"blockchain.scripthash.get_history"
=>
self
.blockchain_scripthash_get_history
(
&
params
),
"blockchain.scripthash.get_utxos"
=>
self
.blockchain_scripthash_get_utxos
(
&
params
),
"server.ping"
=>
Ok
(
Value
::
Null
),
...
...
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