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.
|
boolean |
checkStateChangeValidity(StateChange sc)
Checks if the state change is valid or has been tempered
|
static ByzCoinRPC |
fromByzCoin(Roster roster,
SkipblockId skipchainId)
Constructs a ByzCoinRPC from a known configuration.
|
List<StateChange> |
getAllInstanceVersion(InstanceId id)
Fetches all the state changes of the given instance
|
Block |
getBlock(SkipblockId id)
Fetches a given block from the skipchain and returns the corresponding Block.
|
Config |
getConfig() |
SkipBlock |
getGenesisBlock() |
Darc |
getGenesisDarc() |
SecureDarcInstance |
getGenesisDarcInstance() |
StateChange |
getInstanceVersion(InstanceId id,
long version)
Fetches the state change for the given version and instance
|
StateChange |
getLastInstanceVersion(InstanceId id)
Fetches the most recent state change for the given instance
|
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() |
SignerCounters |
getSignerCounters(List<String> signerIDs)
Gets the signer counters for the signer IDs.
|
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,
List<Long> adminCtrs,
int wait)
Sets the new block interval that ByzCoin uses to create new block.
|
void |
setMaxBlockSize(int newMaxSize,
List<Signer> admins,
List<Long> adminCtrs,
int wait)
Sets the new block interval that ByzCoin uses to create new block.
|
void |
setRoster(Roster newRoster,
List<Signer> admins,
List<Long> adminCtrs,
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 CothorityCommunicationException
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.CothorityCommunicationException - if the transaction has not been included within 'wait' blocks.public Proof getProof(InstanceId id) throws CothorityCommunicationException, CothorityCryptoException
id - is the id of the instance to be fetchedCothorityCommunicationException - if something goes wrongCothorityCryptoException - if the verification failspublic SignerCounters getSignerCounters(List<String> signerIDs) throws CothorityCommunicationException
signerIDs - the list of signer IDsCothorityCommunicationException - 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 SecureDarcInstance 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 StateChange getInstanceVersion(InstanceId id, long version) throws CothorityCommunicationException
id - the instance IDversion - the version of the state changeCothorityCommunicationException - if the state change doesn't exist or something went wrongpublic StateChange getLastInstanceVersion(InstanceId id) throws CothorityCommunicationException
id - the instance IDCothorityCommunicationException - if the instance doesn't exist or something went wrongpublic List<StateChange> getAllInstanceVersion(InstanceId id) throws CothorityCommunicationException
id - the instance IDCothorityCommunicationException - if the instance doesn't exist or something went wrongpublic boolean checkStateChangeValidity(StateChange sc) throws CothorityCommunicationException
sc - the state changeCothorityCommunicationException - if something went 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, List<Long> adminCtrs, int wait) throws CothorityException
When adding new nodes, it will take at least two blocks until they are completely active and ready to participate in the consensus. This is due to the time it takes for those blocks to download the global state.
newRoster - a new roster with one addition, one removal or one changeadmins - a list of admins needed to sign off on the changeadminCtrs - a list of monotonically increasing counters for every adminwait - 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,
List<Long> adminCtrs,
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 configurationadminCtrs - a list of monotonically increasing counters for every adminwait - how many blocks to wait for the new config to go inCothorityExceptionpublic void setMaxBlockSize(int newMaxSize,
List<Signer> admins,
List<Long> adminCtrs,
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 configurationadminCtrs - a list of monotonically increasing counters for every adminwait - 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 © 2019. All rights reserved.