public class ByzCoinRPC extends Object
ByzCoinRPC is the new skipchain service of the cothority that allows batching of transactions and simplified proofs. It is a permissioned blockchain with high throughput (100-1000 transactions) and a byzantine-tolerant consensus algorithm.
| Modifier and Type | Field and Description |
|---|---|
static int |
currentVersion |
| Modifier | Constructor and Description |
|---|---|
protected |
ByzCoinRPC()
For use by fromByzcoin
|
protected |
ByzCoinRPC(ByzCoinRPC bc)
For use by CalypsoRPC
|
|
ByzCoinRPC(Roster r,
Darc d,
java.time.Duration blockInterval)
This instantiates a new byzcoin object by asking the cothority to set up a new byzcoin.
|
| Modifier and Type | Method and Description |
|---|---|
List<String> |
checkAuthorization(DarcId id,
List<Identity> identities)
CheckAuthorization asks ByzCoin which of the rules stored in the latest version of the darc given by id
can be resolved with a combination of signatures given by identities.
|
boolean |
checkLiveness()
Verifies if the nodes representing the cothority are alive and reply to a ping.
|
static ByzCoinRPC |
fromByzCoin(Roster roster,
SkipblockId skipchainId)
Constructs a ByzCoinRPC from a known configuration.
|
Block |
getBlock(SkipblockId id)
Fetches a given block from the skipchain and returns the corresponding Block.
|
Config |
getConfig() |
SkipBlock |
getGenesisBlock() |
Darc |
getGenesisDarc() |
DarcInstance |
getGenesisDarcInstance() |
Block |
getLatestBlock()
Fetches the latest block from the Skipchain and returns the corresponding Block.
|
Proof |
getProof(InstanceId id)
Gets a proof from byzcoin to show that a given instance is stored in the
global state.
|
Roster |
getRoster() |
SkipchainRPC |
getSkipchain()
This should be used with caution.
|
Subscription |
getSubscription()
Getter for the subscription object.
|
static Darc |
makeGenesisDarc(Signer admin,
Roster roster)
Creates a genesis darc to use for the initialisation of Byzcoin.
|
ClientTransactionId |
sendTransaction(ClientTransaction t)
Sends a transaction to byzcoin, but doesn't wait for the inclusion of this transaction in a block.
|
ClientTransactionId |
sendTransactionAndWait(ClientTransaction t,
int wait)
Sends a transaction to byzcoin and waits for up to 'wait' blocks for the transaction to be
included in the global state.
|
void |
setBlockInterval(java.time.Duration newInterval,
List<Signer> admins,
int wait)
Sets the new block interval that ByzCoin uses to create new block.
|
void |
setMaxBlockSize(int newMaxSize,
List<Signer> admins,
int wait)
Sets the new block interval that ByzCoin uses to create new block.
|
void |
setRoster(Roster newRoster,
List<Signer> admins,
int wait)
Change the current roster of the ByzCoin ledger.
|
java.util.stream.Stream<SkipBlock> |
subscribeSkipBlock()
Subscribe to an infinite stream of future SkipBlocks.
|
void |
subscribeSkipBlock(Subscription.SkipBlockReceiver sbr)
Subscribes to all new skipBlocks that might arrive.
|
byte[] |
toBytes() |
void |
unsubscribeBlock(Subscription.SkipBlockReceiver sbr)
Unsubscribes a BlockReceiver.
|
void |
update()
Fetches the latest configuration and genesis darc from byzcoin.
|
public static final int currentVersion
public ByzCoinRPC(Roster r, Darc d, java.time.Duration blockInterval) throws CothorityException
r - is the roster to be usedd - is the genesis darcblockInterval - is the block interval between two blocksCothorityException - if something goes wrongprotected ByzCoinRPC()
protected ByzCoinRPC(ByzCoinRPC bc)
bc - the ByzCoinRPC to copy the config from.public ClientTransactionId sendTransaction(ClientTransaction t) throws CothorityException
t - is the client transaction holding one or more instructions to be sent to byzcoin.CothorityException - if something goes wrong if something goes wrongpublic ClientTransactionId sendTransactionAndWait(ClientTransaction t, int wait) throws CothorityException
t - is the client transaction holding one or more instructions to be sent to byzcoin.wait - indicates the number of blocks to wait for the transaction to be included.CothorityException - if the transaction has not been included within 'wait' blocks.public Proof getProof(InstanceId id) throws CothorityCommunicationException
id - is the id of the instance to be fetchedCothorityCommunicationException - if something goes wrongpublic void update()
throws CothorityException
CothorityException - if something goes wrong if something goes wrongpublic boolean checkLiveness()
public byte[] toBytes()
public Config getConfig()
public Darc getGenesisDarc()
public DarcInstance getGenesisDarcInstance() throws CothorityException
CothorityException - if something goes wrong if something goes wrongpublic SkipBlock getGenesisBlock()
public Roster getRoster()
public Block getBlock(SkipblockId id) throws CothorityCommunicationException, CothorityCryptoException
id - hash of the skipblock to fetchCothorityCommunicationException - if it couldn't contact the nodesCothorityCryptoException - if there's a problem with the cryptographypublic Block getLatestBlock() throws CothorityException
CothorityCryptoException - if there's a problem with the cryptographyCothorityExceptionpublic List<String> checkAuthorization(DarcId id, List<Identity> identities) throws CothorityCommunicationException
id - the base id of the darc to be searched foridentities - a list of identities that might signCothorityCommunicationException - if something goes wrongpublic SkipchainRPC getSkipchain()
public void subscribeSkipBlock(Subscription.SkipBlockReceiver sbr) throws CothorityCommunicationException
sbr - is a SkipBlockReceiver that will be called with any new block(s) available.CothorityCommunicationException - if something goes wrongpublic java.util.stream.Stream<SkipBlock> subscribeSkipBlock() throws CothorityCommunicationException
Each subscription request uses its own connection and the stream must be correctly closed to clean the resources
CothorityCommunicationException - if something goes wrong when establishing the connectionpublic void unsubscribeBlock(Subscription.SkipBlockReceiver sbr)
sbr - the SkipBlockReceiver to unsubscribe.public void setRoster(Roster newRoster, List<Signer> admins, int wait) throws CothorityException
newRoster - a new roster with one addition, one removal or one changeadmins - a list of admins needed to sign off on the changewait - how many blocks to wait for the new config to go inCothorityException - if something went wrong.public void setBlockInterval(java.time.Duration newInterval,
List<Signer> admins,
int wait)
throws CothorityException
The chosen interval can not be smaller than 5 seconds.
newInterval - how long to wait before starting to assemble a new blockadmins - a list of admins needed to sign off the new configurationwait - how many blocks to wait for the new config to go inCothorityExceptionpublic void setMaxBlockSize(int newMaxSize,
List<Signer> admins,
int wait)
throws CothorityException
The chosen interval can not be smaller than 5 seconds.
newMaxSize - new maximum size of the assembled blocks.admins - a list of admins needed to sign off the new configurationwait - how many blocks to wait for the new config to go inCothorityExceptionpublic static ByzCoinRPC fromByzCoin(Roster roster, SkipblockId skipchainId) throws CothorityException
roster - the roster to talk toskipchainId - the ID of the genesis skipblock, aka skipchain IDCothorityException - if something goes wrongpublic static Darc makeGenesisDarc(Signer admin, Roster roster) throws CothorityCryptoException
admin - the admin of Byzcoinroster - the nodes of ByzcoinCothorityCryptoException - if there's a problem with the cryptographypublic Subscription getSubscription()
Copyright © 2018. All rights reserved.