forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from XinFinOrg/v2-beta
- V2 consensus engine
- Loading branch information
Showing
99 changed files
with
10,105 additions
and
32,480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,51 @@ | ||
# XDPoSChain | ||
## XinFin Hybrid Blockchain | ||
|
||
XinFin Hybrid Blockchain is an Enterprise ready Blockchain for global trade and finance | ||
|
||
Visit: [XinFin.org](https://xinfin.org) | ||
Contribute: [Developer Docs](https://docs.xinfin.org) | ||
|
||
## XinFin Network XDPoS is community driven project to achieve the following | ||
|
||
- XinFin DPOS (XDPoS) consensus that selects 108 set of Masternodes to achieve a high throughput Energy efficient consensus with instant block finality | ||
|
||
- KYC Enforcement on Masternodes for Enterprise Adoption and compliance | ||
|
||
- Ability to port/relay limited set of data and transactions from privacy channels to public channel | ||
|
||
- Interoperability between applications hosted on Private Blockchains like Corda, Hyperledger, Quorum(JP Morgan) using relayers to XinFin Network | ||
|
||
- Customer Centric and consortium driven Governance to equally benefit the validators as well as providing comfort for large scale enterprise applications to be hosted on the Network. This achieves | ||
|
||
- Rapid Upgradability | ||
|
||
- DApps Standardisation for rapid commercialisation | ||
|
||
- Compliance with major global jurisdictions. | ||
|
||
### KYC for masternodes | ||
|
||
#### OVERVIEW | ||
|
||
To add a layer of KYC for masternodes in the current system and a sense of ownership amongst the masternodes hence tying such a cluster of masternodes to physical entity which can held accountable for its actions. | ||
|
||
#### Design | ||
|
||
We established a bidirectional connection between a candidate and its owner inorder to retrieve a candidate belonging to a specific owner & vice versa. | ||
|
||
All the masternodes are recognized by the KYC of their owners and hence are considered as a single verified entity ( for eg. while voting for invalid KYC, only one vote is considered per such cluster ) | ||
|
||
The contract is very strict in handing out penalty for invalid KYC, it results loss of all funds invested in all of its candidates. | ||
|
||
For eg. say A proposes condidates B,C,D by paying for its proposal cost. | ||
If at a later stage if some predecided amount of owners ( investors ) vote that a KYC for a A is invalid then A & all of its candidates (B,C,D) will lose their position & all their funds will be lost ( will remain with contract wallet ). | ||
|
||
### For developers | ||
|
||
### To contribute | ||
|
||
Simple create a pull request along with proper reasoning, we'll get back to you. | ||
|
||
Our Channels : [Telegram Developer Group](https://t.me/XinFinDevelopers) or [Public Slack Group](https://launchpass.com/xinfin-public) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// A countdown timer that will mostly be used by XDPoS v2 consensus engine | ||
package countdown | ||
|
||
import ( | ||
"sync" | ||
"time" | ||
|
||
"github.com/XinFinOrg/XDPoSChain/log" | ||
) | ||
|
||
type CountdownTimer struct { | ||
lock sync.RWMutex // Protects the Initilised field | ||
resetc chan int | ||
quitc chan chan struct{} | ||
initilised bool | ||
timeoutDuration time.Duration | ||
// Triggered when the countdown timer timeout for the `timeoutDuration` period, it will pass current timestamp to the callback function | ||
OnTimeoutFn func(time time.Time, i interface{}) error | ||
} | ||
|
||
func NewCountDown(duration time.Duration) *CountdownTimer { | ||
return &CountdownTimer{ | ||
resetc: make(chan int), | ||
quitc: make(chan chan struct{}), | ||
initilised: false, | ||
timeoutDuration: duration, | ||
} | ||
} | ||
|
||
// Completely stop the countdown timer from running. | ||
func (t *CountdownTimer) StopTimer() { | ||
q := make(chan struct{}) | ||
t.quitc <- q | ||
<-q | ||
} | ||
|
||
// Reset will start the countdown timer if it's already stopped, or simply reset the countdown time back to the defual `duration` | ||
func (t *CountdownTimer) Reset(i interface{}) { | ||
if !t.isInitilised() { | ||
t.setInitilised(true) | ||
go t.startTimer(i) | ||
} else { | ||
t.resetc <- 0 | ||
} | ||
} | ||
|
||
// A long running process that | ||
func (t *CountdownTimer) startTimer(i interface{}) { | ||
// Make sure we mark Initilised to false when we quit the countdown | ||
defer t.setInitilised(false) | ||
timer := time.NewTimer(t.timeoutDuration) | ||
// We start with a inf loop | ||
for { | ||
select { | ||
case q := <-t.quitc: | ||
log.Debug("Quit countdown timer") | ||
close(q) | ||
return | ||
case <-timer.C: | ||
log.Debug("Countdown time reached!") | ||
go func() { | ||
err := t.OnTimeoutFn(time.Now(), i) | ||
if err != nil { | ||
log.Error("OnTimeoutFn error", "error", err) | ||
} | ||
log.Debug("OnTimeoutFn processed") | ||
}() | ||
timer.Reset(t.timeoutDuration) | ||
case <-t.resetc: | ||
log.Debug("Reset countdown timer") | ||
timer.Reset(t.timeoutDuration) | ||
} | ||
} | ||
} | ||
|
||
// Set the desired value to Initilised with lock to avoid race condition | ||
func (t *CountdownTimer) setInitilised(value bool) { | ||
t.lock.Lock() | ||
defer t.lock.Unlock() | ||
t.initilised = value | ||
} | ||
|
||
func (t *CountdownTimer) isInitilised() bool { | ||
t.lock.Lock() | ||
defer t.lock.Unlock() | ||
return t.initilised | ||
} |
Oops, something went wrong.